home

package
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRefreshPayload added in v1.0.2

func BuildRefreshPayload(updated *coreauth.Auth) ([]byte, error)

BuildRefreshPayload builds a build refresh payload.

func SanitizeAuthForDownstream

func SanitizeAuthForDownstream(auth *coreauth.Auth) *coreauth.Auth

SanitizeAuthForDownstream removes refresh-capable credentials from the auth payload before it is returned to downstream CPA nodes.

Types

type ClusterAdapter added in v1.0.2

type ClusterAdapter interface {
	Enabled() bool
	LoadAuthIndex(ctx context.Context) error
	ListMinimalAuths() []*coreauth.Auth
	GetFullAuth(ctx context.Context, uuid string) (*coreauth.Auth, error)
	LoadConfigYAML(ctx context.Context) ([]byte, error)
}

type DispatchResult

type DispatchResult struct {
	Model       string
	AccessToken string
	BaseURL     string
	APIKey      string

	AuthID   string
	Provider string

	Auth *coreauth.Auth
}

type KVGetResult added in v1.0.34

type KVGetResult struct {
	Value []byte
	Found bool
}

type ModelInfo

type ModelInfo = registry.ModelInfo

type Runtime

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

func NewRuntime

func NewRuntime(cfg *config.Config) (*Runtime, error)

NewRuntime creates a new runtime.

func (*Runtime) AddToken

func (r *Runtime) AddToken(ctx context.Context, rawJSON string) (string, error)

AddToken stores a credential JSON blob into the auth directory and schedules it for use. It returns the created (or existing) auth file name under auth-dir.

func (*Runtime) ApplyConfigFromCluster added in v1.0.2

func (r *Runtime) ApplyConfigFromCluster(ctx context.Context, cfg *config.Config) error

ApplyConfigFromCluster updates apply config from cluster.

func (*Runtime) Authenticate

func (r *Runtime) Authenticate(ctx context.Context, headers http.Header) (*access.Result, *access.AuthError)

Authenticate validates request credentials and returns the access result.

func (*Runtime) AuthenticateHTTPRequest added in v1.0.34

func (r *Runtime) AuthenticateHTTPRequest(ctx context.Context, req *http.Request) (*access.Result, *access.AuthError)

AuthenticateHTTPRequest validates request credentials from a complete HTTP request.

func (*Runtime) Config

func (r *Runtime) Config() *config.Config

Config handles a config.

func (*Runtime) ConfigPath

func (r *Runtime) ConfigPath() string

ConfigPath handles a config path.

func (*Runtime) CoreManager

func (r *Runtime) CoreManager() *coreauth.Manager

CoreManager handles a core manager.

func (*Runtime) DispatchForAPIKey added in v1.0.20

func (r *Runtime) DispatchForAPIKey(ctx context.Context, reqModel string, headers http.Header, apiKey string) (*DispatchResult, error)

DispatchForAPIKey processes dispatch with API-key channel restrictions.

func (*Runtime) KVDel added in v1.0.34

func (r *Runtime) KVDel(ctx context.Context, keys []string) (int64, error)

KVDel deletes active KV values from the cluster store.

func (*Runtime) KVExpire added in v1.0.34

func (r *Runtime) KVExpire(ctx context.Context, key string, ttl time.Duration) (bool, error)

KVExpire updates a KV value TTL in the cluster store.

func (*Runtime) KVGet added in v1.0.34

func (r *Runtime) KVGet(ctx context.Context, key string) ([]byte, bool, error)

KVGet returns an active KV value from the cluster store.

func (*Runtime) KVIncrBy added in v1.0.34

func (r *Runtime) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)

KVIncrBy increments a KV integer in the cluster store.

func (*Runtime) KVMGet added in v1.0.34

func (r *Runtime) KVMGet(ctx context.Context, keys []string) ([]KVGetResult, error)

KVMGet returns KV values in request order from the cluster store.

