github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/dispatch/graph/zz_generated.options.go (about) 1 // Code generated by github.com/ecordell/optgen. DO NOT EDIT. 2 package graph 3 4 import ( 5 defaults "github.com/creasty/defaults" 6 helpers "github.com/ecordell/optgen/helpers" 7 ) 8 9 type ConcurrencyLimitsOption func(c *ConcurrencyLimits) 10 11 // NewConcurrencyLimitsWithOptions creates a new ConcurrencyLimits with the passed in options set 12 func NewConcurrencyLimitsWithOptions(opts ...ConcurrencyLimitsOption) *ConcurrencyLimits { 13 c := &ConcurrencyLimits{} 14 for _, o := range opts { 15 o(c) 16 } 17 return c 18 } 19 20 // NewConcurrencyLimitsWithOptionsAndDefaults creates a new ConcurrencyLimits with the passed in options set starting from the defaults 21 func NewConcurrencyLimitsWithOptionsAndDefaults(opts ...ConcurrencyLimitsOption) *ConcurrencyLimits { 22 c := &ConcurrencyLimits{} 23 defaults.MustSet(c) 24 for _, o := range opts { 25 o(c) 26 } 27 return c 28 } 29 30 // ToOption returns a new ConcurrencyLimitsOption that sets the values from the passed in ConcurrencyLimits 31 func (c *ConcurrencyLimits) ToOption() ConcurrencyLimitsOption { 32 return func(to *ConcurrencyLimits) { 33 to.Check = c.Check 34 to.ReachableResources = c.ReachableResources 35 to.LookupResources = c.LookupResources 36 to.LookupSubjects = c.LookupSubjects 37 } 38 } 39 40 // DebugMap returns a map form of ConcurrencyLimits for debugging 41 func (c ConcurrencyLimits) DebugMap() map[string]any { 42 debugMap := map[string]any{} 43 debugMap["Check"] = helpers.DebugValue(c.Check, false) 44 debugMap["ReachableResources"] = helpers.DebugValue(c.ReachableResources, false) 45 debugMap["LookupResources"] = helpers.DebugValue(c.LookupResources, false) 46 debugMap["LookupSubjects"] = helpers.DebugValue(c.LookupSubjects, false) 47 return debugMap 48 } 49 50 // ConcurrencyLimitsWithOptions configures an existing ConcurrencyLimits with the passed in options set 51 func ConcurrencyLimitsWithOptions(c *ConcurrencyLimits, opts ...ConcurrencyLimitsOption) *ConcurrencyLimits { 52 for _, o := range opts { 53 o(c) 54 } 55 return c 56 } 57 58 // WithOptions configures the receiver ConcurrencyLimits with the passed in options set 59 func (c *ConcurrencyLimits) WithOptions(opts ...ConcurrencyLimitsOption) *ConcurrencyLimits { 60 for _, o := range opts { 61 o(c) 62 } 63 return c 64 } 65 66 // WithCheck returns an option that can set Check on a ConcurrencyLimits 67 func WithCheck(check uint16) ConcurrencyLimitsOption { 68 return func(c *ConcurrencyLimits) { 69 c.Check = check 70 } 71 } 72 73 // WithReachableResources returns an option that can set ReachableResources on a ConcurrencyLimits 74 func WithReachableResources(reachableResources uint16) ConcurrencyLimitsOption { 75 return func(c *ConcurrencyLimits) { 76 c.ReachableResources = reachableResources 77 } 78 } 79 80 // WithLookupResources returns an option that can set LookupResources on a ConcurrencyLimits 81 func WithLookupResources(lookupResources uint16) ConcurrencyLimitsOption { 82 return func(c *ConcurrencyLimits) { 83 c.LookupResources = lookupResources 84 } 85 } 86 87 // WithLookupSubjects returns an option that can set LookupSubjects on a ConcurrencyLimits 88 func WithLookupSubjects(lookupSubjects uint16) ConcurrencyLimitsOption { 89 return func(c *ConcurrencyLimits) { 90 c.LookupSubjects = lookupSubjects 91 } 92 }