proxyservice

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is the error returned when a method hasn't been implemented
	ErrNotImplemented = errors.New("endpoint not implemented")

	// ErrNotFound is the error returned when the service can't find the requested
	// resource
	ErrNotFound = errors.New("not found")

	// ErrInternal is the error that the proxy service returns when it encounters
	// an unexpected error
	ErrInternal = errors.New("internal error")

	// ErrUnauthorised is the error that the proxy service returns when the
	ErrUnauthorised = errors.New("unauthorised")

	// ErrStreamDisconnected is the error that the proxy service returns when
	// its internal sdk has disconnected from the SaaS stream
	ErrStreamDisconnected = errors.New("SaaS stream disconnected")
)

Functions

This section is empty.

Types

type CacheHealthFn

type CacheHealthFn func(ctx context.Context) error

CacheHealthFn is a function that checks the cache health

type Config

type Config struct {
	Logger           log.ContextualLogger
	FeatureRepo      repository.FeatureFlagRepo
	TargetRepo       repository.TargetRepo
	SegmentRepo      repository.SegmentRepo
	AuthRepo         repository.AuthRepo
	CacheHealthFn    CacheHealthFn
	EnvHealthFn      EnvHealthFn
	AuthFn           authTokenFn
	ClientService    clientService
	MetricService    metricService
	Offline          bool
	Hasher           hash.Hasher
	StreamingEnabled bool
	SDKClients       SDKClients
}

Config is the config for a Service

type EnvHealthFn

type EnvHealthFn func() []domain.EnvironmentHealth

EnvHealthFn is a function that checks the health of all connected environments

type ProxyService

type ProxyService interface {
	// Authenticate performs authentication
	Authenticate(ctx context.Context, req domain.AuthRequest) (domain.AuthResponse, error)

	// FeatureConfig gets all FeatureConfig for an environment
	FeatureConfig(ctx context.Context, req domain.FeatureConfigRequest) ([]domain.FeatureConfig, error)

	// FeatureConfigByIdentifier gets the feature config for a feature
	FeatureConfigByIdentifier(ctx context.Context, req domain.FeatureConfigByIdentifierRequest) (domain.FeatureConfig, error)

	// TargetSegments gets all of the TargetSegments in an environment
	TargetSegments(ctx context.Context, req domain.TargetSegmentsRequest) ([]domain.Segment, error)

	// TargetSegmentsByIdentifier get a TargetSegments from an environment by its identifier
	TargetSegmentsByIdentifier(ctx context.Context, req domain.TargetSegmentsByIdentifierRequest) (domain.Segment, error)

	// Evaluations gets all of the evaluations in an environment for a target
	Evaluations(ctx context.Context, req domain.EvaluationsRequest) ([]clientgen.Evaluation, error)

	// Evaluations gets all of the evaluations in an environment for a target for a particular feature
	EvaluationsByFeature(ctx context.Context, req domain.EvaluationsByFeatureRequest) (clientgen.Evaluation, error)

	// Stream returns the name of the GripChannel that the client should subscribe to
	Stream(ctx context.Context, req domain.StreamRequest) (domain.StreamResponse, error)

	// Metrics forwards metrics to the analytics service
	Metrics(ctx context.Context, req domain.MetricsRequest) error

	// Health checks the health of the system
	Health(ctx context.Context) (domain.HealthResponse, error)
}

ProxyService is the interface for the ProxyService

type QueryStore

type QueryStore struct {
	F func(identifier string) (rest.FeatureConfig, error)
	S func(identifier string) (rest.Segment, error)
	L func() ([]rest.FeatureConfig, error)
}

QueryStore ...

func (QueryStore) GetFlag

func (q QueryStore) GetFlag(identifier string) (rest.FeatureConfig, error)

GetFlag returns a FeatureConfig from the QueryStore

func (QueryStore) GetFlags

func (q QueryStore) GetFlags() ([]rest.FeatureConfig, error)

GetFlags returns FeatureConfigs from the QueryStore

func (QueryStore) GetSegment

func (q QueryStore) GetSegment(identifier string) (rest.Segment, error)

GetSegment returns a Segment from the QueryStore

type SDKClients

type SDKClients interface {
	StreamConnected(key string) bool
}

SDKClients is an interface that can be used to find out if internal sdks are connected to the SaaS FF stream

type Service

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

Service is the proxy service implementation

func NewService

func NewService(c Config) Service

NewService creates and returns a ProxyService

func (Service) Authenticate

func (s Service) Authenticate(ctx context.Context, req domain.AuthRequest) (domain.AuthResponse, error)

Authenticate performs authentication

func (Service) Evaluations

Evaluations gets all the evaluations in an environment for a target

func (Service) EvaluationsByFeature

func (s Service) EvaluationsByFeature(ctx context.Context, req domain.EvaluationsByFeatureRequest) (clientgen.Evaluation, error)

EvaluationsByFeature gets all the evaluations in an environment for a target for a particular feature

func (Service) FeatureConfig

FeatureConfig gets all FeatureConfig for an environment

func (Service) FeatureConfigByIdentifier

func (s Service) FeatureConfigByIdentifier(ctx context.Context, req domain.FeatureConfigByIdentifierRequest) (domain.FeatureConfig, error)

FeatureConfigByIdentifier gets the feature config for a feature

func (Service) GenerateQueryStore

func (s Service) GenerateQueryStore(ctx context.Context, environmentID string) QueryStore

GenerateQueryStore returns a QueryStore object which can be passed to the go sdk evaluator

func (Service) Health

func (s Service) Health(ctx context.Context) (domain.HealthResponse, error)

Health checks the health of the system

func (Service) Metrics

func (s Service) Metrics(ctx context.Context, req domain.MetricsRequest) error

Metrics forwards metrics to the analytics service

func (Service) Stream

Stream does a lookup for the environmentID for the APIKey in the StreamRequest and returns it as the GripChannel.

func (Service) TargetSegments

func (s Service) TargetSegments(ctx context.Context, req domain.TargetSegmentsRequest) ([]domain.Segment, error)

TargetSegments gets all of the TargetSegments in an environment

func (Service) TargetSegmentsByIdentifier

func (s Service) TargetSegmentsByIdentifier(ctx context.Context, req domain.TargetSegmentsByIdentifierRequest) (domain.Segment, error)

TargetSegmentsByIdentifier get a TargetSegments from an environment by its identifier

Jump to

Keyboard shortcuts

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