github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/cmd/datastore/zz_generated.options.go (about)

     1  // Code generated by github.com/ecordell/optgen. DO NOT EDIT.
     2  package datastore
     3  
     4  import (
     5  	defaults "github.com/creasty/defaults"
     6  	helpers "github.com/ecordell/optgen/helpers"
     7  	"time"
     8  )
     9  
    10  type ConfigOption func(c *Config)
    11  
    12  // NewConfigWithOptions creates a new Config with the passed in options set
    13  func NewConfigWithOptions(opts ...ConfigOption) *Config {
    14  	c := &Config{}
    15  	for _, o := range opts {
    16  		o(c)
    17  	}
    18  	return c
    19  }
    20  
    21  // NewConfigWithOptionsAndDefaults creates a new Config with the passed in options set starting from the defaults
    22  func NewConfigWithOptionsAndDefaults(opts ...ConfigOption) *Config {
    23  	c := &Config{}
    24  	defaults.MustSet(c)
    25  	for _, o := range opts {
    26  		o(c)
    27  	}
    28  	return c
    29  }
    30  
    31  // ToOption returns a new ConfigOption that sets the values from the passed in Config
    32  func (c *Config) ToOption() ConfigOption {
    33  	return func(to *Config) {
    34  		to.Engine = c.Engine
    35  		to.URI = c.URI
    36  		to.GCWindow = c.GCWindow
    37  		to.LegacyFuzzing = c.LegacyFuzzing
    38  		to.RevisionQuantization = c.RevisionQuantization
    39  		to.MaxRevisionStalenessPercent = c.MaxRevisionStalenessPercent
    40  		to.CredentialsProviderName = c.CredentialsProviderName
    41  		to.ReadConnPool = c.ReadConnPool
    42  		to.WriteConnPool = c.WriteConnPool
    43  		to.ReadOnly = c.ReadOnly
    44  		to.EnableDatastoreMetrics = c.EnableDatastoreMetrics
    45  		to.DisableStats = c.DisableStats
    46  		to.BootstrapFiles = c.BootstrapFiles
    47  		to.BootstrapFileContents = c.BootstrapFileContents
    48  		to.BootstrapOverwrite = c.BootstrapOverwrite
    49  		to.BootstrapTimeout = c.BootstrapTimeout
    50  		to.RequestHedgingEnabled = c.RequestHedgingEnabled
    51  		to.RequestHedgingInitialSlowValue = c.RequestHedgingInitialSlowValue
    52  		to.RequestHedgingMaxRequests = c.RequestHedgingMaxRequests
    53  		to.RequestHedgingQuantile = c.RequestHedgingQuantile
    54  		to.FollowerReadDelay = c.FollowerReadDelay
    55  		to.MaxRetries = c.MaxRetries
    56  		to.OverlapKey = c.OverlapKey
    57  		to.OverlapStrategy = c.OverlapStrategy
    58  		to.EnableConnectionBalancing = c.EnableConnectionBalancing
    59  		to.ConnectRate = c.ConnectRate
    60  		to.GCInterval = c.GCInterval
    61  		to.GCMaxOperationTime = c.GCMaxOperationTime
    62  		to.SpannerCredentialsFile = c.SpannerCredentialsFile
    63  		to.SpannerEmulatorHost = c.SpannerEmulatorHost
    64  		to.SpannerMinSessions = c.SpannerMinSessions
    65  		to.SpannerMaxSessions = c.SpannerMaxSessions
    66  		to.TablePrefix = c.TablePrefix
    67  		to.WatchBufferLength = c.WatchBufferLength
    68  		to.WatchBufferWriteTimeout = c.WatchBufferWriteTimeout
    69  		to.MigrationPhase = c.MigrationPhase
    70  	}
    71  }
    72  
    73  // DebugMap returns a map form of Config for debugging
    74  func (c Config) DebugMap() map[string]any {
    75  	debugMap := map[string]any{}
    76  	debugMap["Engine"] = helpers.DebugValue(c.Engine, false)
    77  	debugMap["URI"] = helpers.SensitiveDebugValue(c.URI)
    78  	debugMap["GCWindow"] = helpers.DebugValue(c.GCWindow, false)
    79  	debugMap["LegacyFuzzing"] = helpers.DebugValue(c.LegacyFuzzing, false)
    80  	debugMap["RevisionQuantization"] = helpers.DebugValue(c.RevisionQuantization, false)
    81  	debugMap["MaxRevisionStalenessPercent"] = helpers.DebugValue(c.MaxRevisionStalenessPercent, false)
    82  	debugMap["CredentialsProviderName"] = helpers.DebugValue(c.CredentialsProviderName, false)
    83  	debugMap["ReadConnPool"] = helpers.DebugValue(c.ReadConnPool, false)
    84  	debugMap["WriteConnPool"] = helpers.DebugValue(c.WriteConnPool, false)
    85  	debugMap["ReadOnly"] = helpers.DebugValue(c.ReadOnly, false)
    86  	debugMap["EnableDatastoreMetrics"] = helpers.DebugValue(c.EnableDatastoreMetrics, false)
    87  	debugMap["DisableStats"] = helpers.DebugValue(c.DisableStats, false)
    88  	debugMap["BootstrapFiles"] = helpers.DebugValue(c.BootstrapFiles, true)
    89  	debugMap["BootstrapFileContents"] = helpers.DebugValue(c.BootstrapFileContents, false)
    90  	debugMap["BootstrapOverwrite"] = helpers.DebugValue(c.BootstrapOverwrite, false)
    91  	debugMap["BootstrapTimeout"] = helpers.DebugValue(c.BootstrapTimeout, false)
    92  	debugMap["RequestHedgingEnabled"] = helpers.DebugValue(c.RequestHedgingEnabled, false)
    93  	debugMap["RequestHedgingInitialSlowValue"] = helpers.DebugValue(c.RequestHedgingInitialSlowValue, false)
    94  	debugMap["RequestHedgingMaxRequests"] = helpers.DebugValue(c.RequestHedgingMaxRequests, false)
    95  	debugMap["RequestHedgingQuantile"] = helpers.DebugValue(c.RequestHedgingQuantile, false)
    96  	debugMap["FollowerReadDelay"] = helpers.DebugValue(c.FollowerReadDelay, false)
    97  	debugMap["MaxRetries"] = helpers.DebugValue(c.MaxRetries, false)
    98  	debugMap["OverlapKey"] = helpers.DebugValue(c.OverlapKey, false)
    99  	debugMap["OverlapStrategy"] = helpers.DebugValue(c.OverlapStrategy, false)
   100  	debugMap["EnableConnectionBalancing"] = helpers.DebugValue(c.EnableConnectionBalancing, false)
   101  	debugMap["ConnectRate"] = helpers.DebugValue(c.ConnectRate, false)
   102  	debugMap["GCInterval"] = helpers.DebugValue(c.GCInterval, false)
   103  	debugMap["GCMaxOperationTime"] = helpers.DebugValue(c.GCMaxOperationTime, false)
   104  	debugMap["SpannerCredentialsFile"] = helpers.DebugValue(c.SpannerCredentialsFile, false)
   105  	debugMap["SpannerEmulatorHost"] = helpers.DebugValue(c.SpannerEmulatorHost, false)
   106  	debugMap["SpannerMinSessions"] = helpers.DebugValue(c.SpannerMinSessions, false)
   107  	debugMap["SpannerMaxSessions"] = helpers.DebugValue(c.SpannerMaxSessions, false)
   108  	debugMap["TablePrefix"] = helpers.DebugValue(c.TablePrefix, false)
   109  	debugMap["WatchBufferLength"] = helpers.DebugValue(c.WatchBufferLength, false)
   110  	debugMap["WatchBufferWriteTimeout"] = helpers.DebugValue(c.WatchBufferWriteTimeout, false)
   111  	debugMap["MigrationPhase"] = helpers.DebugValue(c.MigrationPhase, false)
   112  	return debugMap
   113  }
   114  
   115  // ConfigWithOptions configures an existing Config with the passed in options set
   116  func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config {
   117  	for _, o := range opts {
   118  		o(c)
   119  	}
   120  	return c
   121  }
   122  
   123  // WithOptions configures the receiver Config with the passed in options set
   124  func (c *Config) WithOptions(opts ...ConfigOption) *Config {
   125  	for _, o := range opts {
   126  		o(c)
   127  	}
   128  	return c
   129  }
   130  
   131  // WithEngine returns an option that can set Engine on a Config
   132  func WithEngine(engine string) ConfigOption {
   133  	return func(c *Config) {
   134  		c.Engine = engine
   135  	}
   136  }
   137  
   138  // WithURI returns an option that can set URI on a Config
   139  func WithURI(uRI string) ConfigOption {
   140  	return func(c *Config) {
   141  		c.URI = uRI
   142  	}
   143  }
   144  
   145  // WithGCWindow returns an option that can set GCWindow on a Config
   146  func WithGCWindow(gCWindow time.Duration) ConfigOption {
   147  	return func(c *Config) {
   148  		c.GCWindow = gCWindow
   149  	}
   150  }
   151  
   152  // WithLegacyFuzzing returns an option that can set LegacyFuzzing on a Config
   153  func WithLegacyFuzzing(legacyFuzzing time.Duration) ConfigOption {
   154  	return func(c *Config) {
   155  		c.LegacyFuzzing = legacyFuzzing
   156  	}
   157  }
   158  
   159  // WithRevisionQuantization returns an option that can set RevisionQuantization on a Config
   160  func WithRevisionQuantization(revisionQuantization time.Duration) ConfigOption {
   161  	return func(c *Config) {
   162  		c.RevisionQuantization = revisionQuantization
   163  	}
   164  }
   165  
   166  // WithMaxRevisionStalenessPercent returns an option that can set MaxRevisionStalenessPercent on a Config
   167  func WithMaxRevisionStalenessPercent(maxRevisionStalenessPercent float64) ConfigOption {
   168  	return func(c *Config) {
   169  		c.MaxRevisionStalenessPercent = maxRevisionStalenessPercent
   170  	}
   171  }
   172  
   173  // WithCredentialsProviderName returns an option that can set CredentialsProviderName on a Config
   174  func WithCredentialsProviderName(credentialsProviderName string) ConfigOption {
   175  	return func(c *Config) {
   176  		c.CredentialsProviderName = credentialsProviderName
   177  	}
   178  }
   179  
   180  // WithReadConnPool returns an option that can set ReadConnPool on a Config
   181  func WithReadConnPool(readConnPool ConnPoolConfig) ConfigOption {
   182  	return func(c *Config) {
   183  		c.ReadConnPool = readConnPool
   184  	}
   185  }
   186  
   187  // WithWriteConnPool returns an option that can set WriteConnPool on a Config
   188  func WithWriteConnPool(writeConnPool ConnPoolConfig) ConfigOption {
   189  	return func(c *Config) {
   190  		c.WriteConnPool = writeConnPool
   191  	}
   192  }
   193  
   194  // WithReadOnly returns an option that can set ReadOnly on a Config
   195  func WithReadOnly(readOnly bool) ConfigOption {
   196  	return func(c *Config) {
   197  		c.ReadOnly = readOnly
   198  	}
   199  }
   200  
   201  // WithEnableDatastoreMetrics returns an option that can set EnableDatastoreMetrics on a Config
   202  func WithEnableDatastoreMetrics(enableDatastoreMetrics bool) ConfigOption {
   203  	return func(c *Config) {
   204  		c.EnableDatastoreMetrics = enableDatastoreMetrics
   205  	}
   206  }
   207  
   208  // WithDisableStats returns an option that can set DisableStats on a Config
   209  func WithDisableStats(disableStats bool) ConfigOption {
   210  	return func(c *Config) {
   211  		c.DisableStats = disableStats
   212  	}
   213  }
   214  
   215  // WithBootstrapFiles returns an option that can append BootstrapFiless to Config.BootstrapFiles
   216  func WithBootstrapFiles(bootstrapFiles string) ConfigOption {
   217  	return func(c *Config) {
   218  		c.BootstrapFiles = append(c.BootstrapFiles, bootstrapFiles)
   219  	}
   220  }
   221  
   222  // SetBootstrapFiles returns an option that can set BootstrapFiles on a Config
   223  func SetBootstrapFiles(bootstrapFiles []string) ConfigOption {
   224  	return func(c *Config) {
   225  		c.BootstrapFiles = bootstrapFiles
   226  	}
   227  }
   228  
   229  // WithBootstrapFileContents returns an option that can append BootstrapFileContentss to Config.BootstrapFileContents
   230  func WithBootstrapFileContents(key string, value []byte) ConfigOption {
   231  	return func(c *Config) {
   232  		c.BootstrapFileContents[key] = value
   233  	}
   234  }
   235  
   236  // SetBootstrapFileContents returns an option that can set BootstrapFileContents on a Config
   237  func SetBootstrapFileContents(bootstrapFileContents map[string][]byte) ConfigOption {
   238  	return func(c *Config) {
   239  		c.BootstrapFileContents = bootstrapFileContents
   240  	}
   241  }
   242  
   243  // WithBootstrapOverwrite returns an option that can set BootstrapOverwrite on a Config
   244  func WithBootstrapOverwrite(bootstrapOverwrite bool) ConfigOption {
   245  	return func(c *Config) {
   246  		c.BootstrapOverwrite = bootstrapOverwrite
   247  	}
   248  }
   249  
   250  // WithBootstrapTimeout returns an option that can set BootstrapTimeout on a Config
   251  func WithBootstrapTimeout(bootstrapTimeout time.Duration) ConfigOption {
   252  	return func(c *Config) {
   253  		c.BootstrapTimeout = bootstrapTimeout
   254  	}
   255  }
   256  
   257  // WithRequestHedgingEnabled returns an option that can set RequestHedgingEnabled on a Config
   258  func WithRequestHedgingEnabled(requestHedgingEnabled bool) ConfigOption {
   259  	return func(c *Config) {
   260  		c.RequestHedgingEnabled = requestHedgingEnabled
   261  	}
   262  }
   263  
   264  // WithRequestHedgingInitialSlowValue returns an option that can set RequestHedgingInitialSlowValue on a Config
   265  func WithRequestHedgingInitialSlowValue(requestHedgingInitialSlowValue time.Duration) ConfigOption {
   266  	return func(c *Config) {
   267  		c.RequestHedgingInitialSlowValue = requestHedgingInitialSlowValue
   268  	}
   269  }
   270  
   271  // WithRequestHedgingMaxRequests returns an option that can set RequestHedgingMaxRequests on a Config
   272  func WithRequestHedgingMaxRequests(requestHedgingMaxRequests uint64) ConfigOption {
   273  	return func(c *Config) {
   274  		c.RequestHedgingMaxRequests = requestHedgingMaxRequests
   275  	}
   276  }
   277  
   278  // WithRequestHedgingQuantile returns an option that can set RequestHedgingQuantile on a Config
   279  func WithRequestHedgingQuantile(requestHedgingQuantile float64) ConfigOption {
   280  	return func(c *Config) {
   281  		c.RequestHedgingQuantile = requestHedgingQuantile
   282  	}
   283  }
   284  
   285  // WithFollowerReadDelay returns an option that can set FollowerReadDelay on a Config
   286  func WithFollowerReadDelay(followerReadDelay time.Duration) ConfigOption {
   287  	return func(c *Config) {
   288  		c.FollowerReadDelay = followerReadDelay
   289  	}
   290  }
   291  
   292  // WithMaxRetries returns an option that can set MaxRetries on a Config
   293  func WithMaxRetries(maxRetries int) ConfigOption {
   294  	return func(c *Config) {
   295  		c.MaxRetries = maxRetries
   296  	}
   297  }
   298  
   299  // WithOverlapKey returns an option that can set OverlapKey on a Config
   300  func WithOverlapKey(overlapKey string) ConfigOption {
   301  	return func(c *Config) {
   302  		c.OverlapKey = overlapKey
   303  	}
   304  }
   305  
   306  // WithOverlapStrategy returns an option that can set OverlapStrategy on a Config
   307  func WithOverlapStrategy(overlapStrategy string) ConfigOption {
   308  	return func(c *Config) {
   309  		c.OverlapStrategy = overlapStrategy
   310  	}
   311  }
   312  
   313  // WithEnableConnectionBalancing returns an option that can set EnableConnectionBalancing on a Config
   314  func WithEnableConnectionBalancing(enableConnectionBalancing bool) ConfigOption {
   315  	return func(c *Config) {
   316  		c.EnableConnectionBalancing = enableConnectionBalancing
   317  	}
   318  }
   319  
   320  // WithConnectRate returns an option that can set ConnectRate on a Config
   321  func WithConnectRate(connectRate time.Duration) ConfigOption {
   322  	return func(c *Config) {
   323  		c.ConnectRate = connectRate
   324  	}
   325  }
   326  
   327  // WithGCInterval returns an option that can set GCInterval on a Config
   328  func WithGCInterval(gCInterval time.Duration) ConfigOption {
   329  	return func(c *Config) {
   330  		c.GCInterval = gCInterval
   331  	}
   332  }
   333  
   334  // WithGCMaxOperationTime returns an option that can set GCMaxOperationTime on a Config
   335  func WithGCMaxOperationTime(gCMaxOperationTime time.Duration) ConfigOption {
   336  	return func(c *Config) {
   337  		c.GCMaxOperationTime = gCMaxOperationTime
   338  	}
   339  }
   340  
   341  // WithSpannerCredentialsFile returns an option that can set SpannerCredentialsFile on a Config
   342  func WithSpannerCredentialsFile(spannerCredentialsFile string) ConfigOption {
   343  	return func(c *Config) {
   344  		c.SpannerCredentialsFile = spannerCredentialsFile
   345  	}
   346  }
   347  
   348  // WithSpannerEmulatorHost returns an option that can set SpannerEmulatorHost on a Config
   349  func WithSpannerEmulatorHost(spannerEmulatorHost string) ConfigOption {
   350  	return func(c *Config) {
   351  		c.SpannerEmulatorHost = spannerEmulatorHost
   352  	}
   353  }
   354  
   355  // WithSpannerMinSessions returns an option that can set SpannerMinSessions on a Config
   356  func WithSpannerMinSessions(spannerMinSessions uint64) ConfigOption {
   357  	return func(c *Config) {
   358  		c.SpannerMinSessions = spannerMinSessions
   359  	}
   360  }
   361  
   362  // WithSpannerMaxSessions returns an option that can set SpannerMaxSessions on a Config
   363  func WithSpannerMaxSessions(spannerMaxSessions uint64) ConfigOption {
   364  	return func(c *Config) {
   365  		c.SpannerMaxSessions = spannerMaxSessions
   366  	}
   367  }
   368  
   369  // WithTablePrefix returns an option that can set TablePrefix on a Config
   370  func WithTablePrefix(tablePrefix string) ConfigOption {
   371  	return func(c *Config) {
   372  		c.TablePrefix = tablePrefix
   373  	}
   374  }
   375  
   376  // WithWatchBufferLength returns an option that can set WatchBufferLength on a Config
   377  func WithWatchBufferLength(watchBufferLength uint16) ConfigOption {
   378  	return func(c *Config) {
   379  		c.WatchBufferLength = watchBufferLength
   380  	}
   381  }
   382  
   383  // WithWatchBufferWriteTimeout returns an option that can set WatchBufferWriteTimeout on a Config
   384  func WithWatchBufferWriteTimeout(watchBufferWriteTimeout time.Duration) ConfigOption {
   385  	return func(c *Config) {
   386  		c.WatchBufferWriteTimeout = watchBufferWriteTimeout
   387  	}
   388  }
   389  
   390  // WithMigrationPhase returns an option that can set MigrationPhase on a Config
   391  func WithMigrationPhase(migrationPhase string) ConfigOption {
   392  	return func(c *Config) {
   393  		c.MigrationPhase = migrationPhase
   394  	}
   395  }