Documentation
¶
Index ¶
- Constants
- Variables
- func DisableZapScript(cfg *config.Instance) func()
- func IsServiceRunning(cfg *config.Instance) bool
- func LocalClient(ctx context.Context, cfg *config.Instance, method string, params string) (string, error)
- func WaitForAPI(cfg *config.Instance, maxWaitTime, checkInterval time.Duration) bool
- func WaitNotification(ctx context.Context, timeout time.Duration, cfg *config.Instance, id string) (string, error)
- func WaitNotifications(ctx context.Context, timeout time.Duration, cfg *config.Instance, ...) (method, params string, err error)
- type APIClient
- type LocalAPIClient
Constants ¶
const APIPath = "/api/v0.1"
Variables ¶
Functions ¶
func DisableZapScript ¶
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
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
WaitForAPI waits for the service API to become available. Returns true if API became available, false if timeout reached.
func WaitNotification ¶
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
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.