model

package
v0.3.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: 8 Imported by: 1 module, 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 model defines the request and response models of the relay proxy HTTP API.

Index

Constants

View Source
const OFREPSSEEventTypeRefetchEvaluation = "refetchEvaluation"

OFREPSSEEventTypeRefetchEvaluation tells the provider that the flag configuration has changed and that it must re-fetch its evaluations.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFlagRequest

type AllFlagRequest struct {
	// LegacyUser captures the removed `user` request field so that the API can reject it
	// with an explicit error instead of silently ignoring it. It is never documented.
	LegacyUser any `hidden:"true" json:"user,omitempty"`
	// EvaluationContext The representation of a EvaluationContext for your feature flag system.
	EvaluationContext *EvaluationContextRequest `form:"evaluationContext" json:"evaluationContext,omitempty" query:"evaluationContext" xml:"evaluationContext,omitempty"` //nolint:lll // struct tags (json, yaml, toml, jsonschema, mapstructure) can not be wrapped
}

AllFlagRequest is the request body of the all flags evaluation API.

type CollectEvalDataRequest

type CollectEvalDataRequest struct {
	// Meta are the extra information added during the configuration
	Meta exporter.FeatureEventMetadata `json:"meta" required:"false"`

	// Events is the list of the event we send in the payload
	// here the type is any because we will unmarshal later in the different event types
	Events []map[string]any `json:"events" required:"false"`
}

CollectEvalDataRequest is the request to collect data in.

type CollectEvalDataResponse

type CollectEvalDataResponse struct {
	// IngestedContentCount number of model.FeatureEvents that have been sent to the data exporter
	IngestedContentCount int `form:"ingestedContentCount" json:"ingestedContentCount" query:"ingestedContentCount" xml:"ingestedContentCount"` //nolint:lll // struct tags (json, yaml, toml, jsonschema, mapstructure) can not be wrapped
}

CollectEvalDataResponse is the object returned by the health API.

type ConfigInfo added in v0.2.0

type ConfigInfo struct {
	// Reader is the outcome of the last manifest read by the manifest reader; absent before any read.
	Reader *ReaderInfo `json:"reader,omitempty"`
	// LastRejected is the most recent rejected round, kept until a later applied round supersedes it; absent then.
	LastRejected *ReloadInfo `json:"lastRejected,omitempty"`
	// Reloads counts the rounds by outcome: applied, rejected, ignored.
	Reloads map[string]uint64 `json:"reloads"`
	// Staleness says how long ago the held configuration was last confirmed by the control plane.
	Staleness StalenessInfo `json:"staleness"`
	// LastReload is the most recent round of any outcome.
	LastReload ReloadInfo `json:"lastReload"`
	// LastApplied is the most recent applied round.
	LastApplied ReloadInfo `json:"lastApplied"`
	// FlagSets are the flag sets by name.
	FlagSets []FlagSetInfo `json:"flagSets"`
	// Objects are the source objects by name.
	Objects []ObjectInfo `json:"objects"`
	// SegmentStores are the connections that can serve dynamic segments, with their state; left out when the file has
	// none.
	SegmentStores []SegmentStoreInfo `json:"segmentStores,omitempty"`
	// SegmentBindings is what the flag sets share of the dynamic segments; left out when none is served.
	SegmentBindings *SegmentBindingsInfo `json:"segmentBindings,omitempty"`
	// UnknownFields reports unknown fields noticed in control-plane documents, by kind; absent when zero.
	UnknownFields []UnknownFieldsInfo `json:"unknownFields,omitempty"`
	// Withdrawn lists the flag sets removed by the publisher.
	Withdrawn []WithdrawnInfo `json:"withdrawn"`
	// PendingRestart names the settings that changed and need a restart.
	PendingRestart []string `json:"pendingRestart"`
	// Public says which flag sets serve the requests without an API key: the flag sets published without a key.
	Public PublicInfo `json:"public"`
	// State says how the state directory is doing.
	State StateInfo `json:"state"`
	// DisabledAdminKeys counts the admin keys that are not accepted because a flag set publishes the same key.
	DisabledAdminKeys int `json:"disabledAdminKeys"`
	// Generation is the applied manifest generation, Snapshot the local swap counter.
	Generation uint64 `json:"generation"`
	Snapshot   uint64 `json:"snapshot"`
}

ConfigInfo is what /info says about the config v2 runtime. It never holds an API key, an admin key, a secret or the bytes of an object.

