httpclient

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package httpclient provides a domain-aware HTTP client for the TaskFlow API. Consumers use the generic functions GetOne, GetMany, Exec, and ExecNoResult with model.Resource and model.Operation types — no manual URL building needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec[T any](c *Client, op model.Operation, params PathParams, body any) (T, error)

Exec executes an operation and returns a typed result.

func ExecNoResult

func ExecNoResult(c *Client, op model.Operation, params PathParams, body any) error

ExecNoResult executes an operation that returns no body (e.g. DELETE → 204).

func GetMany

func GetMany[T any](c *Client, res model.Resource, params PathParams, filter any) ([]T, error)

GetMany executes a resource query and returns a typed slice.

func GetOne

func GetOne[T any](c *Client, res model.Resource, params PathParams, filter any) (T, error)

GetOne executes a resource query and returns a single typed result.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError is returned when the server responds with a 4xx or 5xx status.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client makes authenticated JSON HTTP requests to a TaskFlow server.

func New

func New(baseURL, apiKey string) *Client

New creates a new Client for the given server.

func (*Client) ServerVersion

func (c *Client) ServerVersion() (string, error)

ServerVersion fetches the server's version from the /health endpoint.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, opts SubscribeOptions) *EventStream

Subscribe opens a global SSE event stream with optional filtering. Events are delivered on the returned channels until ctx is cancelled.

func (*Client) Version

func (c *Client) Version() string

Version returns the client's build version.

func (*Client) WhoAmI

func (c *Client) WhoAmI() (model.Actor, error)

WhoAmI returns the authenticated actor for this client's API key.

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

WithContext returns a shallow copy of the client with a different default context.

type ConnectionError

type ConnectionError struct {
	URL string
	Err error
}

ConnectionError is returned when the HTTP request fails at the transport level (server unreachable, DNS failure, timeout, etc.).

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (e *ConnectionError) Unwrap() error

type EventStream

type EventStream struct {
	Events    <-chan eventbus.Event // domain events
	Errors    <-chan StreamError    // connection errors; non-permanent errors are retried automatically
	Connected <-chan struct{}       // sent each time a connection is established
}

EventStream delivers domain events from an SSE connection. The stream reconnects automatically with exponential backoff. Cancel the context passed to Subscribe to stop.

type PathParams

type PathParams = map[string]string

PathParams maps path parameter names to values for URL substitution.

type StreamError

type StreamError struct {
	Err       error
	Permanent bool // if true, the stream will not retry (e.g. 401, 404)
}

StreamError describes an SSE connection error.

type SubscribeOptions

type SubscribeOptions struct {
	Boards   []string // filter to specific board slugs (empty = all boards)
	Assignee string   // filter to events on tasks assigned to this user (supports @me)
}

SubscribeOptions configures the event stream filter.

Jump to

Keyboard shortcuts

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