home

package
v7.2.42 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

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")
)

Functions

func ClearCurrent

func ClearCurrent()

ClearCurrent removes the active home 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 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 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) Close

func (c *Client) Close()

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) 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) 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) LPushUsage

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

func (*Client) Ping

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

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) StartConfigSubscriber

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

StartConfigSubscriber connects to home, fetches config once via GET config, then subscribes to the "config" channel to receive runtime config updates.

The subscription connection is treated as the home heartbeat. HeartbeatOK is set to true only after the initial GET config succeeds and the SUBSCRIBE connection is established. When the subscription ends unexpectedly, HeartbeatOK becomes false and the loop reconnects.

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