client

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	LekkoURL          = "https://prod.api.lekko.dev"
	LekkoAPIKeyHeader = "apikey"
)

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, key string, value interface{}) context.Context

func Merge

func Merge(ctx context.Context, lekkoCtx map[string]interface{}) context.Context

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 struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(namespace string, provider Provider) *Client

func (*Client) GetBool

func (c *Client) GetBool(ctx context.Context, key string) (bool, error)

func (*Client) GetJSON

func (c *Client) GetJSON(ctx context.Context, key string, result interface{}) error

func (*Client) GetProto

func (c *Client) GetProto(ctx context.Context, key string, result proto.Message) 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{}
}

func (ClientOptions) NewClient

func (o ClientOptions) NewClient(provider Provider) *Client

type Provider

type Provider interface {
	GetBoolFeature(ctx context.Context, key string, namespace string) (bool, 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
}

A provider evaluates configuration from a number of sources.

func NewBackendProvider

func NewBackendProvider(apiKey string, rk *RepositoryKey) Provider

Fetches configuration directly from Lekko Backend.

func NewSidecarProvider

func NewSidecarProvider(ctx context.Context, url, apiKey string, rk *RepositoryKey) (Provider, error)

Fetches configuration from a lekko sidecar, likely running on the local network. Will make an RPC to register the client, so providing context is preferred.

func NewStaticProvider

func NewStaticProvider(pathToRoot string) (Provider, error)

The static provider will read from a git repo via a relative path. This may be useful for local testing when a sidecar is not available.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL