wasm

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RateLimitServiceName       = "ratelimit-service"
	RateLimitCheckServiceName  = "ratelimit-check-service"
	RateLimitReportServiceName = "ratelimit-report-service"
	AuthServiceName            = "auth-service"
	TracingServiceName         = "tracing-service"
)

Variables

This section is empty.

Functions

func ActionSetNameForPath

func ActionSetNameForPath(pathID string, httpRouteMatchIndex int, hostname string) string

func AuthServiceTimeout

func AuthServiceTimeout() string

func BuildActionSetsForPath

func BuildActionSetsForPath(ctx context.Context, pathID string, path []machinery.Targetable, actions []Action) ([]kuadrantgatewayapi.HTTPRouteMatchConfig, error)

func ExtensionName

func ExtensionName(gatewayName string) string

func PredicatesFromHTTPRouteMatch

func PredicatesFromHTTPRouteMatch(match gatewayapiv1.HTTPRouteMatch) []string

PredicatesFromHTTPRouteMatch builds a list of conditions from a rule match

func RatelimitCheckServiceTimeout added in v1.3.0

func RatelimitCheckServiceTimeout() string

func RatelimitReportServiceTimeout added in v1.3.0

func RatelimitReportServiceTimeout() string

func RatelimitServiceTimeout

func RatelimitServiceTimeout() string

func TracingServiceTimeout added in v1.4.0

func TracingServiceTimeout() string

Types

type Action

type Action struct {
	ServiceName string `json:"service"`
	Scope       string `json:"scope"`

	Predicates []string `json:"predicates,omitempty"`

	// ConditionalData data contains the predicates and data that will be sent to the service
	// +optional
	ConditionalData []ConditionalData `json:"conditionalData,omitempty"`

	// SourcePolicyLocators tracks all policies that contributed to this action.
	// This is important for policies that can be merged (e.g., Gateway-level + HTTPRoute-level).
	// For atomic merge strategies or individual rules, this may contain a single entry.
	// Serialized to wasm config as "sources" for observability and debugging.
	// Format: "kind/namespace/name"
	SourcePolicyLocators []string `json:"sources,omitempty"`
}

func (*Action) EqualTo

func (a *Action) EqualTo(other Action) bool

func (*Action) HasAuthAccess

func (a *Action) HasAuthAccess() bool

type ActionSet

type ActionSet struct {
	Name string `json:"name"`

	// Conditions that activate the action set
	RouteRuleConditions RouteRuleConditions `json:"routeRuleConditions,omitempty"`

	// Actions that will be invoked when the conditions are met
	// +optional
	Actions []Action `json:"actions,omitempty"`
}

func (*ActionSet) EqualTo

func (s *ActionSet) EqualTo(other ActionSet) bool

type ConditionalData added in v1.3.0

type ConditionalData struct {
	// Predicates holds a list of CEL predicates
	// +optional
	Predicates []string `json:"predicates,omitempty"`

	// Data to be sent to the service
	// +optional
	Data []DataType `json:"data,omitempty"`
}

func (*ConditionalData) EqualTo added in v1.3.0

func (c *ConditionalData) EqualTo(other ConditionalData) bool

type Config

type Config struct {
	RequestData   map[string]string  `json:"requestData,omitempty"`
	Services      map[string]Service `json:"services"`
	ActionSets    []ActionSet        `json:"actionSets"`
	Observability *Observability     `json:"observability,omitempty"`
}

func BuildConfigForActionSet

func BuildConfigForActionSet(actionSets []ActionSet, logger *logr.Logger, observability *Observability, serviceBuilder *ServiceBuilder) Config

func ConfigFromJSON

func ConfigFromJSON(configJSON *apiextensionsv1.JSON) (*Config, error)

func ConfigFromStruct

func ConfigFromStruct(structure *structpb.Struct) (*Config, error)

func (*Config) EqualTo

func (c *Config) EqualTo(other *Config) bool

func (*Config) ToJSON

func (c *Config) ToJSON() (*apiextensionsv1.JSON, error)

func (*Config) ToStruct

func (c *Config) ToStruct() (*_struct.Struct, error)

type DataType

type DataType struct {
	Value interface{}
}

func (*DataType) EqualTo

func (d *DataType) EqualTo(other DataType) bool

func (*DataType) MarshalJSON

func (d *DataType) MarshalJSON() ([]byte, error)

func (*DataType) UnmarshalJSON

func (d *DataType) UnmarshalJSON(data []byte) error

type Expression

type Expression struct {
	// Data to be sent to the service
	ExpressionItem ExpressionItem `json:"expression"`
}

