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
2025-05-23 10:57:38 +02:00
parent 14ca086c72
commit a0a20bd0d0
3 changed files with 16 additions and 16 deletions

View File

@@ -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),

View File

@@ -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()

View File

@@ -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
}
}