api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api talks to the Bachs HTTP API.

Only the handful of calls the CLI needs. Errors carry the server's own message rather than a bare status code: a bad event name or a key missing webhooks:write is worth reading, and hiding it behind "400" wastes the user's time.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the CLI version, overridden at build time via -ldflags. Set by main before any request is made, so the user agent is computed per call rather than frozen at init.

Functions

This section is empty.

Types

type Client

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

func New

func New(cfg config.Config) *Client

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context, sessionID string) error

CloseSession releases a session so fanout stops aiming at a socket nobody holds. Best-effort at shutdown — the server's reaper covers the case where this never runs, which is why a failure here is not worth surfacing.

func (*Client) CreateSession

func (c *Client) CreateSession(
	ctx context.Context, req CreateSessionRequest,
) (*CreateSessionResponse, error)

func (*Client) Replay

func (c *Client) Replay(
	ctx context.Context, eventID string,
) (*ReplayResponse, error)

type CreateSessionRequest

type CreateSessionRequest struct {
	DeviceName string   `json:"device_name,omitempty"`
	ForwardTo  string   `json:"forward_to,omitempty"`
	Events     []string `json:"events,omitempty"`
}

type CreateSessionResponse

type CreateSessionResponse struct {
	SessionID     string   `json:"session_id"`
	Token         string   `json:"token"`
	SigningSecret string   `json:"signing_secret"`
	WebSocketPath string   `json:"websocket_path"`
	Events        []string `json:"events"`
	// How often to cycle the connection. Server-dictated so deploys can
	// drain sockets without stranding them.
	ReconnectAfterSeconds int `json:"reconnect_after_seconds"`
}

type Error

type Error struct {
	StatusCode int
	Detail     string
	Code       string
}

Error is an API error with the server's own detail preserved.

func (*Error) Error

func (e *Error) Error() string

type ReplayRequest

type ReplayRequest struct {
	EventID string `json:"event_id,omitempty"`
}

type ReplayResponse

type ReplayResponse struct {
	EventID   string `json:"event_id"`
	AttemptID string `json:"attempt_id"`
	AttemptNo int    `json:"attempt_no"`
	EventType string `json:"event_type"`
}

Jump to

Keyboard shortcuts

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