Documentation
¶
Index ¶
- Constants
- func CastKeyToString(key any) (string, error)
- func ConfigurableKvStoreFixtureSetFactory[T any](name string, data fixtures.NamedFixtures[*KvStoreFixture], ...) fixtures.FixtureSetFactory
- func DdbBaseName(settings *Settings) string
- func DynamoDbKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data fixtures.NamedFixtures[*KvStoreFixture], ...) fixtures.FixtureSetFactory
- func GetConfigurableKey(name string) string
- func Marshal(v any) ([]byte, error)
- func NewConfigurableKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (fixtures.FixtureWriter, error)
- func NewConfigurableKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store KvStore[T]) fixtures.FixtureWriter
- func NewDynamoDbKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, ...) (fixtures.FixtureWriter, error)
- func NewDynamoDbKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store KvStore[T]) fixtures.FixtureWriter
- func NewNamedKvStoreFixture[T any](name any, value T) *fixtures.NamedFixture[*KvStoreFixture]
- func NewRedisKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, ...) (fixtures.FixtureWriter, error)
- func NewRedisKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store KvStore[T]) fixtures.FixtureWriter
- func RedisBasename(name string) string
- func RedisConfigPostProcessor(config cfg.GosoConf) (bool, error)
- func RedisKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data fixtures.NamedFixtures[*KvStoreFixture], ...) fixtures.FixtureSetFactory
- func UniqKeys(keys []any) ([]any, error)
- func Unmarshal(data []byte, v any) error
- type ChainConfiguration
- type ChainKvStore
- type DdbDeleteItem
- type DdbItem
- type DdbSettings
- type ElementFactory
- type Factory
- type InMemoryConfiguration
- type InMemoryKvStore
- func (s *InMemoryKvStore[T]) Contains(_ context.Context, key any) (bool, error)
- func (s *InMemoryKvStore[T]) Delete(_ context.Context, key any) error
- func (s *InMemoryKvStore[T]) DeleteBatch(ctx context.Context, keys any) error
- func (s *InMemoryKvStore[T]) EstimateSize() *int64
- func (s *InMemoryKvStore[T]) Get(_ context.Context, key any, value *T) (bool, error)
- func (s *InMemoryKvStore[T]) GetBatch(ctx context.Context, keys any, values any) ([]any, error)
- func (s *InMemoryKvStore[T]) Put(_ context.Context, key any, value T) error
- func (s *InMemoryKvStore[T]) PutBatch(ctx context.Context, values any) error
- type InMemorySettings
- type KvStore
- func NewConfigurableKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (KvStore[T], error)
- func NewDdbKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (KvStore[T], error)
- func NewDdbKvStoreWithInterfaces[T any](repository ddb.Repository, settings *Settings) KvStore[T]
- func NewEmptyKvStore[T any]() KvStore[T]
- func NewEmptyKvStoreWithInterfaces[T any]() KvStore[T]
- func NewInMemoryKvStore[T any](_ context.Context, config cfg.Config, _ log.Logger, settings *Settings) (KvStore[T], error)
- func NewInMemoryKvStoreWithInterfaces[T any](settings *Settings) KvStore[T]
- func NewMetricStoreWithInterfaces[T any](store KvStore[T], settings *Settings) KvStore[T]
- func NewRedisKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (KvStore[T], error)
- func NewRedisKvStoreWithInterfaces[T any](client redis.Client, settings *Settings) KvStore[T]
- func ProvideConfigurableKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (KvStore[T], error)
- type KvStoreFixture
- type MetricStore
- func (s *MetricStore[T]) Contains(ctx context.Context, key any) (bool, error)
- func (s *MetricStore[T]) Delete(ctx context.Context, key any) error
- func (s *MetricStore[T]) DeleteBatch(ctx context.Context, keys any) error
- func (s *MetricStore[T]) Get(ctx context.Context, key any, value *T) (bool, error)
- func (s *MetricStore[T]) GetBatch(ctx context.Context, keys any, result any) ([]any, error)
- func (s *MetricStore[T]) Put(ctx context.Context, key any, value T) error
- func (s *MetricStore[T]) PutBatch(ctx context.Context, values any) error
- type RedisConfiguration
- type RedisSettings
- type Settings
- type SizedStore
Constants ¶
View Source
const ( TypeChain = "chain" TypeDdb = "ddb" TypeInMemory = "inMemory" TypeRedis = "redis" )
View Source
const (
ConfigKeyKvstore = "kvstore"
)
Variables ¶
This section is empty.
Functions ¶
func CastKeyToString ¶
func ConfigurableKvStoreFixtureSetFactory ¶ added in v0.37.0
func ConfigurableKvStoreFixtureSetFactory[T any](name string, data fixtures.NamedFixtures[*KvStoreFixture], options ...fixtures.FixtureSetOption) fixtures.FixtureSetFactory
func DdbBaseName ¶
func DynamoDbKvStoreFixtureSetFactory ¶ added in v0.37.0
func DynamoDbKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data fixtures.NamedFixtures[*KvStoreFixture], options ...fixtures.FixtureSetOption) fixtures.FixtureSetFactory
func GetConfigurableKey ¶
func NewConfigurableKvStoreFixtureWriter ¶ added in v0.37.0
func NewConfigurableKvStoreFixtureWriterWithInterfaces ¶ added in v0.37.0
func NewDynamoDbKvStoreFixtureWriter ¶ added in v0.37.0
func NewDynamoDbKvStoreFixtureWriterWithInterfaces ¶ added in v0.37.0
func NewNamedKvStoreFixture ¶ added in v0.37.0
func NewNamedKvStoreFixture[T any](name any, value T) *fixtures.NamedFixture[*KvStoreFixture]
func NewRedisKvStoreFixtureWriter ¶ added in v0.37.0
func NewRedisKvStoreFixtureWriterWithInterfaces ¶ added in v0.37.0
func RedisBasename ¶
func RedisConfigPostProcessor ¶ added in v0.43.0
func RedisKvStoreFixtureSetFactory ¶ added in v0.37.0
func RedisKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data fixtures.NamedFixtures[*KvStoreFixture], options ...fixtures.FixtureSetOption) fixtures.FixtureSetFactory
Types ¶
type ChainConfiguration ¶
type ChainConfiguration struct {
ModelId mdl.ModelId `cfg:"model_id"`
Type string `cfg:"type" default:"chain" validate:"eq=chain"`
Elements []string `cfg:"elements" validate:"min=1"`
Ddb DdbSettings `cfg:"ddb"`
Ttl time.Duration `cfg:"ttl"`
BatchSize int `cfg:"batch_size" default:"100" validate:"min=1"`
MissingCacheEnabled bool `cfg:"missing_cache_enabled" default:"false"`
MetricsEnabled bool `cfg:"metrics_enabled" default:"false"`
InMemory InMemoryConfiguration `cfg:"in_memory"`
Redis RedisConfiguration `cfg:"redis"`
}
type ChainKvStore ¶
type ChainKvStore[T any] interface { KvStore[T] Add(elementFactory ElementFactory[T]) error AddStore(store KvStore[T]) }
func NewChainKvStore ¶
type DdbDeleteItem ¶
type DdbDeleteItem struct {
Key string `json:"key" ddb:"key=hash"`
}
type DdbSettings ¶
type DdbSettings struct {
ClientName string `cfg:"client_name" default:"default"`
}
type ElementFactory ¶
type Factory ¶
type Factory[T any] func(elementFactory ElementFactory[T], settings *Settings) (KvStore[T], error)
type InMemoryConfiguration ¶
type InMemoryConfiguration struct {
MaxSize int64 `cfg:"max_size" default:"5000"`
Buckets uint32 `cfg:"buckets" default:"16"`
ItemsToPrune uint32 `cfg:"items_to_prune" default:"500"`
DeleteBuffer uint32 `cfg:"delete_buffer" default:"1024"`
PromoteBuffer uint32 `cfg:"promote_buffer" default:"1024"`
GetsPerPromote int32 `cfg:"gets_per_promote" default:"3"`
}
type InMemoryKvStore ¶
type InMemoryKvStore[T any] struct { // contains filtered or unexported fields }
func (*InMemoryKvStore[T]) Delete ¶
func (s *InMemoryKvStore[T]) Delete(_ context.Context, key any) error
func (*InMemoryKvStore[T]) DeleteBatch ¶
func (s *InMemoryKvStore[T]) DeleteBatch(ctx context.Context, keys any) error
func (*InMemoryKvStore[T]) EstimateSize ¶
func (s *InMemoryKvStore[T]) EstimateSize() *int64
type InMemorySettings ¶
type KvStore ¶
type KvStore[T any] interface { // Check if a key exists in the store. Contains(ctx context.Context, key any) (bool, error) // Retrieve a value from the store by the given key. If the value does // not exist, false is returned and value is not modified. // value should be a pointer to the model you want to retrieve. Get(ctx context.Context, key any, value *T) (bool, error) // Retrieve a set of values from the store. Each value is written to the // map in values at its key. Values should be something which can be converted to map[any]T. // Returns a list of missing keys in the store. GetBatch(ctx context.Context, keys any, values any) ([]any, error) // Write a value to the store Put(ctx context.Context, key any, value T) error // Write a batch of values to the store. Values should be something which // can be converted to map[any]T. PutBatch(ctx context.Context, values any) error // Remove the value with the given key from the store Delete(ctx context.Context, key any) error // Remove all values with the given keys from the store DeleteBatch(ctx context.Context, keys any) error }
func NewConfigurableKvStore ¶
func NewDdbKvStore ¶
func NewDdbKvStoreWithInterfaces ¶
func NewDdbKvStoreWithInterfaces[T any](repository ddb.Repository, settings *Settings) KvStore[T]
func NewEmptyKvStore ¶
func NewInMemoryKvStore ¶
func NewRedisKvStore ¶
type KvStoreFixture ¶ added in v0.37.0
func (KvStoreFixture) GetValue ¶ added in v0.37.0
func (k KvStoreFixture) GetValue() any
type MetricStore ¶
func (*MetricStore[T]) DeleteBatch ¶
func (s *MetricStore[T]) DeleteBatch(ctx context.Context, keys any) error
type RedisConfiguration ¶ added in v0.43.0
type RedisSettings ¶ added in v0.56.0
type RedisSettings struct {
KeyPrefixPattern string
}
type Settings ¶
type Settings struct {
mdl.ModelId
InMemorySettings
DdbSettings DdbSettings
RedisSettings RedisSettings
Ttl time.Duration
BatchSize int
MetricsEnabled bool
}
type SizedStore ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.