Documentation ¶
Index ¶
- type Closer
- type Engine
- type GetSetCloser
- type Getter
- type MemoryStore
- type Option
- type RedisOption
- func WithRedisAuth(a string) RedisOption
- func WithRedisDialTLSSkipVerify(b bool) RedisOption
- func WithRedisEndpoint(e string) RedisOption
- func WithRedisIdleTimeout(d time.Duration) RedisOption
- func WithRedisMaxActive(m int) RedisOption
- func WithRedisMaxConnLifetime(d time.Duration) RedisOption
- func WithRedisMaxIdle(m int) RedisOption
- func WithRedisTLS(b bool) RedisOption
- func WithRedisWait(b bool) RedisOption
- type RedisStore
- type Setter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closer ¶
type Closer interface {
Close() error
}
Closer is an interface that wraps around the standard Close method.
type Engine ¶
type Engine uint8
Engine is the enum type for StorageEngine
const ( MemoryEngine Engine RedisEngine )
Enum types for Storage Engine
type GetSetCloser ¶
GetSetCloser is the interface that groups the basic Get, Set and Close methods.
func New ¶
func New(opts ...Option) (GetSetCloser, error)
New is a helper function that takes an arbitrary number of options and returns a GetSetCloser interface
type MemoryStore ¶
MemoryStore is the primary in-memory data storage and retrieval struct. It contains a sync.RWMutex and an internal map of `map[string][]byte` to store state that conforms to the Storage interface.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore returns a reference to a MemoryStore with an initialized internal map
func (*MemoryStore) Close ¶
func (s *MemoryStore) Close() error
Close implements the standard Close method for storage.
func (*MemoryStore) Get ¶
func (s *MemoryStore) Get(key string) ([]byte, error)
Get takes a key string and returns a byte slice and error. This method uses read locks. It returns an error if the key is not found.
type Option ¶
type Option func(*options)
Option is used for special Settings in Storage
func WithEngine ¶
WithEngine takes an Engine and returns an Option.
func WithRedisOptions ¶
func WithRedisOptions(opts ...RedisOption) Option
WithRedisOptions takes an arbitrary number of RedisOption and returns a Option
type RedisOption ¶
type RedisOption func(*redisOptions)
RedisOption is used for special Settings in Storage
func WithRedisAuth ¶
func WithRedisAuth(a string) RedisOption
WithRedisAuth takes a string and returns an RedisOption
func WithRedisDialTLSSkipVerify ¶
func WithRedisDialTLSSkipVerify(b bool) RedisOption
WithRedisDialTLSSkipVerify takes a bool and returns an RedisOption
func WithRedisEndpoint ¶
func WithRedisEndpoint(e string) RedisOption
WithRedisEndpoint takes a string and returns an RedisOption
func WithRedisIdleTimeout ¶
func WithRedisIdleTimeout(d time.Duration) RedisOption
WithRedisIdleTimeout takes a time.Duration and returns an RedisOption
func WithRedisMaxActive ¶
func WithRedisMaxActive(m int) RedisOption
WithRedisMaxActive takes an int and returns an RedisOption
func WithRedisMaxConnLifetime ¶
func WithRedisMaxConnLifetime(d time.Duration) RedisOption
WithRedisMaxConnLifetime takes a bool and returns an RedisOption
func WithRedisMaxIdle ¶
func WithRedisMaxIdle(m int) RedisOption
WithRedisMaxIdle takes an int and returns an RedisOption
func WithRedisTLS ¶
func WithRedisTLS(b bool) RedisOption
WithRedisTLS takes a bool and returns an RedisOption
func WithRedisWait ¶
func WithRedisWait(b bool) RedisOption
WithRedisWait takes a bool and returns an RedisOption
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is a struct with methods that conforms to the Storage Interface
func NewRedisStore ¶
func NewRedisStore(opts ...RedisOption) *RedisStore
NewRedisStore returns a RedisStore with StorageOptions mapped to Redis Pool settings. Optionally, if Auth is set, Auth is configured on Dial
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close implements the standard Close method for storage
type Setter ¶
type Setter interface {
Set(key string, value []byte, ttl time.Duration, timestamp time.Time) error
}
Setter is an interface that wraps around the standard Set method. To Prevent replay attacks, the ttl set on key should never be less than the minimumTTL, which is 2x the payload.MaxSubmitWindow. This prevents a specific type of replay attack in which a short-lived TTL is set, below the SubmitWindow horizon, and a slightly older message, also within the SubmitWindow time horizon is replayed and accepted due to no previous key being in the system. Timestamps outside of this window should be automatically forward-looking, but a proper Set method should always check that the submitted timestamp is greater than the existing one, if an existing one is found.