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 ¶
func (e *EvaluationResponse) Render(w http.ResponseWriter, r *http.Request) error
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 ¶
func (e *EvaluationsResponse) Render(w http.ResponseWriter, r *http.Request) error
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