diff --git a/config_builder.go b/config_builder.go index 708e79d8f..3277d72ea 100644 --- a/config_builder.go +++ b/config_builder.go @@ -1026,7 +1026,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase( "instances") } - graphDBOptions := []graphdb.KVStoreOptionModifier{ + graphDBOptions := []graphdb.StoreOptionModifier{ graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize), graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize), graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval), diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 3e1e009e2..187fc13af 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -203,7 +203,7 @@ var _ V1Store = (*KVStore)(nil) // NewKVStore allocates a new KVStore backed by a DB instance. The // returned instance has its own unique reject cache and channel cache. -func NewKVStore(db kvdb.Backend, options ...KVStoreOptionModifier) (*KVStore, +func NewKVStore(db kvdb.Backend, options ...StoreOptionModifier) (*KVStore, error) { opts := DefaultOptions() diff --git a/graph/db/options.go b/graph/db/options.go index 7bff8637a..3edda6602 100644 --- a/graph/db/options.go +++ b/graph/db/options.go @@ -61,8 +61,8 @@ func WithPreAllocCacheNumNodes(n int) ChanGraphOption { } } -// KVStoreOptions holds parameters for tuning and customizing a graph.DB. -type KVStoreOptions struct { +// StoreOptions holds parameters for tuning and customizing a graph DB. +type StoreOptions struct { // RejectCacheSize is the maximum number of rejectCacheEntries to hold // in the rejection cache. RejectCacheSize int @@ -81,37 +81,37 @@ type KVStoreOptions struct { NoMigration bool } -// DefaultOptions returns a KVStoreOptions populated with default values. -func DefaultOptions() *KVStoreOptions { - return &KVStoreOptions{ +// DefaultOptions returns a StoreOptions populated with default values. +func DefaultOptions() *StoreOptions { + return &StoreOptions{ RejectCacheSize: DefaultRejectCacheSize, ChannelCacheSize: DefaultChannelCacheSize, NoMigration: false, } } -// KVStoreOptionModifier is a function signature for modifying the default -// KVStoreOptions. -type KVStoreOptionModifier func(*KVStoreOptions) +// StoreOptionModifier is a function signature for modifying the default +// StoreOptions. +type StoreOptionModifier func(*StoreOptions) // WithRejectCacheSize sets the RejectCacheSize to n. -func WithRejectCacheSize(n int) KVStoreOptionModifier { - return func(o *KVStoreOptions) { +func WithRejectCacheSize(n int) StoreOptionModifier { + return func(o *StoreOptions) { o.RejectCacheSize = n } } // WithChannelCacheSize sets the ChannelCacheSize to n. -func WithChannelCacheSize(n int) KVStoreOptionModifier { - return func(o *KVStoreOptions) { +func WithChannelCacheSize(n int) StoreOptionModifier { + return func(o *StoreOptions) { o.ChannelCacheSize = n } } // WithBatchCommitInterval sets the batch commit interval for the interval batch // schedulers. -func WithBatchCommitInterval(interval time.Duration) KVStoreOptionModifier { - return func(o *KVStoreOptions) { +func WithBatchCommitInterval(interval time.Duration) StoreOptionModifier { + return func(o *StoreOptions) { o.BatchCommitInterval = interval } }