github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/cmd/testserver/zz_generated.options.go (about) 1 // Code generated by github.com/ecordell/optgen. DO NOT EDIT. 2 package testserver 3 4 import ( 5 util "github.com/authzed/spicedb/pkg/cmd/util" 6 defaults "github.com/creasty/defaults" 7 helpers "github.com/ecordell/optgen/helpers" 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.GRPCServer = c.GRPCServer 35 to.ReadOnlyGRPCServer = c.ReadOnlyGRPCServer 36 to.HTTPGateway = c.HTTPGateway 37 to.ReadOnlyHTTPGateway = c.ReadOnlyHTTPGateway 38 to.LoadConfigs = c.LoadConfigs 39 to.MaximumUpdatesPerWrite = c.MaximumUpdatesPerWrite 40 to.MaximumPreconditionCount = c.MaximumPreconditionCount 41 to.MaxCaveatContextSize = c.MaxCaveatContextSize 42 to.MaxRelationshipContextSize = c.MaxRelationshipContextSize 43 to.MaxReadRelationshipsLimit = c.MaxReadRelationshipsLimit 44 to.MaxDeleteRelationshipsLimit = c.MaxDeleteRelationshipsLimit 45 to.MaxLookupResourcesLimit = c.MaxLookupResourcesLimit 46 to.MaxBulkExportRelationshipsLimit = c.MaxBulkExportRelationshipsLimit 47 } 48 } 49 50 // DebugMap returns a map form of Config for debugging 51 func (c Config) DebugMap() map[string]any { 52 debugMap := map[string]any{} 53 debugMap["GRPCServer"] = helpers.DebugValue(c.GRPCServer, false) 54 debugMap["ReadOnlyGRPCServer"] = helpers.DebugValue(c.ReadOnlyGRPCServer, false) 55 debugMap["HTTPGateway"] = helpers.DebugValue(c.HTTPGateway, false) 56 debugMap["ReadOnlyHTTPGateway"] = helpers.DebugValue(c.ReadOnlyHTTPGateway, false) 57 debugMap["LoadConfigs"] = helpers.DebugValue(c.LoadConfigs, false) 58 debugMap["MaximumUpdatesPerWrite"] = helpers.DebugValue(c.MaximumUpdatesPerWrite, false) 59 debugMap["MaximumPreconditionCount"] = helpers.DebugValue(c.MaximumPreconditionCount, false) 60 debugMap["MaxCaveatContextSize"] = helpers.DebugValue(c.MaxCaveatContextSize, false) 61 debugMap["MaxRelationshipContextSize"] = helpers.DebugValue(c.MaxRelationshipContextSize, false) 62 debugMap["MaxReadRelationshipsLimit"] = helpers.DebugValue(c.MaxReadRelationshipsLimit, false) 63 debugMap["MaxDeleteRelationshipsLimit"] = helpers.DebugValue(c.MaxDeleteRelationshipsLimit, false) 64 debugMap["MaxLookupResourcesLimit"] = helpers.DebugValue(c.MaxLookupResourcesLimit, false) 65 debugMap["MaxBulkExportRelationshipsLimit"] = helpers.DebugValue(c.MaxBulkExportRelationshipsLimit, false) 66 return debugMap 67 } 68 69 // ConfigWithOptions configures an existing Config with the passed in options set 70 func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config { 71 for _, o := range opts { 72 o(c) 73 } 74 return c 75 } 76 77 // WithOptions configures the receiver Config with the passed in options set 78 func (c *Config) WithOptions(opts ...ConfigOption) *Config { 79 for _, o := range opts { 80 o(c) 81 } 82 return c 83 } 84 85 // WithGRPCServer returns an option that can set GRPCServer on a Config 86 func WithGRPCServer(gRPCServer util.GRPCServerConfig) ConfigOption { 87 return func(c *Config) { 88 c.GRPCServer = gRPCServer 89 } 90 } 91 92 // WithReadOnlyGRPCServer returns an option that can set ReadOnlyGRPCServer on a Config 93 func WithReadOnlyGRPCServer(readOnlyGRPCServer util.GRPCServerConfig) ConfigOption { 94 return func(c *Config) { 95 c.ReadOnlyGRPCServer = readOnlyGRPCServer 96 } 97 } 98 99 // WithHTTPGateway returns an option that can set HTTPGateway on a Config 100 func WithHTTPGateway(hTTPGateway util.HTTPServerConfig) ConfigOption { 101 return func(c *Config) { 102 c.HTTPGateway = hTTPGateway 103 } 104 } 105 106 // WithReadOnlyHTTPGateway returns an option that can set ReadOnlyHTTPGateway on a Config 107 func WithReadOnlyHTTPGateway(readOnlyHTTPGateway util.HTTPServerConfig) ConfigOption { 108 return func(c *Config) { 109 c.ReadOnlyHTTPGateway = readOnlyHTTPGateway 110 } 111 } 112 113 // WithLoadConfigs returns an option that can append LoadConfigss to Config.LoadConfigs 114 func WithLoadConfigs(loadConfigs string) ConfigOption { 115 return func(c *Config) { 116 c.LoadConfigs = append(c.LoadConfigs, loadConfigs) 117 } 118 } 119 120 // SetLoadConfigs returns an option that can set LoadConfigs on a Config 121 func SetLoadConfigs(loadConfigs []string) ConfigOption { 122 return func(c *Config) { 123 c.LoadConfigs = loadConfigs 124 } 125 } 126 127 // WithMaximumUpdatesPerWrite returns an option that can set MaximumUpdatesPerWrite on a Config 128 func WithMaximumUpdatesPerWrite(maximumUpdatesPerWrite uint16) ConfigOption { 129 return func(c *Config) { 130 c.MaximumUpdatesPerWrite = maximumUpdatesPerWrite 131 } 132 } 133 134 // WithMaximumPreconditionCount returns an option that can set MaximumPreconditionCount on a Config 135 func WithMaximumPreconditionCount(maximumPreconditionCount uint16) ConfigOption { 136 return func(c *Config) { 137 c.MaximumPreconditionCount = maximumPreconditionCount 138 } 139 } 140 141 // WithMaxCaveatContextSize returns an option that can set MaxCaveatContextSize on a Config 142 func WithMaxCaveatContextSize(maxCaveatContextSize int) ConfigOption { 143 return func(c *Config) { 144 c.MaxCaveatContextSize = maxCaveatContextSize 145 } 146 } 147 148 // WithMaxRelationshipContextSize returns an option that can set MaxRelationshipContextSize on a Config 149 func WithMaxRelationshipContextSize(maxRelationshipContextSize int) ConfigOption { 150 return func(c *Config) { 151 c.MaxRelationshipContextSize = maxRelationshipContextSize 152 } 153 } 154 155 // WithMaxReadRelationshipsLimit returns an option that can set MaxReadRelationshipsLimit on a Config 156 func WithMaxReadRelationshipsLimit(maxReadRelationshipsLimit uint32) ConfigOption { 157 return func(c *Config) { 158 c.MaxReadRelationshipsLimit = maxReadRelationshipsLimit 159 } 160 } 161 162 // WithMaxDeleteRelationshipsLimit returns an option that can set MaxDeleteRelationshipsLimit on a Config 163 func WithMaxDeleteRelationshipsLimit(maxDeleteRelationshipsLimit uint32) ConfigOption { 164 return func(c *Config) { 165 c.MaxDeleteRelationshipsLimit = maxDeleteRelationshipsLimit 166 } 167 } 168 169 // WithMaxLookupResourcesLimit returns an option that can set MaxLookupResourcesLimit on a Config 170 func WithMaxLookupResourcesLimit(maxLookupResourcesLimit uint32) ConfigOption { 171 return func(c *Config) { 172 c.MaxLookupResourcesLimit = maxLookupResourcesLimit 173 } 174 } 175 176 // WithMaxBulkExportRelationshipsLimit returns an option that can set MaxBulkExportRelationshipsLimit on a Config 177 func WithMaxBulkExportRelationshipsLimit(maxBulkExportRelationshipsLimit uint32) ConfigOption { 178 return func(c *Config) { 179 c.MaxBulkExportRelationshipsLimit = maxBulkExportRelationshipsLimit 180 } 181 }