type ExpressionItem

type ExpressionItem struct {
	// Key holds the expression key
	Key string `json:"key"`

	// Value holds the CEL expression
	Value string `json:"value"`
}

type FailureModeType

type FailureModeType string

+kubebuilder:validation:Enum:=deny;allow

const (
	FailureModeDeny  FailureModeType = "deny"
	FailureModeAllow FailureModeType = "allow"
)

func AuthServiceFailureMode

func AuthServiceFailureMode(logger *logr.Logger) FailureModeType

func RatelimitCheckServiceFailureMode added in v1.3.0

func RatelimitCheckServiceFailureMode(logger *logr.Logger) FailureModeType

func RatelimitReportServiceFailureMode added in v1.3.0

func RatelimitReportServiceFailureMode(logger *logr.Logger) FailureModeType

func RatelimitServiceFailureMode

func RatelimitServiceFailureMode(logger *logr.Logger) FailureModeType

func TracingServiceFailureMode added in v1.4.0

func TracingServiceFailureMode(logger *logr.Logger) FailureModeType

type LogLevel added in v1.4.0

type LogLevel int
const (
	LogLevelError LogLevel = iota
	LogLevelWarn
	LogLevelInfo
	LogLevelDebug
)

func (LogLevel) String added in v1.4.0

func (ll LogLevel) String() string

type Observability added in v1.4.0

type Observability struct {
	HTTPHeaderIdentifier *string  `json:"httpHeaderIdentifier,omitempty"`
	DefaultLevel         *string  `json:"defaultLevel,omitempty"`
	Tracing              *Tracing `json:"tracing,omitempty"`
}

func BuildObservabilityConfig added in v1.4.0

func BuildObservabilityConfig(serviceBuilder *ServiceBuilder, observabilitySpec *v1beta1.Observability) *Observability

BuildObservabilityConfig builds the wasm-shim observability config from the Observability spec For MVP: finds the highest priority level that is set to "true" Priority: DEBUG(4) > INFO(3) > WARN(2) > ERROR(1) Future: will support dynamic CEL predicates for request-time evaluation

func (*Observability) EqualTo added in v1.4.0

func (o *Observability) EqualTo(other *Observability) bool

type RouteRuleConditions

type RouteRuleConditions struct {
	Hostnames []string `json:"hostnames"`

	// +optional
	Predicates []string `json:"predicates,omitempty"`
}

func (*RouteRuleConditions) EqualTo

func (r *RouteRuleConditions) EqualTo(other RouteRuleConditions) bool

type Service

type Service struct {
	Endpoint    string          `json:"endpoint"`
	Type        ServiceType     `json:"type"`
	FailureMode FailureModeType `json:"failureMode"`
	Timeout     *string         `json:"timeout,omitempty"`
}

func (Service) EqualTo

func (s Service) EqualTo(other Service) bool

type ServiceBuilder added in v1.4.0

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

ServiceBuilder helps build wasm services with optional configurations using the builder pattern

func NewServiceBuilder added in v1.4.0

func NewServiceBuilder(logger *logr.Logger) *ServiceBuilder

NewServiceBuilder creates a new ServiceBuilder with default services

func (*ServiceBuilder) Build added in v1.4.0

func (sb *ServiceBuilder) Build() map[string]Service

Build returns the built services map

func (*ServiceBuilder) WithService added in v1.4.0

func (sb *ServiceBuilder) WithService(name string, service Service) *ServiceBuilder

WithService adds a custom service

func (*ServiceBuilder) WithTracing added in v1.4.0

func (sb *ServiceBuilder) WithTracing() *ServiceBuilder

WithTracing adds a tracing service with the specified endpoint

type ServiceType

type ServiceType string

+kubebuilder:validation:Enum:=ratelimit;auth;ratelimit-check;ratelimit-report;tracing

const (
	RateLimitServiceType       ServiceType = "ratelimit"
	RateLimitCheckServiceType  ServiceType = "ratelimit-check"
	RateLimitReportServiceType ServiceType = "ratelimit-report"
	AuthServiceType            ServiceType = "auth"
	TracingServiceType         ServiceType = "tracing"
)

type Static

type Static struct {
	Static StaticSpec `json:"static"`
}

type StaticSpec

type StaticSpec struct {
	Value string `json:"value"`
	Key   string `json:"key"`
}

type Tracing added in v1.4.0

type Tracing struct {
	Service string `json:"service,omitempty"`
}

func (*Tracing) EqualTo added in v1.4.0

func (t *Tracing) EqualTo(other *Tracing) bool

Jump to

Keyboard shortcuts

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