service

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvaluationRequest

type EvaluationRequest struct {
	UserID      string              `json:"userId"`
	UserContext flaggio.UserContext `json:"context"`
	Debug       *bool               `json:"debug,omitempty"`
}

EvaluationRequest is the evaluation request object

func (EvaluationRequest) Bind

func (er EvaluationRequest) Bind(r *http.Request) error

Bind adds additional data to the EvaluationRequest. Some special fields are added to the user context: * $userId is the user ID provided in the request * $ip is the network address that originated the request

func (EvaluationRequest) Hash

func (er EvaluationRequest) Hash() (string, error)

Hash returns a hash string representation of EvaluationRequest This function will return the same hash regardless of the order the user context comes in.

func (EvaluationRequest) IsDebug

func (er EvaluationRequest) IsDebug() bool

IsDebug returns whether this is a debug request or not

type EvaluationResponse

type EvaluationResponse struct {
	Evaluation  *flaggio.Evaluation  `json:"evaluation"`
	UserContext *flaggio.UserContext `json:"context,omitempty"`
}

EvaluationResponse is the evaluation response object

func (*EvaluationResponse) Render

Render can enrich the EvaluationResponse object before being returned to the user. Currently it does nothing, but is needed to satisfy the chi.Renderer interface.

type EvaluationsResponse

type EvaluationsResponse struct {
	Evaluations flaggio.EvaluationList `json:"evaluations"`
	UserContext *flaggio.UserContext   `json:"context,omitempty"`
}

EvaluationsResponse is the evaluation response object

func (*EvaluationsResponse) Render

Render can enrich the EvaluationsResponse object before being returned to the user. Currently it does nothing, but is needed to satisfy the chi.Renderer interface.

type Flag

type Flag interface {
	// Evaluate returns the result of an evaluation of a single flag.
	Evaluate(ctx context.Context, flagKey string, req *EvaluationRequest) (*EvaluationResponse, error)
	// EvaluateAll returns the results of the evaluation of all flags.
	EvaluateAll(ctx context.Context, req *EvaluationRequest) (*EvaluationsResponse, error)
}

Flag holds the logic for evaluating flags

func NewFlagService

func NewFlagService(
	flagsRepo repository.Flag,
	segmentsRepo repository.Segment,
	evalsRepo repository.Evaluation,
	usersRepo repository.User,
) Flag

NewFlagService returns a new Flag service

Directories

Path Synopsis
Package service_mock is a generated GoMock package.
Package service_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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