flagd

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	Add(K, V) (evicted bool)
	Purge()
	Get(K) (value V, ok bool)
	Remove(K) (present bool)
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(opts ...ProviderOption) *Provider

func (*Provider) BooleanEvaluation

func (p *Provider) BooleanEvaluation(
	ctx context.Context, flagKey string, defaultValue bool, evalCtx of.FlattenedContext,
) of.BoolResolutionDetail

func (*Provider) Configuration

func (p *Provider) Configuration() *ProviderConfiguration

Configuration returns the current configuration of the provider

func (*Provider) FloatEvaluation

func (p *Provider) FloatEvaluation(
	ctx context.Context, flagKey string, defaultValue float64, evalCtx of.FlattenedContext,
) of.FloatResolutionDetail

func (*Provider) Hooks

func (p *Provider) Hooks() []of.Hook

Hooks flagd provider does not have any hooks, returns empty slice

func (*Provider) IntEvaluation

func (p *Provider) IntEvaluation(
	ctx context.Context, flagKey string, defaultValue int64, evalCtx of.FlattenedContext,
) of.IntResolutionDetail

func (*Provider) IsReady

func (p *Provider) IsReady() <-chan struct{}

IsReady returns a non-blocking channel if the provider has received the provider_ready event from flagd

func (*Provider) Metadata

func (p *Provider) Metadata() of.Metadata

Metadata returns value of Metadata (name of current service, exposed to openfeature sdk)

func (*Provider) ObjectEvaluation

func (p *Provider) ObjectEvaluation(
	ctx context.Context, flagKey string, defaultValue interface{}, evalCtx of.FlattenedContext,
) of.InterfaceResolutionDetail

func (*Provider) StringEvaluation

func (p *Provider) StringEvaluation(
	ctx context.Context, flagKey string, defaultValue string, evalCtx of.FlattenedContext,
) of.StringResolutionDetail

type ProviderConfiguration

type ProviderConfiguration struct {
	Port            uint16
	Host            string
	CertificatePath string
	SocketPath      string
}

type ProviderOption

type ProviderOption func(*Provider)

func FromEnv

func FromEnv() ProviderOption

FromEnv sets the provider configuration from environment variables: FLAGD_HOST, FLAGD_PORT, FLAGD_SERVICE_PROVIDER, FLAGD_SERVER_CERT_PATH & FLAGD_CACHING_DISABLED

func WithBasicInMemoryCache

func WithBasicInMemoryCache() ProviderOption

WithBasicInMemoryCache applies a basic in memory cache store (with no memory limits)

func WithCertificatePath

func WithCertificatePath(path string) ProviderOption

WithCertificatePath specifies the location of the certificate to be used in the gRPC dial credentials. If certificate loading fails insecure credentials will be used instead

func WithContext

func WithContext(ctx context.Context) ProviderOption

WithContext supplies the given context to the event stream. Not to be confused with the context used in individual flag evaluation requests.

func WithEventStreamConnectionMaxAttempts

func WithEventStreamConnectionMaxAttempts(i int) ProviderOption

WithEventStreamConnectionMaxAttempts sets the maximum number of attempts to connect to flagd's event stream. On successful connection the attempts are reset.

func WithHost

func WithHost(host string) ProviderOption

WithHost specifies the host name of the flagd server. Defaults to localhost

func WithLRUCache

func WithLRUCache(size int) ProviderOption

WithLRUCache applies least recently used caching (github.com/hashicorp/golang-lru). The provided size is the limit of the number of cached values. Once the limit is reached each new entry replaces the least recently used entry.

func WithLogger added in v0.1.3

func WithLogger(l logr.Logger) ProviderOption

WithLogger sets the logger used by the provider.

func WithPort

func WithPort(port uint16) ProviderOption

WithPort specifies the port of the flagd server. Defaults to 8013

func WithSocketPath

func WithSocketPath(socketPath string) ProviderOption

WithSocketPath overrides the default hostname and port, a unix socket connection is made to flagd instead

func WithoutCache

func WithoutCache() ProviderOption

WithoutCache disables caching

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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