client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MPL-2.0 Imports: 12 Imported by: 1 module, 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 client calls a live worker: the supervisor a stream origin talks to, or (inside the supervisor) one of its worker processes, which answer the same API over a Unix socket.

Index

Constants

View Source
const MaxBody = 256 << 20

MaxBody bounds a response body read into memory (a 20-s segment of a high-bitrate rung, with room to spare).

Variables

This section is empty.

Functions

func ClassOf

func ClassOf(err error) string

ClassOf is err's class: an *Error's, "" for anything else (a transport error: the worker could not be reached or went away).

Types

type Client

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

Client is one live worker's API.

func New

func New(base, token string, hc *http.Client) *Client

New is a client of the worker at base (http://host:port), sending token as a bearer token when it is not empty. hc nil: a client with keep-alive connections and no overall timeout (each call's context bounds it).

func NewUnix

func NewUnix(path string) *Client

NewUnix is a client of a worker process listening on the Unix socket path.

func (*Client) CloseIdle

func (c *Client) CloseIdle()

CloseIdle closes the client's idle connections.

func (*Client) Do

func (c *Client) Do(ctx context.Context, path string, body []byte) (*Reply, error)

Do posts body (JSON) to path and reads the answer, whatever its status. An error is a transport error.

func (*Client) GetJSON

func (c *Client) GetJSON(ctx context.Context, path string, v any) (int, error)

GetJSON gets a JSON endpoint (/healthz, /v1/status, /v1/jobs) into v and returns the status.

func (*Client) Init

func (c *Client) Init(ctx context.Context, req api.Request) (*Output, error)

Init makes a rung's initialization segment (POST /v1/init).

func (*Client) Segment

func (c *Client) Segment(ctx context.Context, req api.Request) (*Output, error)

Segment makes one segment (POST /v1/segment).

func (*Client) Subtitle

func (c *Client) Subtitle(ctx context.Context, req api.SubtitleRequest) ([]byte, error)

Subtitle reads a text subtitle stream as WebVTT (POST /v1/subtitle).

type Error

type Error struct {
	Status     int
	Body       api.ErrorBody
	RetryAfter time.Duration
}

Error is a failure the worker answered.

func (*Error) Class

func (e *Error) Class() string

Class is the failure's class (api.Class*).

func (*Error) Error

func (e *Error) Error() string

type Output

type Output struct {
	Init     []byte
	Fragment []byte
	Result   api.Result
	Codec    string
	Slot     string
	Attempts int
}

Output is a segment or an init: the rung's init, the fragment (nil for an init) and what the worker said about them.

type Reply

type Reply struct {
	Status int
	Header http.Header
	Body   []byte
}

Reply is a raw answer.

func (*Reply) AsError

func (r *Reply) AsError() error

AsError is the reply's failure, nil for a 200.

Jump to

Keyboard shortcuts

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