ofrep

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ofrep implements the OFREP evaluation handlers of the relay proxy.

Index

Constants

View Source
const (
	// MetadataCacheable is the response metadata key telling a provider that it can cache the value.
	MetadataCacheable = "semaphore_cacheable"
	// LegacyMetadataCacheable is the key GO Feature Flag used for the same information. The upstream
	// providers read it, so it is still sent next to MetadataCacheable.
	LegacyMetadataCacheable = "gofeatureflag_cacheable"
)

ofrepSSEPath is the path of the relay proxy endpoint streaming flag changes over SSE.

View Source
const DefaultBulkTagMemo = 8192

DefaultBulkTagMemo is the number of answers whose tag a controller remembers (see WithBulkTagMemo).

View Source
const MaxBodyBytes = 1 << 20

MaxBodyBytes is the size of the largest request body of an evaluation. An evaluation context is a few hundred bytes, a bulk request with a list of flag keys a few kilobytes.

Variables

View Source
var (
	// ErrEventStreamInactivityDelay is the error of a negative inactivity delay.
	ErrEventStreamInactivityDelay = errors.New("the event stream inactivity delay must not be negative, got")
	// ErrEventStreamBaseURL is the error of a base URL that is not an absolute http(s) URL.
	ErrEventStreamBaseURL = errors.New("the event stream base URL must be an absolute http(s) URL")
	// ErrEventStreamBaseURLQuery is the error of a base URL that has a query or a fragment.
	ErrEventStreamBaseURLQuery = errors.New("the event stream base URL must not contain a query or a fragment")
)
View Source
var ErrBodyTooLarge = errors.New("the request body is too large")

ErrBodyTooLarge is the error of a request body larger than MaxBodyBytes.

Functions

func NewEvaluateError

func NewEvaluateError(
	key string,
	errorCode flagdef.ErrorCode,
	errorDetails string,
) *model.OFREPEvaluateResponseError

NewEvaluateError returns the OFREP error response for a failed flag evaluation.

func NewOFREPCommonError

func NewOFREPCommonError(
	errorCode flagdef.ErrorCode,
	errorDetails string,
) *model.OFREPCommonResponseError

NewOFREPCommonError returns the OFREP error response shared by the OFREP endpoints.

Types

type EvaluateCtrl

type EvaluateCtrl struct {
	// contains filtered or unexported fields
}

EvaluateCtrl serves the OFREP evaluation requests of the relay proxy.

func NewOFREPEvaluate

func NewOFREPEvaluate(
	flagsetManager service.FlagSetResolver,
	metrics *metric.Metrics,
	eventStream EventStream,
	opts ...Option,
) EvaluateCtrl

NewOFREPEvaluate returns the controller that evaluates flags through the OFREP API.

func (*EvaluateCtrl) BulkEvaluate

func (h *EvaluateCtrl) BulkEvaluate(w http.ResponseWriter, r *http.Request) error

BulkEvaluate is the entry point to evaluate in bulk flags using the OpenFeature Remote Evaluation Protocol.

func (*EvaluateCtrl) Evaluate

func (h *EvaluateCtrl) Evaluate(w http.ResponseWriter, r *http.Request) error

Evaluate is the entry point to evaluate a flag using the OpenFeature Remote Evaluation Protocol.

type EventStream added in v0.2.0

type EventStream struct {
	// contains filtered or unexported fields
}

EventStream is what the bulk evaluation response advertises of the flag-change SSE endpoint (OpenFeature ADR-0008). The zero value advertises nothing. The only way to set it is NewEventStream, which validates it, so a value of this type is always valid.

func NewEventStream added in v0.2.0

func NewEventStream(baseURL string, inactivityDelaySec int) (EventStream, error)

NewEventStream returns the event stream advertised at baseURL, the public base URL clients use to reach the relay proxy (an absolute http or https URL without query or fragment), with the delay in seconds after which a client considers the stream inactive (0 omits it). An empty baseURL returns the zero value: nothing is advertised. A negative delay or an invalid base URL is an error. The URL may embed credentials: it is never part of the error.

func (EventStream) IsEnabled added in v0.2.0

func (e EventStream) IsEnabled() bool

IsEnabled reports whether the eventStreams field is added to the bulk evaluation response.

type Option

type Option func(*EvaluateCtrl)

Option customizes an EvaluateCtrl.

func WithBulkTagMemo added in v0.2.0

func WithBulkTagMemo(size int) Option

WithBulkTagMemo sets the number of bulk answers whose tag the controller remembers (see DefaultBulkTagMemo): the request that holds the tag of a remembered answer is answered 304 with no flag evaluated. A size that is not positive turns the memo off: every request evaluates.

func WithConfigGate added in v0.2.0

func WithConfigGate(gate *configsync.Gate) Option

WithConfigGate sets the gate that starts the control plane checks of the bulk evaluations that name a newer configuration; the default is a gate on the clock of the process.

func WithLegacyMetadataOnly

func WithLegacyMetadataOnly(legacyOnly bool) Option

WithLegacyMetadataOnly stops the controller from adding the Semaphore metadata keys (semaphore_cacheable) next to the legacy ones.

Jump to

Keyboard shortcuts

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