Documentation
¶
Index ¶
- type Opts
- type SubStore
- type SubStoreImpl
- func (s *SubStoreImpl) AddSubscriber(ctx context.Context, currencyID byte, fromAddr string) error
- func (s *SubStoreImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
- func (s *SubStoreImpl) ListSubscribers(ctx context.Context, currencyID byte) (<-chan string, <-chan error)
- func (s *SubStoreImpl) RemoveSubscriber(ctx context.Context, currencyID byte, fromAddr string) error
- func (s *SubStoreImpl) Shutdown()
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 sub store.
Path string
}
Opts is the options for sub store.
type SubStore ¶
type SubStore interface {
// AddSubscriber is used to add a subscriber.
//
// @input - context, currency id, from address.
//
// @output - error.
AddSubscriber(ctx context.Context, currencyID byte, fromAddr string) error
// RemoveSubscriber is used to remove a subscriber.
//
// @input - context, currency id, from address.
//
// @output - error.
RemoveSubscriber(ctx context.Context, currencyID byte, fromAddr string) error
// ListCurrencyIDs is used to list all currencies.
//
// @input - context.
//
// @output - currency id chan out, error chan out.
ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
// ListSubscribers is used to list all subscribers.
//
// @input - context, currency id.
//
// @output - subscriber chan out, error chan out.
ListSubscribers(ctx context.Context, currencyID byte) (<-chan string, <-chan error)
}
SubStore is the interface for a storage that stores all subscribers.
type SubStoreImpl ¶
type SubStoreImpl struct {
// contains filtered or unexported fields
}
SubStoreImpl is the implementation of the SubStore interface.
func NewSubStoreImpl ¶
func NewSubStoreImpl(ctx context.Context, opts Opts) (*SubStoreImpl, error)
NewSubStoreImpl creates a new SubStoreImpl.
@input - context, options.
@output - store, error.
func (*SubStoreImpl) AddSubscriber ¶
AddSubscriber is used to add a subscriber.
@input - context, currency id, from address.
@output - error.
func (*SubStoreImpl) ListCurrencyIDs ¶
func (s *SubStoreImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
ListCurrencyIDs is used to list all currencies.
@input - context.
@output - currency id chan out, error chan out.
func (*SubStoreImpl) ListSubscribers ¶
func (s *SubStoreImpl) ListSubscribers(ctx context.Context, currencyID byte) (<-chan string, <-chan error)
ListSubscribers is used to list all subscribers.
@input - context, currency id.
@output - subscriber chan out, error chan out.
func (*SubStoreImpl) RemoveSubscriber ¶
func (s *SubStoreImpl) RemoveSubscriber(ctx context.Context, currencyID byte, fromAddr string) error
RemoveSubscriber is used to remove a subscriber.
@input - context, currency id, from address.
@output - error.
func (*SubStoreImpl) Shutdown ¶
func (s *SubStoreImpl) Shutdown()
Shutdown safely shuts down the component.