type DynamicStatesInfo added in v0.2.0

type DynamicStatesInfo struct {
	// Valid is the number of dynamic segments that the connections can serve.
	Valid int `json:"valid"`
	// Rejected is the number of dynamic definitions that were rejected.
	Rejected int `json:"rejected"`
	// StoreError is the number of served segments, among Valid, whose store failed on the last call or whose breaker
	// is open: they answer not a member with STORE_ERROR. Healthy is the number of the others.
	StoreError int `json:"storeError"`
	// Healthy is the number of served segments, among Valid, whose store answers.
	Healthy int `json:"healthy"`
}

DynamicStatesInfo is the dynamic segments of a flag set by state. A rejected definition is one that the connections of the bootstrap file cannot serve (a connection that is not in the file, a store that cannot serve the mode): it is rejected alone, the rest of its document is applied, and it answers as a segment without a provider. The reasons are in the log, never in this answer.

type EvalFlagRequest

type EvalFlagRequest struct {
	AllFlagRequest

	// The value will we use if we are not able to get the variation of the flag.
	DefaultValue any `form:"defaultValue" json:"defaultValue" query:"defaultValue" required:"false" xml:"defaultValue"`
}

EvalFlagRequest is the request body of a single flag evaluation API.

type EvaluationContextRequest

type EvaluationContextRequest struct {
	// Custom is a map containing all extra information for this user.
	Custom map[string]any `` //nolint:lll // struct tags (json, yaml, toml, jsonschema, mapstructure) can not be wrapped
	/* 194-byte string literal not displayed */
	// Key is the identifier of the evaluation context.
	Key string `example:"08b5ffb7-7109-42f4-a6f2-b85560fbd20f" form:"key" json:"key" query:"key" required:"false" xml:"key"` //nolint:lll // struct tags can not be wrapped
}

EvaluationContextRequest The representation of a EvaluationContext for your feature flag system.

type FlagEval

type FlagEval struct {
	Value any `json:"value"`
}

FlagEval is the response body of a flag evaluation.

type FlagSetInfo added in v0.2.0

type FlagSetInfo struct {
	Name     string        `json:"name"`
	State    string        `json:"state"`
	Problems []ProblemInfo `json:"problems"`
	Flags    int           `json:"flags"`
	APIKeys  int           `json:"apiKeys"`
	Rejected int           `json:"rejected"`
	// Segments counts the segments of the flag set by kind; it is left out for a flag set without segments.
	Segments *SegmentCountsInfo `json:"segments,omitempty"`
}

FlagSetInfo is the state of one flag set: ready, degraded or pending.

type HealthResponse

type HealthResponse struct {
	// Set to true if the HTTP server is started
	Initialized bool `example:"true" json:"initialized"`
}

HealthResponse is the object returned by the health API.

type InfoResponse

type InfoResponse struct {
	// LatestCacheRefresh is the last time when your flag file was read and stored in the internal cache.
	// This field is used for backward compatibility when using the default flagset.
	LatestCacheRefresh *time.Time `example:"2022-06-13T11:22:55.941628+02:00" json:"cacheRefresh,omitempty"`

	// Flagsets contains the cache refresh dates for each flagset when using multiple flagsets.
	// The format is {"flagset name": "2022-06-13T11:22:55.941628+02:00"}
	Flagsets map[string]time.Time `example:"{\"default\":\"2022-06-13T11:22:55.941628+02:00\"}" json:"flagsets,omitempty"` //nolint:lll // struct tags (json, yaml, toml, jsonschema, mapstructure) can not be wrapped

	// Config is the state of the config v2 runtime: generation, reloads, flag sets and objects.
	Config *ConfigInfo `json:"config,omitempty"`

	// Listeners are the listeners that serve TLS, with the certificate each serves now; left out when none does.
	Listeners []ListenerInfo `json:"listeners,omitempty"`
}

InfoResponse is the object returned by the info API.

type ListenerInfo added in v0.3.0

type ListenerInfo struct {
	// NotBefore and NotAfter are the validity of the certificate.
	NotBefore time.Time `json:"notBefore"`
	NotAfter  time.Time `json:"notAfter"`
	// Name is the name of the listener role: "api" or "ops".
	Name string `json:"name"`
	// Source is where the certificate comes from: "files", "env" or "selfSigned".
	Source string `json:"source"`
	// Fingerprint is the SHA-256 of the DER certificate, in lower case hexadecimal.
	Fingerprint string `json:"fingerprintSha256"`
	// Certificate is the PEM certificate (public part), set for a generated certificate so that a client can pin it.
	Certificate string `json:"certificate,omitempty"`
	// Names are the DNS names and IP addresses of the certificate.
	Names []string `json:"names"`
}

