Documentation ¶
Index ¶
- Constants
- Variables
- func CreateFiberRouterFromConfig(cfgFilePath string, fiberDebugLog bool) (fiber.Component, error)
- func NewErrorLoggingInterceptor(log log.Logger) fiber.Interceptor
- func NewMetricsInterceptor() fiber.Interceptor
- func NewTimeLoggingInterceptor(log log.Logger) fiber.Interceptor
- func NewTracingInterceptor() fiber.Interceptor
- type CombinedResponse
- type DefaultTuringRoutingStrategy
- type EnsemblingFanIn
- type ErrorLoggingInterceptor
- type MetricsInterceptor
- type RouteResponse
- type TimeLoggingInterceptor
- type TracingInterceptor
- type TrafficSplittingStrategy
- type TrafficSplittingStrategyRule
Constants ¶
const FanInID = "fan_in"
FanInID is used to indendify the fan in component when capturing a request span
Variables ¶
var (
TrafficRuleLabel = "traffic-rule"
)
Functions ¶
func CreateFiberRouterFromConfig ¶
func CreateFiberRouterFromConfig( cfgFilePath string, fiberDebugLog bool, ) (fiber.Component, error)
CreateFiberRouterFromConfig creates a Fiber router from config
func NewErrorLoggingInterceptor ¶
func NewErrorLoggingInterceptor(log log.Logger) fiber.Interceptor
NewErrorLoggingInterceptor is a creator for an ErrorLoggingInterceptor
func NewMetricsInterceptor ¶
func NewMetricsInterceptor() fiber.Interceptor
NewMetricsInterceptor is a creator for a MetricsInterceptor
func NewTimeLoggingInterceptor ¶
func NewTimeLoggingInterceptor(log log.Logger) fiber.Interceptor
NewTimeLoggingInterceptor is a creator for a TimeLoggingInterceptor
func NewTracingInterceptor ¶
func NewTracingInterceptor() fiber.Interceptor
NewTracingInterceptor is a creator for a TracingInterceptor
Types ¶
type CombinedResponse ¶
type CombinedResponse struct { // List of responses from each treatment RouteResponses []RouteResponse `json:"route_responses"` // Configuration / Error response from experiment engine Experiment experiment.Response `json:"experiment"` }
CombinedResponse captures the structure of the final response sent back by the fan in
type DefaultTuringRoutingStrategy ¶
type DefaultTuringRoutingStrategy struct {
// contains filtered or unexported fields
}
DefaultTuringRoutingStrategy selects the route that matches experiment treatment for a given unit and picks the route marked default, if any, as fallback.
func (*DefaultTuringRoutingStrategy) Initialize ¶
func (r *DefaultTuringRoutingStrategy) Initialize(properties json.RawMessage) error
Initialize is invoked by the Fiber library to initialize a new RoutingStrategy.
func (*DefaultTuringRoutingStrategy) SelectRoute ¶
func (r *DefaultTuringRoutingStrategy) SelectRoute( ctx context.Context, req fiber.Request, routes map[string]fiber.Component, ) (fiber.Component, []fiber.Component, fiber.Labels, error)
SelectRoute decides the priority order of the routes for the unit in the given request, according to the treatment returned by the configured experiment engine.
type EnsemblingFanIn ¶
type EnsemblingFanIn struct {
// contains filtered or unexported fields
}
EnsemblingFanIn combines the results from the fanout with the experiment parameters and forwards to the configured ensembling endpoint
func (*EnsemblingFanIn) Aggregate ¶
func (fanIn *EnsemblingFanIn) Aggregate( ctx context.Context, req fiber.Request, queue fiber.ResponseQueue, ) fiber.Response
Aggregate requests for the treatment parameters from the configured experiment engine, collects the results from the fanout, dispatches the combined data to the configured ensembling endpoint and returns the result
func (*EnsemblingFanIn) Initialize ¶
func (fanIn *EnsemblingFanIn) Initialize(properties json.RawMessage) error
Initialize is invoked by the Fiber library to initialize a new FanIn.
type ErrorLoggingInterceptor ¶
type ErrorLoggingInterceptor struct { *fiber.NoopBeforeDispatchInterceptor *fiber.NoopAfterDispatchInterceptor // contains filtered or unexported fields }
ErrorLoggingInterceptor is the structural interceptor used for logging error responses from individual routes
func (*ErrorLoggingInterceptor) AfterCompletion ¶
func (i *ErrorLoggingInterceptor) AfterCompletion( ctx context.Context, _ fiber.Request, queue fiber.ResponseQueue, )
AfterCompletion logs the response summary if any route returns an error
type MetricsInterceptor ¶
type MetricsInterceptor struct {
*fiber.NoopAfterDispatchInterceptor
}
MetricsInterceptor is the structural interceptor used for capturing run time metrics from the Fiber components
func (*MetricsInterceptor) AfterCompletion ¶
func (i *MetricsInterceptor) AfterCompletion( ctx context.Context, _ fiber.Request, queue fiber.ResponseQueue, )
AfterCompletion logs the time taken for the component to process the request, to the metrics collector
func (*MetricsInterceptor) BeforeDispatch ¶
func (i *MetricsInterceptor) BeforeDispatch( ctx context.Context, _ fiber.Request, ) context.Context
BeforeDispatch associates the start time to the context
type RouteResponse ¶
type RouteResponse struct { Route string `json:"route"` Data json.RawMessage `json:"data"` IsDefault bool `json:"is_default"` }
RouteResponse captures the result of each experiment
type TimeLoggingInterceptor ¶
type TimeLoggingInterceptor struct { *fiber.NoopAfterDispatchInterceptor // contains filtered or unexported fields }
TimeLoggingInterceptor is the structural interceptor used for logging responses
func (*TimeLoggingInterceptor) AfterCompletion ¶
func (i *TimeLoggingInterceptor) AfterCompletion( ctx context.Context, _ fiber.Request, _ fiber.ResponseQueue, )
AfterCompletion logs the time taken for the component to process the request and the response status
func (*TimeLoggingInterceptor) BeforeDispatch ¶
func (i *TimeLoggingInterceptor) BeforeDispatch( ctx context.Context, _ fiber.Request, ) context.Context
BeforeDispatch associates the start time to the context
type TracingInterceptor ¶
type TracingInterceptor struct {
*fiber.NoopAfterDispatchInterceptor
}
TracingInterceptor is the structural interceptor used for capturing run time metrics from the Fiber components
func (*TracingInterceptor) AfterCompletion ¶
func (i *TracingInterceptor) AfterCompletion( ctx context.Context, _ fiber.Request, _ fiber.ResponseQueue, )
AfterCompletion retrieves the span from the context, if exists, and finishes the trace
func (*TracingInterceptor) BeforeDispatch ¶
func (i *TracingInterceptor) BeforeDispatch( ctx context.Context, _ fiber.Request, ) context.Context
BeforeDispatch starts a new / child span and associates it with the context
type TrafficSplittingStrategy ¶
type TrafficSplittingStrategy struct { DefaultRouteID string `json:"default_route_id"` Rules []*TrafficSplittingStrategyRule `json:"rules" validate:"required,notBlank,dive"` }
TrafficSplittingStrategy selects the route based on the traffic splitting conditions, configured on this strategy
func (*TrafficSplittingStrategy) Initialize ¶
func (s *TrafficSplittingStrategy) Initialize(properties json.RawMessage) error
Initialize is invoked by the Fiber library to initialize this strategy with the configuration
func (*TrafficSplittingStrategy) SelectRoute ¶
func (s *TrafficSplittingStrategy) SelectRoute( ctx context.Context, req fiber.Request, routes map[string]fiber.Component, ) (fiber.Component, []fiber.Component, fiber.Labels, error)
SelectRoute picks primary and fallback routes based the traffic-splitting rules configured on this strategy
type TrafficSplittingStrategyRule ¶
type TrafficSplittingStrategyRule struct { RouteID string `json:"route_id" validate:"required,notBlank"` Conditions []*router.TrafficRuleCondition `json:"conditions" validate:"required,dive"` }
TrafficSplittingStrategyRule represents one rule of the TrafficSplittingStrategy Each rule maps set of conditions to one route configured on fiber router
func (*TrafficSplittingStrategyRule) TestRequest ¶
func (r *TrafficSplittingStrategyRule) TestRequest(req fiber.Request) (bool, error)
TestRequest checks if the request satisfies all conditions of this rule