home

package
v7.2.96 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InFlightFramePart     InFlightFrameKind       = "part"
	InFlightFrameOverflow InFlightFrameKind       = "overflow"
	InFlightAccounted     InFlightAccountedStatus = "accounted"
	InFlightUnaccounted   InFlightAccountedStatus = "unaccounted"
)

Variables

View Source
var (
	ErrDisabled              = errors.New("home client disabled")
	ErrNotConnected          = errors.New("home not connected")
	ErrEmptyResponse         = errors.New("home returned empty response")
	ErrAuthNotFound          = errors.New("home auth not found")
	ErrConfigNotFound        = errors.New("home config not found")
	ErrModelsNotFound        = errors.New("home models not found")
	ErrPluginSyncUnsupported = errors.New("home plugin sync is unsupported")
	ErrDispatchFenced        = errors.New("home auth dispatch is fenced")
)

Functions

func ClearCurrent

func ClearCurrent()

ClearCurrent removes the active home client.

func ClearCurrentIf added in v7.2.96

func ClearCurrentIf(client *Client)

ClearCurrentIf removes the active client only when it is client.

func ConfigFromJWT added in v7.1.12

func ConfigFromJWT(ctx context.Context, rawJWT string) (config.HomeConfig, error)

ConfigFromJWT prepares a Home config from the JWT and ensures local mTLS files exist.

func HashKeyPart added in v7.2.0

func HashKeyPart(value string) string

func IsAmbiguousDispatchError added in v7.2.96

func IsAmbiguousDispatchError(err error) bool

IsAmbiguousDispatchError reports whether Home may have processed the dispatch request.

func KVDelBestEffort added in v7.2.0

func KVDelBestEffort(ctx context.Context, keys ...string) bool

func KVDelRequired added in v7.2.0

func KVDelRequired(ctx context.Context, keys ...string) (bool, int64, error)

func KVExpireBestEffort added in v7.2.0

func KVExpireBestEffort(ctx context.Context, key string, ttl time.Duration) bool

func KVExpireRequired added in v7.2.0

func KVExpireRequired(ctx context.Context, key string, ttl time.Duration) (bool, error)

func KVGetJSONBestEffort added in v7.2.0

func KVGetJSONBestEffort(ctx context.Context, key string, out any) (bool, bool)

func KVGetJSONRequired added in v7.2.0

func KVGetJSONRequired(ctx context.Context, key string, out any) (bool, bool, error)

func KVSetBytesBestEffort added in v7.2.0

func KVSetBytesBestEffort(ctx context.Context, key string, value []byte, ttl time.Duration) bool

func KVSetBytesRequired added in v7.2.0

func KVSetBytesRequired(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error)

func KVSetJSONBestEffort added in v7.2.0

func KVSetJSONBestEffort(ctx context.Context, key string, value any, ttl time.Duration) bool

func KVSetJSONRequired added in v7.2.0

func KVSetJSONRequired(ctx context.Context, key string, value any, ttl time.Duration) (bool, error)

func KVSetNXBestEffort added in v7.2.0

func KVSetNXBestEffort(ctx context.Context, key string, value []byte, ttl time.Duration) bool

func KVSetNXRequired added in v7.2.0

func KVSetNXRequired(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, bool, error)

func NewAmbiguousDispatchError added in v7.2.96

func NewAmbiguousDispatchError(err error) error

NewAmbiguousDispatchError marks a post-send transport failure as requiring a client abort.

func NewReleaseFlusher added in v7.2.96

func NewReleaseFlusher(configProvider func() internalconfig.CredentialConcurrencyConfig, send func(context.Context, ConcurrencyReleaseFrame) error) *releaseFlusher

NewReleaseFlusher creates a flusher that reads timing updates from the current limiter configuration.

func ReportPluginStatus added in v7.2.33

func ReportPluginStatus(ctx context.Context, client PluginStatusClient, nodeID string, report homeplugins.SyncReport) error

ReportPluginStatus marshals the given report, sets NodeID and UpdatedAt, and pushes it to the provided client with a timeout.

