experiment

package
v0.0.0-...-1c6d3df Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExperimentResponseChannel

func GetExperimentResponseChannel(ctx context.Context) (chan *Response, error)

GetExperimentResponseChannel returns a pointer to a channel of type *Response, which holds the experiment treatment / error, from the input context

func NewExperimentRunner

func NewExperimentRunner(
	name string,
	cfg map[string]interface{},
	livenessPeriodSeconds int,
) (runner.ExperimentRunner, error)

NewExperimentRunner returns an instance of the Planner, based on the input engine name

func NewMetricsInterceptor

func NewMetricsInterceptor() runner.Interceptor

NewMetricsInterceptor is a creator for a MetricsInterceptor

func WithExperimentResponseChannel

func WithExperimentResponseChannel(ctx context.Context, ch chan *Response) context.Context

WithExperimentResponseChannel associates a pointer to a channel of type *Response to the given context object

Types

type MetricsInterceptor

type MetricsInterceptor struct{}

MetricsInterceptor is the structural interceptor used for capturing metrics from experiment runs

func (*MetricsInterceptor) AfterCompletion

func (i *MetricsInterceptor) AfterCompletion(
	ctx context.Context,
	err error,
)

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,
) context.Context

BeforeDispatch associates the start time to the context

type Response

type Response struct {
	// Success response from the experiment engine, unmodified
	Configuration json.RawMessage `json:"configuration,omitempty"`
	// Experiment and treatment name are omitted for now as client does not depend on this.
	ExperimentName string `json:"-"`
	TreatmentName  string `json:"-"`
	// Error message
	Error string `json:"error,omitempty"`
}

Response holds the experiment configuration / error response, also satisfies the missionctl/http Response interface

func NewResponse

func NewResponse(expPlan *runner.Treatment, expPlanErr error) *Response

NewResponse is a helper function to create an object of type Response that holds the experiment treatment / appropriate error information

func (*Response) Body

func (r *Response) Body() []byte

Body satisfies the Response interface, returning the raw configuration

func (*Response) Header

func (r *Response) Header() http.Header

Header satisfies the Response interface, returns nil

Jump to

Keyboard shortcuts

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