mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 07:41:02 +00:00
Add NopSchemator and NopSerializer
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
3542134100
commit
17a5bc51ca
3 changed files with 45 additions and 0 deletions
11
broadcast.go
11
broadcast.go
|
|
@ -27,6 +27,17 @@ type Serializer interface {
|
|||
Unmarshal([]byte, Message) error
|
||||
}
|
||||
|
||||
// NopSerializer represents a Serializer that doesn't do anything.
|
||||
var NopSerializer Serializer = &nopSerializer{}
|
||||
|
||||
type nopSerializer struct{}
|
||||
|
||||
// Marshal A no-op implementation of Serializer Marshall method.
|
||||
func (*nopSerializer) Marshal(Message) ([]byte, error) { return nil, nil }
|
||||
|
||||
// Unmarshal A no-op implementation of Serializer Unmarshal method.
|
||||
func (*nopSerializer) Unmarshal([]byte, Message) error { return nil }
|
||||
|
||||
// broadcaster is an interface for broadcasting messages.
|
||||
type broadcaster interface {
|
||||
SendSync(Message) error
|
||||
|
|
|
|||
|
|
@ -233,3 +233,31 @@ func (n *nopSharder) AddShards(ctx context.Context, index, field string, shards
|
|||
func (n *nopSharder) RemoveShard(ctx context.Context, index, field string, shard uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NopSchemator represents a Schemator that doesn't do anything.
|
||||
var NopSchemator Schemator = &nopSchemator{}
|
||||
|
||||
type nopSchemator struct{}
|
||||
|
||||
// Schema is a no-op implementation of the Schemator Schema method.
|
||||
func (*nopSchemator) Schema(ctx context.Context) (map[string]*Index, error) { return nil, nil }
|
||||
|
||||
// Index is a no-op implementation of the Schemator Index method.
|
||||
func (*nopSchemator) Index(ctx context.Context, name string) ([]byte, error) { return nil, nil }
|
||||
|
||||
// CreateIndex is a no-op implementation of the Schemator CreateIndex method.
|
||||
func (*nopSchemator) CreateIndex(ctx context.Context, name string, val []byte) error { return nil }
|
||||
|
||||
// DeleteIndex is a no-op implementation of the Schemator DeleteIndex method.
|
||||
func (*nopSchemator) DeleteIndex(ctx context.Context, name string) error { return nil }
|
||||
|
||||
// Field is a no-op implementation of the Schemator Field method.
|
||||
func (*nopSchemator) Field(ctx context.Context, index, field string) ([]byte, error) { return nil, nil }
|
||||
|
||||
// CreateField is a no-op implementation of the Schemator CreateField method.
|
||||
func (*nopSchemator) CreateField(ctx context.Context, index, field string, val []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteField is a no-op implementation of the Schemator DeleteField method.
|
||||
func (*nopSchemator) DeleteField(ctx context.Context, index, field string) error { return nil }
|
||||
|
|
|
|||
|
|
@ -213,6 +213,8 @@ type HolderConfig struct {
|
|||
OpenTransactionStore OpenTransactionStoreFunc
|
||||
OpenIDAllocator OpenIDAllocatorFunc
|
||||
TranslationSyncer TranslationSyncer
|
||||
Serializer Serializer
|
||||
Schemator disco.Schemator
|
||||
CacheFlushInterval time.Duration
|
||||
StatsClient stats.StatsClient
|
||||
NewAttrStore func(string) AttrStore
|
||||
|
|
@ -232,6 +234,8 @@ func DefaultHolderConfig() *HolderConfig {
|
|||
OpenTransactionStore: OpenInMemTransactionStore,
|
||||
OpenIDAllocator: func(string) (*idAllocator, error) { return &idAllocator{}, nil },
|
||||
TranslationSyncer: NopTranslationSyncer,
|
||||
Serializer: NopSerializer,
|
||||
Schemator: disco.NopSchemator,
|
||||
CacheFlushInterval: defaultCacheFlushInterval,
|
||||
StatsClient: stats.NopStatsClient,
|
||||
NewAttrStore: newNopAttrStore,
|
||||
|
|
@ -270,6 +274,8 @@ func NewHolder(path string, cfg *HolderConfig) *Holder {
|
|||
OpenTransactionStore: cfg.OpenTransactionStore,
|
||||
OpenIDAllocator: cfg.OpenIDAllocator,
|
||||
translationSyncer: cfg.TranslationSyncer,
|
||||
serializer: cfg.Serializer,
|
||||
schemator: cfg.Schemator,
|
||||
Logger: cfg.Logger,
|
||||
Opts: HolderOpts{StorageBackend: cfg.StorageConfig.Backend, RowcacheOn: cfg.RowcacheOn},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue