kernel

package
v0.0.0-...-2670c00 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Wso2MetadataPrefix = "x-wso2-"
	APIIDKey           = Wso2MetadataPrefix + "api-id"
	APINameKey         = Wso2MetadataPrefix + "api-name"
	APIVersionKey      = Wso2MetadataPrefix + "api-version"
	APITypeKey         = Wso2MetadataPrefix + "api-type"
	APIContextKey      = Wso2MetadataPrefix + "api-context"
	OperationPathKey   = Wso2MetadataPrefix + "operation-path"
	APIKindKey         = Wso2MetadataPrefix + "api-kind"
	ProjectIDKey       = Wso2MetadataPrefix + "project-id"
)

Constants for analytics metadata

Variables

This section is empty.

Functions

func TranslateRequestBodyActions

func TranslateRequestBodyActions(result *executor.RequestExecutionResult, chain *registry.PolicyChain, execCtx *PolicyExecutionContext) (*extprocv3.ProcessingResponse, error)

TranslateRequestBodyActions converts request body execution result to ext_proc response

func TranslateRequestHeadersActions

func TranslateRequestHeadersActions(result *executor.RequestExecutionResult, chain *registry.PolicyChain, execCtx *PolicyExecutionContext) (*extprocv3.ProcessingResponse, error)

TranslateRequestHeadersActions converts request headers execution result to ext_proc response

func TranslateResponseBodyActions

func TranslateResponseBodyActions(result *executor.ResponseExecutionResult, execCtx *PolicyExecutionContext) (*extprocv3.ProcessingResponse, error)

TranslateResponseBodyActions converts response body execution result to ext_proc response

func TranslateResponseHeadersActions

func TranslateResponseHeadersActions(result *executor.ResponseExecutionResult, execCtx *PolicyExecutionContext) (*extprocv3.ProcessingResponse, error)

TranslateResponseHeadersActions converts response headers execution result to ext_proc response

Types

type BodyMode

type BodyMode int

BodyMode represents ext_proc body processing mode

const (
	// BodyModeSkip - skip body processing (headers only)
	BodyModeSkip BodyMode = iota
	// BodyModeBuffered - buffer entire body for processing
	BodyModeBuffered
)

type ConfigLoader

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

ConfigLoader loads policy chain configurations T077: Implement file-based configuration loader as fallback

func NewConfigLoader

func NewConfigLoader(kernel *Kernel, reg *registry.PolicyRegistry) *ConfigLoader

NewConfigLoader creates a new configuration loader

func (*ConfigLoader) LoadFromFile

func (cl *ConfigLoader) LoadFromFile(path string) error

LoadFromFile loads policy chain configurations from a YAML file T077: File-based configuration loader implementation

type ExternalProcessorServer

type ExternalProcessorServer struct {
	extprocv3.UnimplementedExternalProcessorServer
	// contains filtered or unexported fields
}

ExternalProcessorServer implements the Envoy external processor service T059: ExternalProcessorServer gRPC service struct

func NewExternalProcessorServer

func NewExternalProcessorServer(kernel *Kernel, chainExecutor *executor.ChainExecutor, tracingConfig config.TracingConfig, tracingServiceName string) *ExternalProcessorServer

NewExternalProcessorServer creates a new ExternalProcessorServer

func (*ExternalProcessorServer) Process

Process implements the bidirectional streaming RPC handler T060: Process(stream) bidirectional streaming RPC handler

type Kernel

type Kernel struct {

	// Route-to-chain mapping
	// Key: metadata key from Envoy
	// Value: PolicyChain for that route
	Routes map[string]*registry.PolicyChain
	// contains filtered or unexported fields
}

Kernel represents the integration layer between Envoy and the policy execution engine T050: Kernel struct with Routes map

func NewKernel

func NewKernel() *Kernel

NewKernel creates a new Kernel instance

func (*Kernel) ApplyWholeRoutes

func (k *Kernel) ApplyWholeRoutes(newRoutes map[string]*registry.PolicyChain)

ApplyWholeRoutes replaces all existing route mappings with the provided set

func (*Kernel) BuildPolicyChain

func (k *Kernel) BuildPolicyChain(routeKey string, policySpecs []policy.PolicySpec, reg *registry.PolicyRegistry, apiMetadata policy.PolicyMetadata) (*registry.PolicyChain, error)

BuildPolicyChain creates a PolicyChain from PolicySpecs with body requirement computation T055: BuildPolicyChain with body requirement computation apiMetadata is optional and can contain API-level information for policies that need it

func (*Kernel) DumpRoutes

func (k *Kernel) DumpRoutes() map[string]*registry.PolicyChain

DumpRoutes returns a copy of all route mappings for debugging Returns a map of route key -> policy chain

func (*Kernel) GetPolicyChainForKey

func (k *Kernel) GetPolicyChainForKey(key string) *registry.PolicyChain

GetPolicyChainForKey retrieves the policy chain for a given metadata key T051: GetPolicyChainForKey method implementation Returns nil when no policy chain exists for the route (not an error condition)

func (*Kernel) GetRequestBodyMode

func (k *Kernel) GetRequestBodyMode(routeKey string) BodyMode

GetRequestBodyMode returns the body mode for request phase

func (*Kernel) GetResponseBodyMode

func (k *Kernel) GetResponseBodyMode(routeKey string) BodyMode

GetResponseBodyMode returns the body mode for response phase

func (*Kernel) RegisterRoute

func (k *Kernel) RegisterRoute(metadataKey string, chain *registry.PolicyChain)

RegisterRoute registers a policy chain for a route

func (*Kernel) UnregisterRoute

func (k *Kernel) UnregisterRoute(metadataKey string)

UnregisterRoute removes a route mapping

type Mutations

type Mutations struct {
	HeaderMutation *extprocv3.HeaderMutation
	BodyMutation   *extprocv3.BodyMutation
}

Mutations holds header and body mutations for request/response processing

type PolicyDiscoveryService

type PolicyDiscoveryService struct {
}

PolicyDiscoveryService would implement full xDS protocol T071-T074, T076: xDS service (stub for future implementation) For MVP, we use file-based configuration via ConfigLoader above

type PolicyExecutionContext

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

PolicyExecutionContext manages the lifecycle of a single request through the policy chain. This context is created when a request arrives and lives until the response is completed. It encapsulates all state needed for processing both request and response phases.

type RouteMapping

type RouteMapping struct {
	// Metadata key from Envoy (route identifier)
	// Example: "api-v1-private", "public-endpoint"
	MetadataKey string

	// PolicyChain to execute for this route
	// Contains both request and response policies
	Chain *registry.PolicyChain
}

RouteMapping maps Envoy metadata keys to PolicyChains for route-specific processing T049: RouteMapping struct definition

type RouteMetadata

type RouteMetadata struct {
	RouteName      string
	APIId          string
	APIName        string
	APIVersion     string
	Context        string
	OperationPath  string
	Vhost          string
	APIKind        string
	TemplateHandle string
	ProviderName   string
	ProjectID      string
}

RouteMetadata contains metadata about the route

Jump to

Keyboard shortcuts

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