ListenerInfo is the certificate a TLS listener serves. It never holds a private key.

type LiveResponse added in v0.2.0

type LiveResponse struct {
	// Live is true while the process serves.
	Live bool `example:"true" json:"live"`
}

LiveResponse is the body of /livez.

type ManifestDefinitionSuccessResponse

type ManifestDefinitionSuccessResponse struct {
	Key          string         `json:"key"`
	FlagType     model.FlagType `enum:"boolean,string,integer,float,object" json:"type"`
	DefaultValue any            `json:"defaultValue"`
	Description  string         `json:"description"`
}

ManifestDefinitionSuccessResponse is the response body of a successful flag manifest request.

type ManifestError

type ManifestError struct {
	ErrorDetails ManifestErrorDetails `json:"error"`
}

ManifestError is the error response of the flag manifest API.

type ManifestErrorDetails

type ManifestErrorDetails struct {
	Message string `example:"Authorization header required" json:"message"`
	Status  int    `example:"401"                           json:"status"`
}

ManifestErrorDetails holds the details of a flag manifest error.

type ManifestSuccessResponse

type ManifestSuccessResponse struct {
	Flags []ManifestDefinitionSuccessResponse `json:"flags"`
}

ManifestSuccessResponse is the machine-readable manifest envelope for CLI and tooling.

type OFREPBulkEvaluateSuccessResponse

type OFREPBulkEvaluateSuccessResponse struct {
	Flags        []OFREPFlagBulkEvaluateSuccessResponse `json:"flags"`
	EventStreams []OFREPEventStream                     `json:"eventStreams,omitempty"`
}

OFREPBulkEvaluateSuccessResponse is the response body of a successful OFREP bulk evaluation.

type OFREPCommonResponseError

type OFREPCommonResponseError struct {
	ErrorCode flagdef.ErrorCode `` //nolint:lll // struct tags can not be wrapped
	/* 141-byte string literal not displayed */
	ErrorDetails string `json:"errorDetails"`
}

OFREPCommonResponseError is the error response shared by the OFREP endpoints.

func (*OFREPCommonResponseError) Error

func (o *OFREPCommonResponseError) Error() string

type OFREPEvalFlagRequest

type OFREPEvalFlagRequest struct {
	Context map[string]any `` /* 216-byte string literal not displayed */
}

OFREPEvalFlagRequest is the request body of an OFREP flag evaluation.

type OFREPEvaluateResponseError

type OFREPEvaluateResponseError struct {
	OFREPCommonResponseError `yaml:",inline"`

	Key string `json:"key"`
}

OFREPEvaluateResponseError is the error response of an OFREP flag evaluation.

type OFREPEvaluateSuccessResponse

