graph/db: rename KVStoreOptions to StoreOptions

We'll re-use this options struct for our SQLStore too. So here we rename
it to be more generic.
This commit is contained in:
Elle Mouton committed 2025-05-23 11:01:17 +02:00
1 parent 14ca086c72
commit a0a20bd0d0
3 files changed
+16 -16

No files matched your search

+1 -1
View File
@@ -1026,7 +1026,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
"instances") "instances")
} }
graphDBOptions := []graphdb.KVStoreOptionModifier{ graphDBOptions := []graphdb.StoreOptionModifier{
graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize), graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize),
graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize), graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize),
graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval), graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval),
+1 -1
View File
@@ -203,7 +203,7 @@ var _ V1Store = (*KVStore)(nil)
// NewKVStore allocates a new KVStore backed by a DB instance. The // NewKVStore allocates a new KVStore backed by a DB instance. The
// returned instance has its own unique reject cache and channel cache. // 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) { error) {
opts := DefaultOptions() opts := DefaultOptions()
+14 -14
View File
@@ -61,8 +61,8 @@ func WithPreAllocCacheNumNodes(n int) ChanGraphOption {
} }
} }
// KVStoreOptions holds parameters for tuning and customizing a graph.DB. // StoreOptions holds parameters for tuning and customizing a graph DB.
type KVStoreOptions struct { type StoreOptions struct {
// RejectCacheSize is the maximum number of rejectCacheEntries to hold // RejectCacheSize is the maximum number of rejectCacheEntries to hold
// in the rejection cache. // in the rejection cache.
RejectCacheSize int RejectCacheSize int
@@ -81,37 +81,37 @@ type KVStoreOptions struct {
NoMigration bool NoMigration bool
} }
// DefaultOptions returns a KVStoreOptions populated with default values. // DefaultOptions returns a StoreOptions populated with default values.
func DefaultOptions() *KVStoreOptions { func DefaultOptions() *StoreOptions {
return &KVStoreOptions{ return &StoreOptions{
RejectCacheSize: DefaultRejectCacheSize, RejectCacheSize: DefaultRejectCacheSize,
ChannelCacheSize: DefaultChannelCacheSize, ChannelCacheSize: DefaultChannelCacheSize,
NoMigration: false, NoMigration: false,
} }
} }
// KVStoreOptionModifier is a function signature for modifying the default // StoreOptionModifier is a function signature for modifying the default
// KVStoreOptions. // StoreOptions.
type KVStoreOptionModifier func(*KVStoreOptions) type StoreOptionModifier func(*StoreOptions)
// WithRejectCacheSize sets the RejectCacheSize to n. // WithRejectCacheSize sets the RejectCacheSize to n.
func WithRejectCacheSize(n int) KVStoreOptionModifier { func WithRejectCacheSize(n int) StoreOptionModifier {
return func(o *KVStoreOptions) { return func(o *StoreOptions) {
o.RejectCacheSize = n o.RejectCacheSize = n
} }
} }
// WithChannelCacheSize sets the ChannelCacheSize to n. // WithChannelCacheSize sets the ChannelCacheSize to n.
func WithChannelCacheSize(n int) KVStoreOptionModifier { func WithChannelCacheSize(n int) StoreOptionModifier {
return func(o *KVStoreOptions) { return func(o *StoreOptions) {
o.ChannelCacheSize = n o.ChannelCacheSize = n
} }
} }
// WithBatchCommitInterval sets the batch commit interval for the interval batch // WithBatchCommitInterval sets the batch commit interval for the interval batch
// schedulers. // schedulers.
func WithBatchCommitInterval(interval time.Duration) KVStoreOptionModifier { func WithBatchCommitInterval(interval time.Duration) StoreOptionModifier {
return func(o *KVStoreOptions) { return func(o *StoreOptions) {
o.BatchCommitInterval = interval o.BatchCommitInterval = interval
} }
} }