transport

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package transport deals with packet-like connections between endpoints. It includes helpers to create them from sockets or as derived concepts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport interface {
	// Read reads the next message available into the given target, e.g., by decoding.
	Read(any) error

	// Send sends the given message.
	// This may block, or not, and may always return nil (e.g., message put into queue rather than sent directly).
	Send(any) error

	// Context returns a context which is Done when the underlying connection has closed.
	Context() context.Context
}

func SocketJSON

func SocketJSON(ctx context.Context, sock *websocket.Conn) Transport

SocketJSON wraps an open websocket.Conn, converting it to an untyped Transport. It derives a new Context which is canceled only if a Read/Send operation fails, but which also closes the socket itself.

Jump to

Keyboard shortcuts

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