Documentation ¶
Index ¶
- type Opts
- type PieceServingManager
- type PieceServingManagerImpl
- func (s *PieceServingManagerImpl) DeregisterPublishHook()
- func (s *PieceServingManagerImpl) Inspect(ctx context.Context, id cid.Cid, currencyID byte) (bool, *big.Int, error)
- func (s *PieceServingManagerImpl) ListCurrencyIDs(ctx context.Context, id cid.Cid) (<-chan byte, <-chan error)
- func (s *PieceServingManagerImpl) ListPieceIDs(ctx context.Context) (<-chan cid.Cid, <-chan error)
- func (s *PieceServingManagerImpl) RegisterPublishFunc(hook func(cid.Cid))
- func (s *PieceServingManagerImpl) Serve(ctx context.Context, id cid.Cid, currencyID byte, ppb *big.Int) error
- func (s *PieceServingManagerImpl) Shutdown()
- func (s *PieceServingManagerImpl) Stop(ctx context.Context, id cid.Cid, currencyID byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct { // The datastore path of the piece serving manager. Path string }
Opts is the options for piece serving manager.
type PieceServingManager ¶
type PieceServingManager interface { // Serve is used to serve a piece. // // @input - context, piece id, currency id, price-per-byte. // // @output - error. Serve(ctx context.Context, id cid.Cid, currencyID byte, ppb *big.Int) error // Stop is used to stop serving a piece. // // @input - context, piece id, currency id. // // @output - error. Stop(ctx context.Context, id cid.Cid, currencyID byte) error // Inspect is used to inspect a piece serving state. // // @input - context, piece id, currency id. // // @output - if served, price-per-byte, error. Inspect(ctx context.Context, id cid.Cid, currencyID byte) (bool, *big.Int, error) // ListPieceIDs lists all pieces. // // @input - context. // // @output - piece id chan out, error chan out. ListPieceIDs(ctx context.Context) (<-chan cid.Cid, <-chan error) // ListCurrencyIDs lists all currencies. // // @input - context, piece id. // // @output - currency chan out, error chan out. ListCurrencyIDs(ctx context.Context, id cid.Cid) (<-chan byte, <-chan error) // RegisterPublishHook adds a hook function to call when a new serving presents. // // @input - hook function. RegisterPublishFunc(hook func(cid.Cid)) // DeregisterPublishHook deregister the hook function. DeregisterPublishHook() }
PieceServingManager is the interface for a manager that manages all served pieces.
type PieceServingManagerImpl ¶
type PieceServingManagerImpl struct {
// contains filtered or unexported fields
}
PieceServingManagerImpl is the implementation of the PieceServingManager interface.
func NewPieceServingManager ¶
func NewPieceServingManager(ctx context.Context, opts Opts) (*PieceServingManagerImpl, error)
NewPieceServingManager creates a new PieceServingManager.
@input - context, options.
@output - piece serving manager, error.
func (*PieceServingManagerImpl) DeregisterPublishHook ¶
func (s *PieceServingManagerImpl) DeregisterPublishHook()
DeregisterPublishHook deregister the hook function.
func (*PieceServingManagerImpl) Inspect ¶
func (s *PieceServingManagerImpl) Inspect(ctx context.Context, id cid.Cid, currencyID byte) (bool, *big.Int, error)
Inspect is used to inspect a piece serving state.
@input - context, piece id, currency id.
@output - if served, price-per-byte, error.
func (*PieceServingManagerImpl) ListCurrencyIDs ¶
func (s *PieceServingManagerImpl) ListCurrencyIDs(ctx context.Context, id cid.Cid) (<-chan byte, <-chan error)
ListCurrencyIDs lists all currencies.
@input - context, piece id.
@output - currency chan out, error chan out.
func (*PieceServingManagerImpl) ListPieceIDs ¶
func (s *PieceServingManagerImpl) ListPieceIDs(ctx context.Context) (<-chan cid.Cid, <-chan error)
ListPieceIDs lists all pieces.
@input - context.
@output - piece id chan out, error chan out.
func (*PieceServingManagerImpl) RegisterPublishFunc ¶
func (s *PieceServingManagerImpl) RegisterPublishFunc(hook func(cid.Cid))
RegisterPublishHook adds a hook function to call when a new serving presents.
@input - hook function.
func (*PieceServingManagerImpl) Serve ¶
func (s *PieceServingManagerImpl) Serve(ctx context.Context, id cid.Cid, currencyID byte, ppb *big.Int) error
Serve is used to serve a piece.
@input - context, piece id, currency id, price-per-byte.
@output - error.
func (*PieceServingManagerImpl) Shutdown ¶
func (s *PieceServingManagerImpl) Shutdown()
Shutdown safely shuts down the component.