substore

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2022 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

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

func (s *SubStoreImpl) AddSubscriber(ctx context.Context, currencyID byte, fromAddr string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL