fiberapi

package
v0.0.0-...-20989ac Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const FanInID = "fan_in"

FanInID is used to indendify the fan in component when capturing a request span

Variables

This section is empty.

Functions

func CreateFiberRequestHandler

func CreateFiberRequestHandler(
	cfgFilePath string,
	timeout time.Duration,
	fiberDebugLog bool,
) (*fiberhttp.Handler, error)

CreateFiberRequestHandler creates a new Fiber component from the given config file, associates it with a Fiber HTTP handler and returns it.

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

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,
	req 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,
	req 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,
	req 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,
	req fiber.Request,
	queue 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,
	req 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,
	req fiber.Request,
	queue 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,
	req 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

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,notBlank,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(reqHeader http.Header, bodyBytes []byte) (bool, error)

TestRequest checks if the request satisfies all conditions of this rule

Directories

Path Synopsis
internal
testutils
Package testutils contains mocks that can be shared across tests for multiple packages
Package testutils contains mocks that can be shared across tests for multiple packages

Jump to

Keyboard shortcuts

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