NewConfig creates a new Config instance with default values and applies any provided DatastoreOption modifications.
(opts ...DatastoreOption)
| 200 | // NewConfig creates a new Config instance with default values |
| 201 | // and applies any provided DatastoreOption modifications. |
| 202 | func NewConfig(opts ...DatastoreOption) *Config { |
| 203 | cfg := &Config{} |
| 204 | |
| 205 | for _, opt := range opts { |
| 206 | opt(cfg) |
| 207 | } |
| 208 | |
| 209 | if cfg.Logger == nil { |
| 210 | cfg.Logger = logger.NewNoopLogger() |
| 211 | } |
| 212 | |
| 213 | if cfg.MaxTuplesPerWriteField == 0 { |
| 214 | cfg.MaxTuplesPerWriteField = storage.DefaultMaxTuplesPerWrite |
| 215 | } |
| 216 | |
| 217 | if cfg.MaxTypesPerModelField == 0 { |
| 218 | cfg.MaxTypesPerModelField = storage.DefaultMaxTypesPerAuthorizationModel |
| 219 | } |
| 220 | |
| 221 | if cfg.PingTimeout == 0 { |
| 222 | cfg.PingTimeout = config.DefaultDatastorePingTimeout |
| 223 | } |
| 224 | |
| 225 | if cfg.PingRetryMaxElapsedTime == 0 { |
| 226 | cfg.PingRetryMaxElapsedTime = config.DefaultDatastorePingRetryMaxElapsedTime |
| 227 | } |
| 228 | |
| 229 | return cfg |
| 230 | } |
| 231 | |
| 232 | // ContToken represents a continuation token structure used in pagination. |
| 233 | type ContToken struct { |
searching dependent graphs…