func SetCurrent

func SetCurrent(client *Client)

SetCurrent sets the active home client used by runtime integrations.

Types

type Client

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

func Current

func Current() *Client

Current returns the active home client instance, if any.

func CurrentKVClient added in v7.2.0

func CurrentKVClient() (*Client, bool, error)

func New

func New(homeCfg config.HomeConfig) *Client

func (*Client) AbortAmbiguousDispatch added in v7.2.96

func (c *Client) AbortAmbiguousDispatch()

AbortAmbiguousDispatch fences this client after an auth dispatch response is ambiguous.

func (*Client) Close

func (c *Client) Close()

Close permanently ends this client's dispatch lifetime.

func (*Client) Enabled

func (c *Client) Enabled() bool

func (*Client) GetConfig

func (c *Client) GetConfig(ctx context.Context) ([]byte, error)

func (*Client) GetModels

func (c *Client) GetModels(ctx context.Context, headers http.Header, query url.Values) ([]byte, error)

func (*Client) GetPluginSync added in v7.2.82

func (*Client) GetPluginTasks added in v7.2.32

func (c *Client) GetPluginTasks(ctx context.Context) ([]PluginTask, error)

func (*Client) GetRefreshAuth

func (c *Client) GetRefreshAuth(ctx context.Context, authIndex string) ([]byte, error)

func (*Client) HeartbeatOK

func (c *Client) HeartbeatOK() bool

func (*Client) KVCompareAndSwap added in v7.2.85

func (c *Client) KVCompareAndSwap(ctx context.Context, key string, expected []byte, expectedExists bool, value []byte, ttl time.Duration) (bool, error)

KVCompareAndSwap atomically replaces a value only when its current state matches the expected state.

func (*Client) KVDel added in v7.2.0

func (c *Client) KVDel(ctx context.Context, keys ...string) (int64, error)

func (*Client) KVExpire added in v7.2.0

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

func (*Client) KVGet added in v7.2.0

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

func (*Client) KVIncrBy added in v7.2.0

func (c *Client) KVIncrBy(ctx context.Context, key string, delta int64) (int64, error)

func (*Client) KVMGet added in v7.2.0

func (c *Client) KVMGet(ctx context.Context, keys ...string) ([][]byte, []bool, error)

func (*Client) KVMSet added in v7.2.0

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

func (*Client) KVSet added in v7.2.0

func (c *Client) KVSet(ctx context.Context, key string, value []byte, opts KVSetOptions) (bool, error)

func (*Client) KVSetNX added in v7.2.0

func (c *Client) KVSetNX(ctx context.Context, key string, value []byte, ttl time.Duration) (bool, error)

func (*Client) KVTTL added in v7.2.0

func (c *Client) KVTTL(ctx context.Context, key string) (time.Duration, bool, error)

func (*Client) LPushInFlightSnapshot added in v7.2.96

func (c *Client) LPushInFlightSnapshot(ctx context.Context, payload []byte) error

LPushInFlightSnapshot publishes a bounded in-flight observation frame.

func (*Client) LPushUsage

func (c *Client) LPushUsage(ctx context.Context, payload []byte) error

func (*Client) LimiterConfig added in v7.2.96

func (c *Client) LimiterConfig() config.CredentialConcurrencyConfig

LimiterConfig returns the latest immutable, validated Home limiter configuration.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) PushConcurrencyRelease added in v7.2.96

func (c *Client) PushConcurrencyRelease(ctx context.Context, frame ConcurrencyReleaseFrame) error

PushConcurrencyRelease sends one cumulative concurrency release frame through an independent client.

func (*Client) RPopAuth

func (c *Client) RPopAuth(ctx context.Context, requestedModel string, sessionID string, headers http.Header, count int) ([]byte, error)

func (*Client) RPushAppLog added in v7.1.29

func (c *Client) RPushAppLog(ctx context.Context, payload []byte) error

func (*Client) RPushPluginStatus added in v7.2.32

func (c *Client) RPushPluginStatus(ctx context.Context, payload []byte) error

