connectedws

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 13 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 connectedws supplies the bounded, tracked transport for external service connections. Protocol authentication and command semantics stay in each plugin

Index

Constants

View Source
const MaxFrame = 4 << 20
View Source
const MaxRequest = 64 << 10

Variables

View Source
var ErrClosed = errors.New("WebSocket connection closed; reconnect to refresh state")

Functions

func CommandError

func CommandError(err error) error

Distinguish confirmed rejection from an uncertain command outcome

Types

type Client

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

Client owns at most one authenticated session, including an in-progress dial Close is reusable: settings changes and the last unbind cancel outstanding work, while a later binding can establish a fresh session. No request is replayed

func (*Client) Close

func (c *Client) Close()

Close the client-owned service session

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, key, endpoint string, handshake Handshake, route Route, closed func()) (*Session, bool, error)

Reuse a matching session or establish an authenticated connection

type Handshake

type Handshake func(context.Context, *websocket.Conn) error

Handshake must use ctx for all authentication reads and writes

type Rejected

type Rejected struct{ Operation string }

Rejected distinguishes an authoritative server rejection from an uncertain delivery (disconnect/timeout). Callers must never retry either kind of write

func (*Rejected) Error

func (e *Rejected) Error() string

Describe an explicitly rejected service command

type Route

type Route func(json.RawMessage) (string, error)

Route validates a protocol envelope, returns a response ID for correlated replies, and handles unsolicited events synchronously. It must not block on a request

type Session

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

func (*Session) Alive

func (s *Session) Alive() bool

Report whether the service session remains open

func (*Session) Close

func (s *Session) Close()

Close the session and release pending requests

func (*Session) Request

func (s *Session) Request(ctx context.Context, id string, value any) (json.RawMessage, error)

Send a correlated service request with independent cancellation

Jump to

Keyboard shortcuts

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