type OFREPEvaluateSuccessResponse struct {
	Key      string         `json:"key"`
	Value    any            `json:"value,omitempty"`
	Reason   string         `json:"reason"`
	Variant  string         `json:"variant"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

OFREPEvaluateSuccessResponse is the OFREP evaluation result (also the bulk result items, whose strong ETag hashes the serialized bytes).

func (*OFREPEvaluateSuccessResponse) MarshalJSONTo added in v0.3.0

func (r *OFREPEvaluateSuccessResponse) MarshalJSONTo(enc *jsontext.Encoder) error

MarshalJSONTo is the streaming method that encoding/json calls (in the Go versions that build it on encoding/json/v2). A result whose value is a stored encoding is written from a struct that holds the bytes as raw JSON: an interface that holds a value of a type with a method of its own costs the encoder two allocations, the raw field none. Any other result is left to the default encoding (the method reports it unsupported before it writes anything), so what it writes and what it allocates are what they were.

type OFREPEventStream

type OFREPEventStream struct {
	Type               string `json:"type"`
	URL                string `json:"url"`
	InactivityDelaySec int    `json:"inactivityDelaySec,omitempty"`
}

OFREPEventStream describes a stream a provider can subscribe to in order to be notified of flag changes instead of polling, as defined by OpenFeature ADR-0008.

type OFREPFlagBulkEvaluateSuccessResponse

type OFREPFlagBulkEvaluateSuccessResponse struct {
	OFREPEvaluateSuccessResponse

	ErrorCode    string `json:"errorCode,omitempty"`
	ErrorDetails string `json:"errorDetails,omitempty"`
}

OFREPFlagBulkEvaluateSuccessResponse is the result of one flag in an OFREP bulk evaluation.

func (*OFREPFlagBulkEvaluateSuccessResponse) MarshalJSONTo added in v0.3.0

MarshalJSONTo is the streaming method of the item: see OFREPEvaluateSuccessResponse.MarshalJSONTo. It is defined here too because the method of the embedded result would otherwise be promoted and drop the error fields.

type OFREPSSEEvent

type OFREPSSEEvent struct {
	// Type of the event, providers must ignore the types they don't know.
	Type string `example:"refetchEvaluation" json:"type"`
	// ETag identifies the flag configuration that the change leads to. A provider sends it back as the
	// flagConfigEtag query parameter of its re-fetch, so that a relay that has not loaded that configuration yet
	// checks its control plane before it answers.
	ETag string `example:"3f9a1c" json:"etag,omitempty"`
	// LastModified is the unix timestamp (in seconds) of the flag configuration change.
	LastModified int64 `example:"1771622898" json:"lastModified,omitempty"`
}

OFREPSSEEvent is the payload of the events sent on the OFREP SSE stream, as defined by OpenFeature ADR-0008.

type ObjectInfo added in v0.2.0

type ObjectInfo struct {
	Name  string `json:"name"`
	Kind  string `json:"kind"`
	State string `json:"state"`
	// Reason is the closed code of the failure of the last load of the object, empty when it loaded.
	Reason string `json:"reason,omitempty"`
	// ChecksumHeld is the checksum of the content served, ChecksumListed the one the manifest lists.
	ChecksumHeld   string `json:"checksumHeld"`
	ChecksumListed string `json:"checksumListed,omitempty"`
	Flags          int    `json:"flags"`
	Rejected       int    `json:"rejected"`
	// Kept is the number of rejected flags that are served from an earlier version of the object. The state directory
	// holds the bytes of the object, not that earlier version: a restart serves none of these flags.
	Kept int `json:"kept"`
}

ObjectInfo is the state of one source object: ok, stale, missing, pending or invalid.

type ProblemInfo added in v0.2.0

type ProblemInfo struct {
	Code    string `json:"code"`
	Subject string `json:"subject,omitempty"`
}

ProblemInfo is a reported problem of a flag set: a closed code and the object it is about. The free text of the problem is not served, for it can quote the content of an object.

type PublicInfo added in v0.2.0

type PublicInfo struct {
	// Sets are the names of the flag sets, sorted.
	Sets    []string `json:"sets"`
	Flags   int      `json:"flags"`
	Present bool     `json:"present"`
}

PublicInfo is the status of the public namespace: the flag sets published without an API key, merged. Present says that a request without a key is served.

type ReaderInfo added in v0.2.0

type ReaderInfo struct {
	// At is when the reader processed the last manifest; absent before any manifest was read.
	At *time.Time `json:"at,omitempty"`
	// Outcome is the closed outcome of the last read manifest.
	Outcome string `json:"outcome"`
	// Reason uses the same closed rejection-reason set as semaphore_config_reader_rejections_total; empty when accepted.
	Reason string `json:"reason,omitempty"`
}

ReaderInfo reports the outcome of the last manifest read by the manifest reader. A manifest that the reader rejects never reaches the engine, so it shows here rather than in LastRejected.

type ReadyResponse added in v0.2.0

type ReadyResponse struct {
	// State is set when ready: empty, serving or degraded.
	State string `example:"serving" json:"state,omitempty"`
	// Reason is set when not ready: starting, waiting-for-manifest, waiting-for-segment-stores or shutting-down.
	Reason string `example:"waiting-for-manifest" json:"reason,omitempty"`
	// Ready is true when the relay is able to serve.
	Ready bool `example:"true" json:"ready"`
}

ReadyResponse is the body of /readyz and /startupz. It never holds a key, a name or a credential.

type ReloadInfo added in v0.2.0

type ReloadInfo struct {
	// At is when the round ended; absent before the first round.
	At         *time.Time `json:"at,omitempty"`
	Outcome    string     `json:"outcome"`
	Code       string     `json:"code"`
	Generation uint64     `json:"generation"`
}

ReloadInfo is the result of one round.

The free text of a round (the detail) is not served: it can quote the content of an object. The code is a closed reason; the detail is in the logs.

type SegmentBindingsInfo added in v0.2.0

type SegmentBindingsInfo struct {
	// Snapshots is the state of the held sets (snapshot mode) of each connection.
	Snapshots []SegmentSnapshotInfo `json:"snapshots,omitempty"`
	// Live is the number of bindings that the served runtime uses.
	Live int `json:"live"`
}

SegmentBindingsInfo is the shared state of the dynamic segments: one binding serves every flag set and every generation that uses one segments object on one connection.

type SegmentCountsInfo added in v0.2.0

type SegmentCountsInfo struct {
	// DynamicStates tells how many of the dynamic definitions are valid and how many were rejected; it is left out
	// when the flag set has no dynamic segment and no rejection.
	DynamicStates *DynamicStatesInfo `json:"dynamicStates,omitempty"`
	// UnresolvedNames are the first segment names (sorted, bounded) that flags of the flag set use and no segments
	// object of the flag set defines; Unresolved is how many there are. Names only.
	UnresolvedNames []string `json:"unresolvedNames,omitempty"`
	Static          int      `json:"static"`
	Dynamic         int      `json:"dynamic"`
	Unresolved      int      `json:"unresolved,omitempty"`
}

SegmentCountsInfo is the number of segments of a flag set: static (members in the document) and dynamic (members in a store).

type SegmentSnapshotInfo added in v0.2.0

type SegmentSnapshotInfo struct {
	Connection  string `json:"connection"`
	Loaded      int    `json:"loaded"`
	Stale       int    `json:"stale"`
	Missing     int    `json:"missing"`
	NeverLoaded int    `json:"neverLoaded"`
	Members     int    `json:"members"`
}

SegmentSnapshotInfo counts the held sets of one connection by state: loaded, stale (the last refresh failed or the set is over the limit), missing (the store does not have the segment) and never loaded; Members is the total.

type SegmentStoreInfo added in v0.2.0

type SegmentStoreInfo struct {
	Name  string `json:"name"`
	Kind  string `json:"kind"`
	State string `json:"state"`
}

SegmentStoreInfo is the state of one connection that can serve dynamic segments: idle (no segment uses it), connecting, connected or error (the last dial failed; it is dialled again until it works).

type StalenessInfo added in v0.2.0

type StalenessInfo struct {
	// LastConfirmed is the last poll that confirmed the held manifest, absent when there was none.
	LastConfirmed *time.Time `json:"lastConfirmed,omitempty"`
	// LastSuccessfulReload is the last applied round, absent when there was none.
	LastSuccessfulReload *time.Time `json:"lastSuccessfulReload,omitempty"`
	// AgeSeconds is the time since LastConfirmed, 0 when there was none.
	AgeSeconds float64 `json:"ageSeconds"`
}

StalenessInfo is the age of the configuration.

type StateInfo added in v0.2.0

type StateInfo struct {
	// LastSaveError is the closed code of the failure of the last write (no-space, denied, io, unsafe), empty when it
	// worked.
	LastSaveError string `json:"lastSaveError"`
	// Saves and SaveErrors count the writes that ended, and the ones that failed.
	Saves      uint64 `json:"saves"`
	SaveErrors uint64 `json:"saveErrors"`
	// KeptFlags is the number of flags, over all objects, that are served from an earlier version of their object
	// and that a restart from the state directory would not serve (see ObjectInfo.Kept).
	KeptFlags int `json:"keptFlags"`
	// Enabled tells that a state directory is in use.
	Enabled bool `json:"enabled"`
}

StateInfo is the state directory as /info shows it: whether one is in use, and whether the writes work. A write that fails never stops the relay from serving; this is where it shows.

type UnknownFieldsInfo added in v0.2.0

type UnknownFieldsInfo struct {
	// Kind is the document kind ("manifest", "flagSets", "flags", "segments").
	Kind string `json:"kind"`
	// Fields lists the first field paths (bounded, sorted), never field values.
	Fields []string `json:"fields,omitempty"`
	// Count is the total number of unknown fields across documents of this kind.
	Count int `json:"count"`
}

UnknownFieldsInfo reports unknown fields noticed when decoding control-plane documents of one kind.

type WithdrawnInfo added in v0.2.0

type WithdrawnInfo struct {
	Name       string `json:"name"`
	Generation uint64 `json:"generation"`
}

WithdrawnInfo is a flag set removed by the publisher.

Jump to

Keyboard shortcuts

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