consumer

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GatewayIDKey    contextKey = "auth.gateway_id"
	ConsumerDataKey contextKey = "auth.consumer_data"
	AuthIDKey       contextKey = "auth.auth_id"
	ConsumerKey     contextKey = "auth.consumer"
)

Variables

This section is empty.

Functions

func AuthIDFromContext

func AuthIDFromContext(ctx context.Context) (ids.AuthID, bool)

func GatewayIDFromContext

func GatewayIDFromContext(ctx context.Context) (ids.GatewayID, bool)

func MCPPath

func MCPPath(slug string) string

func SlugFromMCPPath

func SlugFromMCPPath(path string) string

func WithAuthID

func WithAuthID(ctx context.Context, id ids.AuthID) context.Context

func WithConsumer

func WithConsumer(ctx context.Context, consumer *RoutableConsumer) context.Context

func WithData

func WithData(ctx context.Context, data *Data) context.Context

func WithGatewayID

func WithGatewayID(ctx context.Context, id ids.GatewayID) context.Context

Types

type Associator

type Associator interface {
	AttachRegistry(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, registryID ids.RegistryID, weight *int) error
	DetachRegistry(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, registryID ids.RegistryID) error
	AttachRole(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, roleID ids.RoleID) error
	DetachRole(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, roleID ids.RoleID) error
	AttachAuth(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, authID ids.AuthID) error
	DetachAuth(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, authID ids.AuthID) error
	AttachPolicy(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, policyID ids.PolicyID) error
	DetachPolicy(ctx context.Context, gatewayID ids.GatewayID, consumerID ids.ConsumerID, policyID ids.PolicyID) error
}

func NewAssociator

func NewAssociator(
	repo domain.Repository,
	registryRepo registrydomain.Repository,
	roleRepo roledomain.Repository,
	authRepo authdomain.Repository,
	policyRepo policydomain.Repository,
	manager *cache.TTLMapManager,
	publisher cache.EventPublisher,
	logger *slog.Logger,
) Associator

type CreateInput

type CreateInput struct {
	GatewayID       ids.GatewayID
	Name            string
	Type            domain.Type
	RoutingMode     domain.RoutingMode
	LBConfig        *domain.LBConfig
	Headers         map[string]string
	Active          *bool
	Fallback        *domain.Fallback
	RegistryIDs     []ids.RegistryID
	RegistryWeights map[ids.RegistryID]int
	RoleIDs         []ids.RoleID
	ModelPolicies   domain.ModelPolicies
	MCP             *domain.MCPPolicy
}

type Creator

type Creator interface {
	Create(ctx context.Context, in CreateInput) (*domain.Consumer, error)
}

func NewCreator

func NewCreator(
	repo domain.Repository,
	registryRepo registrydomain.Repository,
	roleRepo roledomain.Repository,
	manager *cache.TTLMapManager,
	publisher cache.EventPublisher,
	logger *slog.Logger,
) Creator

type Data

type Data struct {
	GatewayID ids.GatewayID
	Consumers []RoutableConsumer
	Roles     []*roledomain.Role
	// contains filtered or unexported fields
}

func DataFromContext

func DataFromContext(ctx context.Context) (*Data, bool)

func NewData

func NewData(gatewayID ids.GatewayID, consumers []RoutableConsumer, roles ...[]*roledomain.Role) *Data

func (*Data) EffectiveRegistries

func (d *Data) EffectiveRegistries(rc *RoutableConsumer) []*registrydomain.Registry

func (*Data) MatchPath

func (d *Data) MatchPath(path string) (*RoutableConsumer, bool)

func (*Data) MatchSlug

func (d *Data) MatchSlug(slug string) (*RoutableConsumer, bool)

func (*Data) RegistryByID

func (d *Data) RegistryByID(id ids.RegistryID) (*registrydomain.Registry, bool)

func (*Data) SetRegistryIndex

func (d *Data) SetRegistryIndex(byID map[ids.RegistryID]*registrydomain.Registry)

type DataFinder

type DataFinder interface {
	FindByGateway(ctx context.Context, gatewayID ids.GatewayID) (*Data, error)
}

func NewDataFinder

func NewDataFinder(
	repo domain.Repository,
	registryRepo registrydomain.Repository,
	policyRepo policydomain.Repository,
	authRepo authdomain.Repository,
	roleRepo roledomain.Repository,
	pluginRegistry appplugins.Registry,
	manager *cache.TTLMapManager,
	logger *slog.Logger,
) DataFinder

type Deleter

type Deleter interface {
	Delete(ctx context.Context, gatewayID ids.GatewayID, id ids.ConsumerID) error
}

func NewDeleter

func NewDeleter(
	repo domain.Repository,
	manager *cache.TTLMapManager,
	publisher cache.EventPublisher,
	logger *slog.Logger,
) Deleter

type Finder

type Finder interface {
	FindByID(ctx context.Context, gatewayID ids.GatewayID, id ids.ConsumerID) (*domain.Consumer, error)
	List(ctx context.Context, filter domain.ListFilter) ([]*domain.Consumer, int, error)
}

func NewFinder

func NewFinder(repo domain.Repository, manager *cache.TTLMapManager, logger *slog.Logger) Finder

type PathMatch

type PathMatch struct {
	GatewayID ids.GatewayID
	Consumer  *domain.Consumer
	Auths     []*authdomain.Auth
}

type PathResolver

type PathResolver interface {
	Match(ctx context.Context, host, path string) ([]PathMatch, error)
}

func NewPathResolver

func NewPathResolver(
	consumers domain.Repository,
	auths authdomain.Repository,
	gateways gatewaydomain.Repository,
	manager *cache.TTLMapManager,
	logger *slog.Logger,
) PathResolver

type RoutableConsumer

type RoutableConsumer struct {
	Consumer   *domain.Consumer
	Registries []*registrydomain.Registry

	FallbackBackends []*registrydomain.Registry
	Policies         []*policydomain.Policy
	Auths            []*authdomain.Auth
	PolicyPlan       *appplugins.StagePlan
}

func ConsumerFromContext

func ConsumerFromContext(ctx context.Context) (*RoutableConsumer, bool)

type UpdateInput

type UpdateInput struct {
	ID            ids.ConsumerID
	GatewayID     ids.GatewayID
	Name          *string
	Type          *domain.Type
	RoutingMode   *domain.RoutingMode
	LBConfig      *domain.LBConfig
	Headers       *map[string]string
	Active        *bool
	Fallback      *domain.Fallback
	ModelPolicies *domain.ModelPolicies
	Toolkit       *domain.Toolkit
	FailMode      *domain.FailMode
}

type Updater

type Updater interface {
	Update(ctx context.Context, in UpdateInput) (*domain.Consumer, error)
}

func NewUpdater

func NewUpdater(
	repo domain.Repository,
	authRepo authdomain.Repository,
	manager *cache.TTLMapManager,
	publisher cache.EventPublisher,
	logger *slog.Logger,
) Updater

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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