storage

package
v2.0.437+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTP

type HTTP struct {
	sync.Mutex
	// contains filtered or unexported fields
}

HTTP represents a storage which uses HTTP requests to store/retrieve messages.

func NewHTTP

func NewHTTP() *HTTP

NewHTTP creates a new HTTP storage.

func (*HTTP) Close

func (s *HTTP) Close() error

Close gracefully terminates the storage and ensures that every related resource is properly disposed.

func (*HTTP) Configure

func (s *HTTP) Configure(config map[string]interface{}) (err error)

Configure configures the storage. The config parameter provided is loosely typed, since various storage mechanisms will require different configurations.

func (*HTTP) Name

func (s *HTTP) Name() string

Name returns the name of the provider.

func (*HTTP) QueryLast

func (s *HTTP) QueryLast(ssid []uint32, limit int) (ch <-chan []byte, err error)

QueryLast performs a query and attempts to fetch last n messages where n is specified by limit argument. It returns a channel which will be ranged over to retrieve messages asynchronously.

func (*HTTP) Store

func (s *HTTP) Store(m *message.Message) error

Store is used to store a message, the SSID provided must be a full SSID SSID, where first element should be a contract ID. The time resolution for TTL will be in seconds. The function is executed synchronously and it returns an error if some error was encountered during storage.

type InMemory

type InMemory struct {
	Query func(string, []byte) (message.Awaiter, error) // The cluster request function.
	// contains filtered or unexported fields
}

InMemory represents a storage which does nothing.

func NewInMemory

func NewInMemory(q func(string, []byte) (message.Awaiter, error)) *InMemory

NewInMemory creates a new in-memory storage.

func (*InMemory) Close

func (s *InMemory) Close() error

Close gracefully terminates the storage and ensures that every related resource is properly disposed.

func (*InMemory) Configure

func (s *InMemory) Configure(config map[string]interface{}) error

Configure configures the storage. The config parameter provided is loosely typed, since various storage mechanisms will require different configurations.

func (*InMemory) Name

func (s *InMemory) Name() string

Name returns the name of the provider.

func (*InMemory) OnRequest

func (s *InMemory) OnRequest(queryType string, payload []byte) ([]byte, bool)

OnRequest handles an incoming cluster lookup request.

func (*InMemory) QueryLast

func (s *InMemory) QueryLast(ssid []uint32, limit int) (<-chan []byte, error)

QueryLast performs a query and attempts to fetch last n messages where n is specified by limit argument. It returns a channel which will be ranged over to retrieve messages asynchronously.

func (*InMemory) Store

func (s *InMemory) Store(m *message.Message) error

Store is used to store a message, the SSID provided must be a full SSID SSID, where first element should be a contract ID. The time resolution for TTL will be in seconds. The function is executed synchronously and it returns an error if some error was encountered during storage.

type Noop

type Noop struct{}

Noop represents a storage which does nothing.

func NewNoop

func NewNoop() *Noop

NewNoop creates a new no-op storage.

func (*Noop) Close

func (s *Noop) Close() error

Close gracefully terminates the storage and ensures that every related resource is properly disposed.

func (*Noop) Configure

func (s *Noop) Configure(config map[string]interface{}) error

Configure configures the storage. The config parameter provided is loosely typed, since various storage mechanisms will require different configurations.

func (*Noop) Name

func (s *Noop) Name() string

Name returns the name of the provider.

func (*Noop) QueryLast

func (s *Noop) QueryLast(ssid []uint32, limit int) (<-chan []byte, error)

QueryLast performs a query and attempts to fetch last n messages where n is specified by limit argument. It returns a channel which will be ranged over to retrieve messages asynchronously.

func (*Noop) Store

func (s *Noop) Store(m *message.Message) error

Store is used to store a message, the SSID provided must be a full SSID SSID, where first element should be a contract ID. The time resolution for TTL will be in seconds. The function is executed synchronously and it returns an error if some error was encountered during storage.

type Storage

type Storage interface {
	config.Provider
	io.Closer

	// Store is used to store a message, the SSID provided must be a full SSID
	// SSID, where first element should be a contract ID. The time resolution
	// for TTL will be in seconds. The function is executed synchronously and
	// it returns an error if some error was encountered during storage.
	Store(m *message.Message) error

	// QueryLast performs a query and attempts to fetch last n messages where
	// n is specified by limit argument. It returns a channel which will be
	// ranged over to retrieve messages asynchronously.
	QueryLast(ssid []uint32, limit int) (<-chan []byte, error)
}

Storage represents a message storage contract that message storage provides must fulfill.

Jump to

Keyboard shortcuts

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