Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Deprecate Types and Readme #50

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
[![Coverage Status](https://codecov.io/gh/ipfs/go-ipfs-provider/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-provider)
[![Travis CI](https://travis-ci.org/ipfs/go-ipfs-provider.svg?branch=master)](https://travis-ci.org/ipfs/go-ipfs-provider)

## ❗ This repo is no longer maintained.
👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/provider.
🏎️ Good news! There is [tooling and documentation](https://github.com/ipfs/boxo#migrating-to-boxo) to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, [here](https://github.com/ipfs/boxo/wiki/Copied-or-Migrated-Repos-FAQ).

## Background

The provider system is responsible for announcing and reannouncing to the ipfs network that a node has content.
Expand Down Expand Up @@ -51,12 +59,6 @@ sys.Provide(cid)
sys.Close()
```

## Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## License

This library is dual-licensed under Apache 2.0 and MIT terms.
Expand Down
8 changes: 8 additions & 0 deletions batched/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

var log = logging.Logger("provider.batched")

// Deprecated: use github.com/ipfs/boxo/provider/batched.BatchProvidingSystem
type BatchProvidingSystem struct {
ctx context.Context
close context.CancelFunc
Expand All @@ -30,9 +31,9 @@
initialReprovideDelaySet bool

rsys provideMany
keyProvider simple.KeyChanFunc

Check failure on line 34 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

simple.KeyChanFunc is deprecated: use github.com/ipfs/boxo/provider/simple.KeyChanFunc (SA1019)

Check failure on line 34 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

simple.KeyChanFunc is deprecated: use github.com/ipfs/boxo/provider/simple.KeyChanFunc (SA1019)

q *queue.Queue

Check failure on line 36 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

queue.Queue is deprecated: use github.com/ipfs/boxo/provider/queue.Queue (SA1019)

Check failure on line 36 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

queue.Queue is deprecated: use github.com/ipfs/boxo/provider/queue.Queue (SA1019)
ds datastore.Batching

reprovideCh chan cid.Cid
Expand All @@ -41,7 +42,7 @@
avgProvideDuration, lastReprovideDuration time.Duration
}

var _ provider.System = (*BatchProvidingSystem)(nil)

Check failure on line 45 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

provider.System is deprecated: use github.com/ipfs/boxo/provider.System (SA1019)

Check failure on line 45 in batched/system.go

View workflow job for this annotation

GitHub Actions / All

provider.System is deprecated: use github.com/ipfs/boxo/provider.System (SA1019)

type provideMany interface {
ProvideMany(ctx context.Context, keys []multihash.Multihash) error
Expand All @@ -50,10 +51,13 @@

// Option defines the functional option type that can be used to configure
// BatchProvidingSystem instances
//
// Deprecated: use github.com/ipfs/boxo/provider/batched.Option
type Option func(system *BatchProvidingSystem) error

var lastReprovideKey = datastore.NewKey("/provider/reprovide/lastreprovide")

// Deprecated: use github.com/ipfs/boxo/provider/batched.New
func New(provider provideMany, q *queue.Queue, opts ...Option) (*BatchProvidingSystem, error) {
s := &BatchProvidingSystem{
reprovideInterval: time.Hour * 24,
Expand Down Expand Up @@ -98,20 +102,23 @@
return s, nil
}

// Deprecated: use github.com/ipfs/boxo/provider/batched.Datastore
func Datastore(batching datastore.Batching) Option {
return func(system *BatchProvidingSystem) error {
system.ds = batching
return nil
}
}

// Deprecated: use github.com/ipfs/boxo/provider/batched.ReproviderInterval
func ReproviderInterval(duration time.Duration) Option {
return func(system *BatchProvidingSystem) error {
system.reprovideInterval = duration
return nil
}
}

// Deprecated: use github.com/ipfs/boxo/provider/batched.KeyProvider
func KeyProvider(fn simple.KeyChanFunc) Option {
return func(system *BatchProvidingSystem) error {
system.keyProvider = fn
Expand Down Expand Up @@ -403,6 +410,7 @@
return true
}

// Deprecated: use github.com/ipfs/boxo/provider/batched.BatchedProviderStats
type BatchedProviderStats struct {
TotalProvides, LastReprovideBatchSize int
AvgProvideDuration, LastReprovideDuration time.Duration
Expand Down
2 changes: 2 additions & 0 deletions offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
type offlineProvider struct{}

// NewOfflineProvider creates a ProviderSystem that does nothing
//
// Deprecated: use github.com/ipfs/boxo/provider.NewOfflineProvider
func NewOfflineProvider() System {
return &offlineProvider{}
}
Expand Down
4 changes: 4 additions & 0 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

// Provider announces blocks to the network
//
// Deprecated: use github.com/ipfs/boxo/provider.Provider
type Provider interface {
// Run is used to begin processing the provider work
Run()
Expand All @@ -17,6 +19,8 @@ type Provider interface {
}

// Reprovider reannounces blocks to the network
//
// Deprecated: use github.com/ipfs/boxo/provider.Reprovider
type Reprovider interface {
// Run is used to begin processing the reprovider work and waiting for reprovide triggers
Run()
Expand Down
4 changes: 4 additions & 0 deletions queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var log = logging.Logger("provider.queue")
// Best-effort durability just means that cids in the process of being provided when a
// crash or shutdown occurs may be in the queue when the node is brought back online
// depending on whether the underlying datastore has synchronous or asynchronous writes.
//
// Deprecated: use github.com/ipfs/boxo/provider/queue.Queue
type Queue struct {
// used to differentiate queues in datastore
// e.g. provider vs reprovider
Expand All @@ -32,6 +34,8 @@ type Queue struct {
}

// NewQueue creates a queue for cids
//
// Deprecated: use github.com/ipfs/boxo/provider/queue.NewQueue
func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue, error) {
namespaced := namespace.Wrap(ds, datastore.NewKey("/"+name+"/queue/"))
cancelCtx, cancel := context.WithCancel(ctx)
Expand Down
10 changes: 10 additions & 0 deletions simple/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
var logP = logging.Logger("provider.simple")

// Provider announces blocks to the network
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.Provider
type Provider struct {
ctx context.Context
// the CIDs for which provide announcements should be made
queue *q.Queue

Check failure on line 24 in simple/provider.go

View workflow job for this annotation

GitHub Actions / All

q.Queue is deprecated: use github.com/ipfs/boxo/provider/queue.Queue (SA1019)

Check failure on line 24 in simple/provider.go

View workflow job for this annotation

GitHub Actions / All

q.Queue is deprecated: use github.com/ipfs/boxo/provider/queue.Queue (SA1019)
// used to announce providing to the network
contentRouting routing.ContentRouting
// how long to wait for announce to complete before giving up
Expand All @@ -30,23 +32,31 @@

// Option defines the functional option type that can be used to configure
// provider instances
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.Option
type Option func(*Provider)

// WithTimeout is an option to set a timeout on a provider
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.WithTimeout
func WithTimeout(timeout time.Duration) Option {
return func(p *Provider) {
p.timeout = timeout
}
}

// MaxWorkers is an option to set the max workers on a provider
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.MaxWorkers
func MaxWorkers(count int) Option {
return func(p *Provider) {
p.workerLimit = count
}
}

// NewProvider creates a provider that announces blocks to the network using a content router
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.NewProvider
func NewProvider(ctx context.Context, queue *q.Queue, contentRouting routing.ContentRouting, options ...Option) *Provider {
p := &Provider{
ctx: ctx,
Expand Down
14 changes: 14 additions & 0 deletions simple/reprovide.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ import (
var logR = logging.Logger("reprovider.simple")

// ErrClosed is returned by Trigger when operating on a closed reprovider.
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.ErrClosed
var ErrClosed = errors.New("reprovider service stopped")

// KeyChanFunc is function streaming CIDs to pass to content routing
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.KeyChanFunc
type KeyChanFunc func(context.Context) (<-chan cid.Cid, error)

// Reprovider reannounces blocks to the network
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.Reprovider
type Reprovider struct {
// Reprovider context. Cancel to stop, then wait on closedCh.
ctx context.Context
Expand All @@ -45,6 +51,8 @@ type Reprovider struct {
}

// NewReprovider creates new Reprovider instance.
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.NewReprovider
func NewReprovider(ctx context.Context, reprovideInterval time.Duration, rsys routing.ContentRouting, keyProvider KeyChanFunc) *Reprovider {
ctx, cancel := context.WithCancel(ctx)
return &Reprovider{
Expand Down Expand Up @@ -171,6 +179,8 @@ func (rp *Reprovider) Trigger(ctx context.Context) error {
// Strategies

// NewBlockstoreProvider returns key provider using bstore.AllKeysChan
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.NewBlockstoreProvider
func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
return bstore.AllKeysChan(ctx)
Expand All @@ -179,12 +189,16 @@ func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {

// Pinner interface defines how the simple.Reprovider wants to interact
// with a Pinning service
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.Pinner
type Pinner interface {
DirectKeys(ctx context.Context) ([]cid.Cid, error)
RecursiveKeys(ctx context.Context) ([]cid.Cid, error)
}

// NewPinnedProvider returns provider supplying pinned keys
//
// Deprecated: use github.com/ipfs/boxo/provider/simple.NewPinnedProvider
func NewPinnedProvider(onlyRoots bool, pinning Pinner, fetchConfig fetcher.Factory) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
set, err := pinSet(ctx, pinning, fetchConfig, onlyRoots)
Expand Down
4 changes: 4 additions & 0 deletions system.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

// System defines the interface for interacting with the value
// provider system
//
// Deprecated: use github.com/ipfs/boxo/provider.System
type System interface {
Run()
Close() error
Expand All @@ -21,6 +23,8 @@ type system struct {
}

// NewSystem constructs a new provider system from a provider and reprovider
//
// Deprecated: use github.com/ipfs/boxo/provider.NewSystem
func NewSystem(provider Provider, reprovider Reprovider) System {
return &system{provider, reprovider}
}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.8.1"
"version": "v0.8.2"
}