func (*Runtime) KVMSet added in v1.0.34

func (r *Runtime) KVMSet(ctx context.Context, pairs map[string][]byte) error

KVMSet atomically writes KV values to the cluster store.

func (*Runtime) KVSet added in v1.0.34

func (r *Runtime) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode string) (bool, error)

KVSet writes a KV value to the cluster store.

func (*Runtime) KVTTL added in v1.0.34

func (r *Runtime) KVTTL(ctx context.Context, key string) (int64, error)

KVTTL returns a Redis-compatible KV TTL from the cluster store.

func (*Runtime) PersistAppLogPayload added in v1.0.25

func (r *Runtime) PersistAppLogPayload(ctx context.Context, clientIP string, payload string) (bool, error)

PersistAppLogPayload stores a CPA app log payload in the runtime database.

func (*Runtime) PersistClusterUsagePayload added in v1.0.2

func (r *Runtime) PersistClusterUsagePayload(ctx context.Context, payload string) (bool, error)

PersistClusterUsagePayload stores persist cluster usage payload.

func (*Runtime) PublishConfigYAML

func (r *Runtime) PublishConfigYAML(payload []byte)

PublishConfigYAML handles a publish config yaml.

func (*Runtime) ReadConfigYAMLContext added in v1.0.2

func (r *Runtime) ReadConfigYAMLContext(ctx context.Context) ([]byte, error)

ReadConfigYAMLContext loads read config yaml context.

func (*Runtime) RecordUsagePayload

func (r *Runtime) RecordUsagePayload(ctx context.Context, payload string)

RecordUsagePayload applies downstream usage status to the scheduler auth state.

func (*Runtime) RefreshClusterAuthIndex added in v1.0.2

func (r *Runtime) RefreshClusterAuthIndex(ctx context.Context, uuid string) error

RefreshClusterAuthIndex refreshes refresh cluster auth index.

func (*Runtime) RefreshNow added in v1.0.2

func (r *Runtime) RefreshNow(ctx context.Context, authIndex string) ([]byte, error)

RefreshNow refreshes refresh now.

func (*Runtime) RefreshNowLocal added in v1.0.2

func (r *Runtime) RefreshNowLocal(ctx context.Context, authIndex string) ([]byte, error)

RefreshNowLocal refreshes refresh now local.

func (*Runtime) ReloadAuths added in v1.0.2

func (r *Runtime) ReloadAuths(ctx context.Context) error

ReloadAuths handles a reload auths.

func (*Runtime) SetClusterAdapter added in v1.0.2

func (r *Runtime) SetClusterAdapter(adapter ClusterAdapter)

SetClusterAdapter sets a cluster adapter.

func (*Runtime) SetClusterRefreshHandler added in v1.0.2

func (r *Runtime) SetClusterRefreshHandler(handler func(context.Context, string) ([]byte, error))

SetClusterRefreshHandler sets a cluster refresh handler.

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context, configPath string) error

Start starts the process.

func (*Runtime) StartAutoRefresh added in v1.0.2

func (r *Runtime) StartAutoRefresh(ctx context.Context)

StartAutoRefresh starts an auto refresh.

func (*Runtime) Stop

func (r *Runtime) Stop()

Stop stops the process.

func (*Runtime) StopAutoRefresh added in v1.0.2

func (r *Runtime) StopAutoRefresh()

StopAutoRefresh stops an auto refresh.

func (*Runtime) SubscribeConfigYAML

func (r *Runtime) SubscribeConfigYAML(subscriber func(payload []byte) error) (unsubscribe func())

SubscribeConfigYAML handles a subscribe config yaml.

func (*Runtime) UpdateAuthInMemory added in v1.0.2

func (r *Runtime) UpdateAuthInMemory(ctx context.Context, auth *coreauth.Auth) (*coreauth.Auth, error)

UpdateAuthInMemory updates an auth in memory.

Jump to

Keyboard shortcuts

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