Documentation
¶
Index ¶
- func Add(ctx context.Context, key string, value interface{}) context.Context
- func Merge(ctx context.Context, lekkoCtx map[string]interface{}) context.Context
- func NewClient(namespace string, provider Provider) (Client, CloseFunc)
- type Client
- type ClientOptions
- type CloseFunc
- type Provider
- type ProviderOption
- type RepositoryKey
- type URLOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
Merge allows you to pass arbitrary context variables in order to perform rules evaluation on your feature flags in real time. Priority is given to newly added keys in lekkoCtx. TODO: allow users to run in safe mode, which will throw errors on ctx conflicts. TODO: this is not thread-safe, make it thread-safe.
Types ¶
type Client ¶
type Client interface {
GetBool(ctx context.Context, key string) (bool, error)
GetInt(ctx context.Context, key string) (int64, error)
GetFloat(ctx context.Context, key string) (float64, error)
GetString(ctx context.Context, key string) (string, error)
// result should be an empty Go variable that the JSON feature
// can be unmarshalled into. If an error is returned, the data
// stored in result is unpredictable and should not be relied upon.
GetJSON(ctx context.Context, key string, result interface{}) error
// result should be an empty proto message that the proto feature
// can be unmarshalled into. If an error is returned, the data
// stored in result is unpredictable and should not be relied upon.
GetProto(ctx context.Context, key string, result proto.Message) error
}
Client allows retrieving lekko features. The appropriate method must be called based on the type of the feature. For instance, calling GetBool on an Int feature will result in an error.
type ClientOptions ¶
type ClientOptions struct {
// Lekko namespace to read configurations from
Namespace string
// Arbitrary keys and values for rules evaluation that are
// injected into the context at startup. Context keys passed
// at runtime will override these values in case of conflict.
StartupContext map[string]interface{}
}
type Provider ¶
type Provider interface {
GetBoolFeature(ctx context.Context, key string, namespace string) (bool, error)
GetIntFeature(ctx context.Context, key string, namespace string) (int64, error)
GetFloatFeature(ctx context.Context, key string, namespace string) (float64, error)
GetStringFeature(ctx context.Context, key string, namespace string) (string, error)
GetProtoFeature(ctx context.Context, key string, namespace string, result proto.Message) error
GetJSONFeature(ctx context.Context, key string, namespace string, result interface{}) error
// Error will get called by the closure returned in Client initialization.
Close(ctx context.Context) error
}
A provider evaluates configuration from a number of sources.
func ConnectAPIProvider ¶ added in v0.0.3
func ConnectAPIProvider(ctx context.Context, apiKey string, rk *RepositoryKey, opts ...ProviderOption) (Provider, error)
Fetches configuration directly from Lekko Backend APIs.
func ConnectSidecarProvider ¶ added in v0.0.3
func ConnectSidecarProvider(ctx context.Context, url string, rk *RepositoryKey, opts ...ProviderOption) (Provider, error)
Fetches configuration from a lekko sidecar, likely running on the local network. Will make repeated RPCs to register the client, so providing context with a timeout is strongly preferred. A function is returned to close the client. It is also strongly recommended to call this when the program is exiting or the lekko provider is no longer needed.
type ProviderOption ¶ added in v0.1.0
type ProviderOption interface {
// contains filtered or unexported methods
}
type RepositoryKey ¶
type RepositoryKey struct {
// The name of the github owner. Can be a github
// organization name or a personal account name.
OwnerName string
// The name of the repository on github.
RepoName string
}
Identifies a configuration repository on github.com