diff --git a/config_builder.go b/config_builder.go index 26e1e8a40..aef188b53 100644 --- a/config_builder.go +++ b/config_builder.go @@ -1026,7 +1026,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase( "instances") } - graphDBOptions := []graphdb.OptionModifier{ + graphDBOptions := []graphdb.KVStoreOptionModifier{ graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize), graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize), graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval), diff --git a/graph/db/graph.go b/graph/db/graph.go index 217302ca9..ac52a0306 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -12,8 +12,8 @@ type ChannelGraph struct { } // NewChannelGraph creates a new ChannelGraph instance with the given backend. -func NewChannelGraph(db kvdb.Backend, options ...OptionModifier) (*ChannelGraph, - error) { +func NewChannelGraph(db kvdb.Backend, options ...KVStoreOptionModifier) ( + *ChannelGraph, error) { store, err := NewKVStore(db, options...) if err != nil { diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 6f327d73b..8ddafc179 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -198,7 +198,7 @@ type KVStore struct { // 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 ...OptionModifier) (*KVStore, +func NewKVStore(db kvdb.Backend, options ...KVStoreOptionModifier) (*KVStore, error) { opts := DefaultOptions() @@ -4827,8 +4827,8 @@ func (c *chanGraphNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo, // MakeTestGraph creates a new instance of the KVStore for testing // purposes. -func MakeTestGraph(t testing.TB, modifiers ...OptionModifier) (*ChannelGraph, - error) { +func MakeTestGraph(t testing.TB, modifiers ...KVStoreOptionModifier) ( + *ChannelGraph, error) { opts := DefaultOptions() for _, modifier := range modifiers { diff --git a/graph/db/options.go b/graph/db/options.go index a512ec4bc..a6cf2e909 100644 --- a/graph/db/options.go +++ b/graph/db/options.go @@ -20,8 +20,8 @@ const ( DefaultPreAllocCacheNumNodes = 15000 ) -// Options holds parameters for tuning and customizing a graph.DB. -type Options struct { +// KVStoreOptions holds parameters for tuning and customizing a graph.DB. +type KVStoreOptions struct { // RejectCacheSize is the maximum number of rejectCacheEntries to hold // in the rejection cache. RejectCacheSize int @@ -49,9 +49,9 @@ type Options struct { NoMigration bool } -// DefaultOptions returns an Options populated with default values. -func DefaultOptions() *Options { - return &Options{ +// DefaultOptions returns a KVStoreOptions populated with default values. +func DefaultOptions() *KVStoreOptions { + return &KVStoreOptions{ RejectCacheSize: DefaultRejectCacheSize, ChannelCacheSize: DefaultChannelCacheSize, PreAllocCacheNumNodes: DefaultPreAllocCacheNumNodes, @@ -60,41 +60,42 @@ func DefaultOptions() *Options { } } -// OptionModifier is a function signature for modifying the default Options. -type OptionModifier func(*Options) +// KVStoreOptionModifier is a function signature for modifying the default +// KVStoreOptions. +type KVStoreOptionModifier func(*KVStoreOptions) // WithRejectCacheSize sets the RejectCacheSize to n. -func WithRejectCacheSize(n int) OptionModifier { - return func(o *Options) { +func WithRejectCacheSize(n int) KVStoreOptionModifier { + return func(o *KVStoreOptions) { o.RejectCacheSize = n } } // WithChannelCacheSize sets the ChannelCacheSize to n. -func WithChannelCacheSize(n int) OptionModifier { - return func(o *Options) { +func WithChannelCacheSize(n int) KVStoreOptionModifier { + return func(o *KVStoreOptions) { o.ChannelCacheSize = n } } // WithPreAllocCacheNumNodes sets the PreAllocCacheNumNodes to n. -func WithPreAllocCacheNumNodes(n int) OptionModifier { - return func(o *Options) { +func WithPreAllocCacheNumNodes(n int) KVStoreOptionModifier { + return func(o *KVStoreOptions) { o.PreAllocCacheNumNodes = n } } // WithBatchCommitInterval sets the batch commit interval for the interval batch // schedulers. -func WithBatchCommitInterval(interval time.Duration) OptionModifier { - return func(o *Options) { +func WithBatchCommitInterval(interval time.Duration) KVStoreOptionModifier { + return func(o *KVStoreOptions) { o.BatchCommitInterval = interval } } // WithUseGraphCache sets the UseGraphCache option to the given value. -func WithUseGraphCache(use bool) OptionModifier { - return func(o *Options) { +func WithUseGraphCache(use bool) KVStoreOptionModifier { + return func(o *KVStoreOptions) { o.UseGraphCache = use } }