client

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const APIPath = "/api/v0.1"

Variables

View Source
var (
	ErrRequestTimeout   = errors.New("request timed out")
	ErrInvalidParams    = errors.New("invalid params")
	ErrRequestCancelled = errors.New("request cancelled")
)

Functions

func DisableZapScript

func DisableZapScript(cfg *config.Instance) func()

DisableZapScript disables the service running any processed ZapScript from tokens, and returns a function to re-enable it. The returned function must be run even if there is an error so the service isn't left in an unusable state.

func IsServiceRunning added in v2.9.0

func IsServiceRunning(cfg *config.Instance) bool

IsServiceRunning checks if a Zaparoo service is running on the configured port.

func LocalClient

func LocalClient(
	ctx context.Context,
	cfg *config.Instance,
	method string,
	params string,
) (string, error)

LocalClient sends a single unauthenticated method with params to the local running API service, waits for a response until timeout then disconnects.

func WaitForAPI added in v2.9.0

func WaitForAPI(cfg *config.Instance, maxWaitTime, checkInterval time.Duration) bool

WaitForAPI waits for the service API to become available. Returns true if API became available, false if timeout reached.

func WaitNotification

func WaitNotification(
	ctx context.Context,
	timeout time.Duration,
	cfg *config.Instance,
	id string,
) (string, error)

func WaitNotifications added in v2.9.0

func WaitNotifications(
	ctx context.Context,
	timeout time.Duration,
	cfg *config.Instance,
	ids ...string,
) (method, params string, err error)

WaitNotifications waits for any of the specified notification types on a single WebSocket connection. Returns the notification method that matched and its params.

Types

type APIClient added in v2.9.0

type APIClient interface {
	// Call executes a JSON-RPC method and returns the result.
	Call(ctx context.Context, method, params string) (string, error)

	// WaitNotification blocks until a notification of the given type is received.
	WaitNotification(ctx context.Context, timeout time.Duration, notificationType string) (string, error)
}

APIClient abstracts API communication for testability.

type LocalAPIClient added in v2.9.0

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

LocalAPIClient implements APIClient using the real local WebSocket client.

func NewLocalAPIClient added in v2.9.0

func NewLocalAPIClient(cfg *config.Instance) *LocalAPIClient

NewLocalAPIClient creates an APIClient that communicates with the local API.

func (*LocalAPIClient) Call added in v2.9.0

func (c *LocalAPIClient) Call(ctx context.Context, method, params string) (string, error)

Call executes a JSON-RPC method via the local WebSocket client.

func (*LocalAPIClient) WaitNotification added in v2.9.0

func (c *LocalAPIClient) WaitNotification(
	ctx context.Context,
	timeout time.Duration,
	notificationType string,
) (string, error)

WaitNotification waits for a notification via the local WebSocket client.

Jump to

Keyboard shortcuts

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