Documentation
¶
Index ¶
- Variables
- func RegisterConfigStoreCreatorFactory(name string, factory ConfigStoreCreatorFactory)
- type Backend
- type ConfigObjectCodec
- type ConfigStore
- type ConfigStoreBackend
- type ConfigStoreCreator
- type ConfigStoreCreatorFactory
- type IndexSchema
- type MetadataFuncs
- type ObjectMetadata
- type ObjectUnwrapper
- type StoreSchema
- type TagCarrier
Constants ¶
This section is empty.
Variables ¶
var ( ErrStoreAlreadyRegistered = errors.New("config store schema already registered") ErrUnknownStoreName = errors.New("unknown config store") )
var ErrNotFound = errors.New("not found")
ErrNotFound is returned by store implementations when a requested record does not exist. Gateway layers should check for this error rather than depending on storage-specific errors (e.g. gorm.ErrRecordNotFound).
Functions ¶
func RegisterConfigStoreCreatorFactory ¶
func RegisterConfigStoreCreatorFactory(name string, factory ConfigStoreCreatorFactory)
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend contains the generic schema registration and store lookup logic shared by persisted config store backends.
func NewBackend ¶
func NewBackend(creator ConfigStoreCreator) *Backend
func (*Backend) UsageDB ¶ added in v0.4.0
UsageDB forwards the usage.SQLDBProvider capability of the underlying creator so the generic Backend wrapper stays transparent. Without this, callers that type-assert the Backend (or an adapter wrapping it) to a usage SQL DB provider would silently fall back to a no-op metrics observer. Returns nil when the creator does not expose a usage database.
type ConfigObjectCodec ¶
type ConfigObjectCodec interface {
Encode(obj any) ([]byte, error)
Decode(data []byte) (any, error)
}
ConfigObjectCodec owns serialization and deserialization for one object family.
type ConfigStore ¶
type ConfigStore interface {
List(ctx context.Context) ([]any, error)
ListByTag(ctx context.Context, tag string) ([]any, error)
ListByTagPrefix(ctx context.Context, tagPrefix string) ([]any, error)
Create(ctx context.Context, obj any) error
Update(ctx context.Context, obj any) error
Delete(ctx context.Context, keyParts ...any) error
Get(ctx context.Context, keyParts ...any) (any, error)
GetByIndex(ctx context.Context, indexName string, value any) (any, error)
}
ConfigStore is a schema-bound generic store for one persisted object family.
type ConfigStoreBackend ¶
type ConfigStoreBackend interface {
Register(name string, storeSchema StoreSchema) error
Get(name string) (ConfigStore, error)
}
ConfigStoreBackend registers store schemas and returns schema-bound stores.
func OpenBackend ¶
func OpenBackendJSON ¶
func OpenBackendJSON(ctx context.Context, name string, raw json.RawMessage, logger *zap.Logger) (ConfigStoreBackend, error)
type ConfigStoreCreator ¶
type ConfigStoreCreator interface {
NewStore(storeSchema StoreSchema) (ConfigStore, error)
}
type ConfigStoreCreatorFactory ¶
type ConfigStoreCreatorFactory func(context.Context, json.RawMessage, *zap.Logger) (ConfigStoreCreator, error)
type IndexSchema ¶
type MetadataFuncs ¶
type MetadataFuncs struct {
PrimaryKeyFunc func(obj any) ([]any, error)
TagFunc func(obj any) (string, bool, error)
IndexesFunc func(obj any) (map[string]any, error)
}
MetadataFuncs adapts functions to ObjectMetadata.
func (MetadataFuncs) PrimaryKey ¶
func (m MetadataFuncs) PrimaryKey(obj any) ([]any, error)
type ObjectMetadata ¶
type ObjectMetadata interface {
PrimaryKey(obj any) ([]any, error)
Tag(obj any) (string, bool, error)
Indexes(obj any) (map[string]any, error)
}
ObjectMetadata extracts storage metadata from one persisted object family.
type ObjectUnwrapper ¶
type ObjectUnwrapper interface {
ConfigStoreObject() any
}
ObjectUnwrapper exposes the underlying persisted object when an adapter needs to attach extra metadata without changing the stored payload shape.
type StoreSchema ¶
type StoreSchema struct {
Name string
Kind string
Table string
PrimaryKeyColumns []string
TagColumn string
DataColumn string
IndexColumns []IndexSchema
Timestamped bool
Codec ConfigObjectCodec
Metadata ObjectMetadata
}
StoreSchema describes how one object family is persisted.
type TagCarrier ¶
type TagCarrier interface {
ConfigStoreTag() string
}
TagCarrier carries a tag value outside the persisted object payload.