Documentation ¶
Index ¶
- Constants
- Variables
- type Chamber
- type ChamberEntry
- func (c *ChamberEntry) BoolValue(ruleKey string, defaultValue bool) (bool, error)
- func (c *ChamberEntry) CustomValue(ruleKey string, v any) error
- func (c *ChamberEntry) Float64Value(ruleKey string, defaultValue float64) (float64, error)
- func (c *ChamberEntry) Get(ruleKey string) *OverrideableRule
- func (c *ChamberEntry) StringValue(ruleKey string, defaultValue string) (string, error)
- type ErrCouldNotConvertRule
- type ErrRuleNotFound
- type Override
- type OverrideableRule
- func (t *OverrideableRule) BoolValue(version string, defaultValue bool) (bool, bool)
- func (t *OverrideableRule) CustomValue(version string, v any) error
- func (t *OverrideableRule) Float64Value(version string, defaultValue float64) (float64, bool)
- func (t *OverrideableRule) GetValueAt(version string) interface{}
- func (t *OverrideableRule) StringValue(version string, defaultValue string) (string, bool)
- func (t *OverrideableRule) UnmarshalJSON(b []byte) error
- type Realm
- func (rlm *Realm) Bool(ctx context.Context, ruleKey string, defaultValue bool) (bool, error)
- func (rlm *Realm) CustomValue(ctx context.Context, ruleKey string, v any) error
- func (rlm *Realm) Float64(ctx context.Context, ruleKey string, defaultValue float64) (float64, error)
- func (rlm *Realm) Logger() hclog.Logger
- func (rlm *Realm) NewContext(ctx context.Context) context.Context
- func (rlm *Realm) Start() error
- func (rlm *Realm) Stop()
- func (rlm *Realm) String(ctx context.Context, ruleKey string, defaultValue string) (string, error)
- type RealmOptions
- type Rule
- type UnsupportedTypeError
Constants ¶
const ( // DefaultRefreshInterval is used as the default refresh interval for realm DefaultRefreshInterval time.Duration = 15 * time.Minute )
Variables ¶
var (
ErrChamberEmpty = errors.New("chamber is nil")
)
var ( // RequestContextKey is the context key to use with a WithValue function to associate a root chamber value with a context // such that rule retrievals will be consistent throughout the client's request RequestContextKey = &contextKey{"realm"} )
Functions ¶
This section is empty.
Types ¶
type Chamber ¶
type Chamber struct {
Rules map[string]*OverrideableRule `json:"rules"`
}
Chamber is a struct that holds metadata and rules
func (*Chamber) UnmarshalJSON ¶
type ChamberEntry ¶ added in v0.0.18
type ChamberEntry struct {
// contains filtered or unexported fields
}
ChamberEntry is a read-only version of Chamber it is specifically used for realm clients
func NewChamberEntry ¶ added in v0.0.18
func NewChamberEntry(c *Chamber, version string) *ChamberEntry
NewChamberEntry creates a new ChamberEntry with the specified version
func (*ChamberEntry) BoolValue ¶ added in v0.0.18
func (c *ChamberEntry) BoolValue(ruleKey string, defaultValue bool) (bool, error)
BoolValue retrieves a bool by the key of the rule and returns the default value if it does not exist and an error if it is not found or could not be converted
func (*ChamberEntry) CustomValue ¶ added in v0.0.18
func (c *ChamberEntry) CustomValue(ruleKey string, v any) error
CustomValue retrieves a json.RawMessage by the key of the rule and returns an error if it is not found or could not be converted
func (*ChamberEntry) Float64Value ¶ added in v0.0.18
func (c *ChamberEntry) Float64Value(ruleKey string, defaultValue float64) (float64, error)
Float64Value retrieves a float64 by the key of the rule and returns the default value if it does not exist and an error if it is not found or could not be converted
func (*ChamberEntry) Get ¶ added in v0.0.18
func (c *ChamberEntry) Get(ruleKey string) *OverrideableRule
Get returns the rule with the specified ruleKey. Will return nil if the rule does not exist
func (*ChamberEntry) StringValue ¶ added in v0.0.18
func (c *ChamberEntry) StringValue(ruleKey string, defaultValue string) (string, error)
StringValue retrieves a string by the key of the rule and returns the default value if it does not exist and an error if it is not found or could not be converted
type ErrCouldNotConvertRule ¶ added in v0.0.24
func (*ErrCouldNotConvertRule) Error ¶ added in v0.0.24
func (cnc *ErrCouldNotConvertRule) Error() string
type ErrRuleNotFound ¶ added in v0.0.24
type ErrRuleNotFound struct {
Key string
}
func (*ErrRuleNotFound) Error ¶ added in v0.0.24
func (tnf *ErrRuleNotFound) Error() string
type Override ¶
type Override struct { *Rule MinimumVersion string `json:"minimumVersion"` MaximumVersion string `json:"maximumVersion"` }
Override is a rule value to be consumed by and restricted to a semantic version range
func (*Override) UnmarshalJSON ¶
UnmarshalJSON Custom UnmarshalJSON method for validating Override
type OverrideableRule ¶ added in v0.0.24
func (*OverrideableRule) BoolValue ¶ added in v0.0.24
func (t *OverrideableRule) BoolValue(version string, defaultValue bool) (bool, bool)
BoolValue retrieves a bool value of the rule and returns the default value if it does not exist and a bool on whether or not the rule exists
func (*OverrideableRule) CustomValue ¶ added in v0.0.24
func (t *OverrideableRule) CustomValue(version string, v any) error
CustomValue unmarshals v into the value of the rule
func (*OverrideableRule) Float64Value ¶ added in v0.0.24
func (t *OverrideableRule) Float64Value(version string, defaultValue float64) (float64, bool)
Float64Value retrieves a float64 value of the rule and returns the default value if it does not exist and a bool on whether or not the rule exists
func (*OverrideableRule) GetValueAt ¶ added in v0.0.24
func (t *OverrideableRule) GetValueAt(version string) interface{}
GetValueAt returns the value at the given version. Will return default value if version is empty string or no override is present for the specified version
func (*OverrideableRule) StringValue ¶ added in v0.0.24
func (t *OverrideableRule) StringValue(version string, defaultValue string) (string, bool)
StringValue retrieves a string value of the rule and returns the default value if it does not exist and a bool on whether or not the rule exists
func (*OverrideableRule) UnmarshalJSON ¶ added in v0.0.24
func (t *OverrideableRule) UnmarshalJSON(b []byte) error
UnmarshalJSON Custom UnmarshalJSON method for validating rule Value to the RuleType
type Realm ¶ added in v0.0.18
type Realm struct {
// contains filtered or unexported fields
}
func NewRealm ¶ added in v0.0.18
func NewRealm(options RealmOptions) (*Realm, error)
NewRealm returns a new Realm struct that carries out all of the core features
func (*Realm) Bool ¶ added in v0.0.18
Bool retrieves a bool by the key of the rule. Returns the default value if it does not exist and a bool on whether or not the rule exists with that type
func (*Realm) CustomValue ¶ added in v0.0.18
CustomValue retrieves an arbitrary value by the key of the rule and unmarshals the value into the custom value v
func (*Realm) Float64 ¶ added in v0.0.18
func (rlm *Realm) Float64(ctx context.Context, ruleKey string, defaultValue float64) (float64, error)
Float64 retrieves a float64 by the key of the rule. Returns the default value if it does not exist and a bool on whether or not the rule exists with that type
func (*Realm) Logger ¶ added in v0.0.18
func (rlm *Realm) Logger() hclog.Logger
Logger retrieves the underlying logger for realm
func (*Realm) NewContext ¶ added in v0.0.18
type RealmOptions ¶ added in v0.0.18
type Rule ¶ added in v0.0.24
type Rule struct { Type string `json:"type"` Value interface{} `json:"value"` }
Rule is a feature definition structure for holding its name, value, type and any overrides to be parsed by the applicable realm sdk
func (*Rule) UnmarshalJSON ¶ added in v0.0.24
type UnsupportedTypeError ¶ added in v0.0.18
type UnsupportedTypeError struct {
RuleType string
}
func (*UnsupportedTypeError) Error ¶ added in v0.0.18
func (ut *UnsupportedTypeError) Error() string