func (*Client) RPushRequestLog

func (c *Client) RPushRequestLog(ctx context.Context, payload []byte) error

func (*Client) RunConfigSubscriberLifetime added in v7.2.96

func (c *Client) RunConfigSubscriberLifetime(ctx context.Context, onConfig func([]byte) error, onReady func()) error

RunConfigSubscriberLifetime runs one GET, SUBSCRIBE, and receive lifetime. Reconnection is owned by the service so each replacement can install a new client lifetime.

func (*Client) SetLifecycleConfig added in v7.2.96

func (c *Client) SetLifecycleConfig(cfg config.CredentialConcurrencyConfig) error

func (*Client) SetManagedLifetime added in v7.2.96

func (c *Client) SetManagedLifetime(managed bool)

SetManagedLifetime defers client shutdown to the Service lifetime owner.

func (*Client) StartConfigSubscriber

func (c *Client) StartConfigSubscriber(ctx context.Context, onConfig func([]byte) error)

StartConfigSubscriber is retained for callers that do not need the lifetime error.

type ConcurrencyReleaseFrame added in v7.2.96

type ConcurrencyReleaseFrame struct {
	CredentialID string `json:"credential_id"`
	Model        string `json:"model"`
	ReleaseSeq   int64  `json:"release_seq"`
}

ConcurrencyReleaseFrame is the cumulative release accepted by Home for one credential and model.

type DispatchError added in v7.2.96

type DispatchError struct {
	Err       error
	Ambiguous bool
}

DispatchError classifies whether Home may have processed an auth dispatch request.

func (*DispatchError) Error added in v7.2.96

func (e *DispatchError) Error() string

func (*DispatchError) Unwrap added in v7.2.96

func (e *DispatchError) Unwrap() error

type InFlightAccountedStatus added in v7.2.96

type InFlightAccountedStatus string

type InFlightAggregate added in v7.2.96

type InFlightAggregate struct {
	CredentialID string                  `json:"credential_id"`
	Model        string                  `json:"model"`
	Status       InFlightAccountedStatus `json:"status"`
	Count        int64                   `json:"count"`
}

type InFlightFrameKind added in v7.2.96

type InFlightFrameKind string

type InFlightRequestDetail added in v7.2.96

type InFlightRequestDetail struct {
	RequestID    string    `json:"request_id"`
	CredentialID string    `json:"credential_id"`
	Model        string    `json:"model"`
	RequestKind  string    `json:"request_kind"`
	StartedAt    time.Time `json:"started_at"`
}

type InFlightSnapshotFrame added in v7.2.96

type InFlightSnapshotFrame struct {
	Kind                InFlightFrameKind       `json:"kind"`
	Revision            int64                   `json:"revision"`
	ObservedAt          time.Time               `json:"observed_at"`
	BarrierRevision     int64                   `json:"barrier_revision"`
	PartIndex           *int                    `json:"part_index,omitempty"`
	PartCount           *int                    `json:"part_count,omitempty"`
	DetailsTruncated    bool                    `json:"details_truncated,omitempty"`
	Aggregates          []InFlightAggregate     `json:"aggregates,omitempty"`
	Details             []InFlightRequestDetail `json:"details,omitempty"`
	AggregateGroupCount int                     `json:"aggregate_group_count,omitempty"`
}

type KVSetOptions added in v7.2.0

type KVSetOptions struct {
	EX time.Duration
	PX time.Duration
	NX bool
	XX bool
}

type PluginStatusClient added in v7.2.33

type PluginStatusClient interface {
	RPushPluginStatus(ctx context.Context, payload []byte) error
}

PluginStatusClient defines the interface for pushing plugin status reports.

type PluginTask added in v7.2.32

type PluginTask struct {
	ID             uint      `json:"id"`
	Operation      string    `json:"operation"`
	PluginID       string    `json:"plugin_id"`
	TargetNodeType string    `json:"target_node_type,omitempty"`
	TargetNodeID   string    `json:"target_node_id,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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