Documentation
¶
Index ¶
- func BuildRefreshPayload(updated *coreauth.Auth) ([]byte, error)
- func SanitizeAuthForDownstream(auth *coreauth.Auth) *coreauth.Auth
- type ClusterAdapter
- type ConcurrencyAdmissionRequest
- type ConcurrencyAdmissionResult
- type ConcurrencyAdmitter
- type ConcurrencyAdmitterFunc
- type DispatchConcurrencyContext
- type DispatchResponsePreparer
- type DispatchResult
- type KVGetResult
- type ModelInfo
- type PluginPlatform
- type Runtime
- func (r *Runtime) AddToken(ctx context.Context, rawJSON string) (string, error)
- func (r *Runtime) ApplyConfigFromCluster(ctx context.Context, cfg *config.Config) error
- func (r *Runtime) Authenticate(ctx context.Context, headers http.Header) (*access.Result, *access.AuthError)
- func (r *Runtime) AuthenticateHTTPRequest(ctx context.Context, req *http.Request) (*access.Result, *access.AuthError)
- func (r *Runtime) BuildPluginSyncPlan(ctx context.Context, request pluginstore.PluginSyncRequest) (pluginstore.PluginSyncResponse, error)
- func (r *Runtime) Config() *config.Config
- func (r *Runtime) ConfigPath() string
- func (r *Runtime) CoreManager() *coreauth.Manager
- func (r *Runtime) DispatchForAPIKey(ctx context.Context, reqModel string, headers http.Header, apiKey string) (*DispatchResult, error)
- func (r *Runtime) DispatchForAPIKeyWithConcurrency(ctx context.Context, reqModel string, headers http.Header, apiKey string, ...) (*DispatchResult, error)
- func (r *Runtime) HasPluginAuthProvider(provider string) bool
- func (r *Runtime) HasScheduler() bool
- func (r *Runtime) KVDel(ctx context.Context, keys []string) (int64, error)
- func (r *Runtime) KVExpire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (r *Runtime) KVGet(ctx context.Context, key string) ([]byte, bool, error)
- func (r *Runtime) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)
- func (r *Runtime) KVMGet(ctx context.Context, keys []string) ([]KVGetResult, error)
- func (r *Runtime) KVMSet(ctx context.Context, pairs map[string][]byte) error
- func (r *Runtime) KVSet(ctx context.Context, key string, value []byte, ttl time.Duration, mode string) (bool, error)
- func (r *Runtime) KVTTL(ctx context.Context, key string) (int64, error)
- func (r *Runtime) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
- func (r *Runtime) ParseAuth(ctx context.Context, req pluginapi.AuthParseRequest) (*homeauth.Auth, bool, error)
- func (r *Runtime) ParseAuths(ctx context.Context, req pluginapi.AuthParseRequest) ([]*homeauth.Auth, bool, error)
- func (r *Runtime) PersistAppLogPayload(ctx context.Context, clientIP string, payload string) (bool, error)
- func (r *Runtime) PersistClusterUsagePayload(ctx context.Context, payload string) (bool, error)
- func (r *Runtime) PickAuth(ctx context.Context, req pluginapi.SchedulerPickRequest) (pluginapi.SchedulerPickResponse, bool, error)
- func (r *Runtime) PluginLoginAuths(resp pluginapi.AuthLoginPollResponse) ([]*homeauth.Auth, error)
- func (r *Runtime) PluginSyncNodeActive(ctx context.Context, nodeID string, fingerprint string) (bool, error)
- func (r *Runtime) PollPluginLogin(ctx context.Context, provider, state string, metadata map[string]any) (pluginapi.AuthLoginPollResponse, bool, error)
- func (r *Runtime) PublishConfigYAML(payload []byte)
- func (r *Runtime) ReadConfigYAMLContext(ctx context.Context) ([]byte, error)
- func (r *Runtime) RecordUsagePayload(ctx context.Context, payload string)
- func (r *Runtime) RefreshAuth(ctx context.Context, auth *homeauth.Auth) (*homeauth.Auth, bool, error)
- func (r *Runtime) RefreshClusterAuthIndex(ctx context.Context, uuid string) error
- func (r *Runtime) RefreshNow(ctx context.Context, authIndex string) ([]byte, error)
- func (r *Runtime) RefreshNowLocal(ctx context.Context, authIndex string) ([]byte, error)
- func (r *Runtime) RegisteredPlugins() []sdkpluginhost.RegisteredPluginInfo
- func (r *Runtime) ReloadAuths(ctx context.Context) error
- func (r *Runtime) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
- func (r *Runtime) SetClusterAdapter(adapter ClusterAdapter)
- func (r *Runtime) SetClusterRefreshHandler(handler func(context.Context, string) ([]byte, error))
- func (r *Runtime) SetConcurrencyAdmitter(admitter ConcurrencyAdmitter)
- func (r *Runtime) SetPluginStoreAuthResolver(resolver func(context.Context) ([]pluginstore.ResolvedAuthConfig, error))
- func (r *Runtime) SetPluginSyncConfigLoader(loader func(context.Context) (*config.Config, error))
- func (r *Runtime) SetPluginSyncNodeActive(check func(context.Context, string, string) (bool, error))
- func (r *Runtime) Start(ctx context.Context, configPath string) error
- func (r *Runtime) StartAutoRefresh(ctx context.Context)
- func (r *Runtime) StartPluginLogin(ctx context.Context, provider, baseURL string) (pluginapi.AuthLoginStartResponse, bool, error)
- func (r *Runtime) Stop()
- func (r *Runtime) StopAutoRefresh()
- func (r *Runtime) SubscribeConfigYAML(subscriber func(payload []byte) error) (unsubscribe func())
- func (r *Runtime) UpdateAuthInMemory(ctx context.Context, auth *coreauth.Auth) (*coreauth.Auth, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRefreshPayload ¶
BuildRefreshPayload builds a build refresh payload.
Types ¶
type ClusterAdapter ¶
type ConcurrencyAdmissionRequest ¶ added in v1.0.63
type ConcurrencyAdmissionRequest struct {
CredentialID string
Model string
Fingerprint string
ConnectedAt time.Time
Controlled bool
ProtocolVersion int
}
ConcurrencyAdmissionRequest identifies a dispatch request for atomic admission.
type ConcurrencyAdmissionResult ¶ added in v1.0.63
ConcurrencyAdmissionResult describes the credential and model admitted by the limiter.
type ConcurrencyAdmitter ¶ added in v1.0.63
type ConcurrencyAdmitter interface {
AdmitCredentialConcurrency(context.Context, ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
}
ConcurrencyAdmitter atomically reserves a credential concurrency slot.
type ConcurrencyAdmitterFunc ¶ added in v1.0.63
type ConcurrencyAdmitterFunc func(context.Context, ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
ConcurrencyAdmitterFunc adapts a function to ConcurrencyAdmitter.
func (ConcurrencyAdmitterFunc) AdmitCredentialConcurrency ¶ added in v1.0.63
func (f ConcurrencyAdmitterFunc) AdmitCredentialConcurrency(ctx context.Context, req ConcurrencyAdmissionRequest) (ConcurrencyAdmissionResult, error)
type DispatchConcurrencyContext ¶ added in v1.0.63
type DispatchConcurrencyContext struct {
Fingerprint string
ConnectedAt time.Time
Controlled bool
ProtocolVersion int
PrepareResponse DispatchResponsePreparer
}
DispatchConcurrencyContext carries the RESP connection identity required for admission.
type DispatchResponsePreparer ¶ added in v1.0.63
type DispatchResponsePreparer func(*DispatchResult) (unaccounted []byte, accounted []byte, err error)
DispatchResponsePreparer prebuilds both dispatch response variants before admission.
type DispatchResult ¶
type KVGetResult ¶ added in v1.0.44
type PluginPlatform ¶ added in v1.0.44
func CurrentPluginPlatform ¶ added in v1.0.44
func CurrentPluginPlatform() PluginPlatform
CurrentPluginPlatform reports the platform used by Home plugin discovery.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
NewRuntime creates a new runtime.
func (*Runtime) AddToken ¶
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 ¶
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.44
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) BuildPluginSyncPlan ¶ added in v1.0.63
func (r *Runtime) BuildPluginSyncPlan(ctx context.Context, request pluginstore.PluginSyncRequest) (pluginstore.PluginSyncResponse, error)
func (*Runtime) ConfigPath ¶
ConfigPath handles a config path.
func (*Runtime) CoreManager ¶
CoreManager handles a core manager.
func (*Runtime) DispatchForAPIKey ¶ added in v1.0.44
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) DispatchForAPIKeyWithConcurrency ¶ added in v1.0.63
func (r *Runtime) DispatchForAPIKeyWithConcurrency(ctx context.Context, reqModel string, headers http.Header, apiKey string, concurrencyCtx DispatchConcurrencyContext) (*DispatchResult, error)
DispatchForAPIKeyWithConcurrency performs dispatch and atomic admission for a RESP request.
func (*Runtime) HasPluginAuthProvider ¶ added in v1.0.63
HasPluginAuthProvider reports whether a Home-loaded plugin owns provider login.
func (*Runtime) HasScheduler ¶ added in v1.0.44
HasScheduler reports whether a Home-loaded plugin supplies auth scheduling.
func (*Runtime) KVMGet ¶ added in v1.0.44
KVMGet returns KV values in request order from the cluster store.
func (*Runtime) KVSet ¶ added in v1.0.44
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.44
KVTTL returns a Redis-compatible KV TTL from the cluster store.
func (*Runtime) ListPendingPluginTasks ¶ added in v1.0.44
func (r *Runtime) ListPendingPluginTasks(ctx context.Context, nodeType string, nodeID string) ([]node.PluginTask, error)
ListPendingPluginTasks returns pending plugin tasks for a node.
func (*Runtime) ParseAuth ¶ added in v1.0.44
func (r *Runtime) ParseAuth(ctx context.Context, req pluginapi.AuthParseRequest) (*homeauth.Auth, bool, error)
ParseAuth lets Home auth synthesis use provider plugins.
func (*Runtime) ParseAuths ¶ added in v1.0.44
func (r *Runtime) ParseAuths(ctx context.Context, req pluginapi.AuthParseRequest) ([]*homeauth.Auth, bool, error)
ParseAuths lets Home auth synthesis use provider plugins that expand one file into multiple auths.
func (*Runtime) PersistAppLogPayload ¶ added in v1.0.44
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 ¶
PersistClusterUsagePayload stores persist cluster usage payload.
func (*Runtime) PickAuth ¶ added in v1.0.44
func (r *Runtime) PickAuth(ctx context.Context, req pluginapi.SchedulerPickRequest) (pluginapi.SchedulerPickResponse, bool, error)
PickAuth lets Home dispatch use scheduler plugins.
func (*Runtime) PluginLoginAuths ¶ added in v1.0.63
PluginLoginAuths converts auth records returned by a successful plugin login.
func (*Runtime) PluginSyncNodeActive ¶ added in v1.0.63
func (*Runtime) PollPluginLogin ¶ added in v1.0.63
func (r *Runtime) PollPluginLogin(ctx context.Context, provider, state string, metadata map[string]any) (pluginapi.AuthLoginPollResponse, bool, error)
PollPluginLogin polls an OAuth flow through a Home-loaded auth provider plugin.
func (*Runtime) PublishConfigYAML ¶
PublishConfigYAML handles a publish config yaml.
func (*Runtime) ReadConfigYAMLContext ¶
ReadConfigYAMLContext loads read config yaml context.
func (*Runtime) RecordUsagePayload ¶
RecordUsagePayload applies downstream usage status to the scheduler auth state.
func (*Runtime) RefreshAuth ¶ added in v1.0.44
func (r *Runtime) RefreshAuth(ctx context.Context, auth *homeauth.Auth) (*homeauth.Auth, bool, error)
RefreshAuth lets Home refresh provider plugin credentials.
func (*Runtime) RefreshClusterAuthIndex ¶
RefreshClusterAuthIndex refreshes refresh cluster auth index.
func (*Runtime) RefreshNow ¶
RefreshNow refreshes refresh now.
func (*Runtime) RefreshNowLocal ¶
RefreshNowLocal refreshes refresh now local.
func (*Runtime) RegisteredPlugins ¶ added in v1.0.63
func (r *Runtime) RegisteredPlugins() []sdkpluginhost.RegisteredPluginInfo
RegisteredPlugins returns Home-loaded plugin metadata for management clients.
func (*Runtime) ReloadAuths ¶
ReloadAuths handles a reload auths.
func (*Runtime) ReplacePluginStatus ¶ added in v1.0.44
func (r *Runtime) ReplacePluginStatus(ctx context.Context, nodeType string, status node.PluginTaskStatus) error
ReplacePluginStatus stores the latest plugin status report in the cluster store.
func (*Runtime) SetClusterAdapter ¶
func (r *Runtime) SetClusterAdapter(adapter ClusterAdapter)
SetClusterAdapter sets a cluster adapter.
func (*Runtime) SetClusterRefreshHandler ¶
SetClusterRefreshHandler sets a cluster refresh handler.
func (*Runtime) SetConcurrencyAdmitter ¶ added in v1.0.63
func (r *Runtime) SetConcurrencyAdmitter(admitter ConcurrencyAdmitter)
SetConcurrencyAdmitter sets the admission backend used for concurrency-aware dispatch.
func (*Runtime) SetPluginStoreAuthResolver ¶ added in v1.0.63
func (r *Runtime) SetPluginStoreAuthResolver(resolver func(context.Context) ([]pluginstore.ResolvedAuthConfig, error))
func (*Runtime) SetPluginSyncConfigLoader ¶ added in v1.0.63
func (*Runtime) SetPluginSyncNodeActive ¶ added in v1.0.63
func (*Runtime) StartAutoRefresh ¶
StartAutoRefresh starts an auto refresh.
func (*Runtime) StartPluginLogin ¶ added in v1.0.63
func (r *Runtime) StartPluginLogin(ctx context.Context, provider, baseURL string) (pluginapi.AuthLoginStartResponse, bool, error)
StartPluginLogin starts an OAuth flow through a Home-loaded auth provider plugin.
func (*Runtime) StopAutoRefresh ¶
func (r *Runtime) StopAutoRefresh()
StopAutoRefresh stops an auto refresh.
func (*Runtime) SubscribeConfigYAML ¶
SubscribeConfigYAML handles a subscribe config yaml.