transport

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemPair

func NewMemPair() (*MemConnection, *MemConnection)

NewMemPair creates two fully connected endpoints.

Types

type Connection

type Connection interface {
	Send(ctx context.Context, data []byte) error
	Receive(ctx context.Context) ([]byte, error)
	Close(reason string) error
}

type MemConnection

type MemConnection struct {
	In  chan []byte
	Out chan []byte
}

MemConnection implements transport.Connection for in-memory tests.

func (*MemConnection) Close

func (m *MemConnection) Close(reason string) error

func (*MemConnection) Receive

func (m *MemConnection) Receive(ctx context.Context) ([]byte, error)

func (*MemConnection) Send

func (m *MemConnection) Send(ctx context.Context, data []byte) error

type WSConnection

type WSConnection struct {
	Conn *websocket.Conn
}

func (*WSConnection) Close

func (w *WSConnection) Close(reason string) error

func (*WSConnection) Receive

func (w *WSConnection) Receive(ctx context.Context) ([]byte, error)

func (*WSConnection) Send

func (w *WSConnection) Send(ctx context.Context, data []byte) error

type WSProvider

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

WSProvider encapsulates the logic for establishing the connection.

func NewWSProvider

func NewWSProvider(logger *slog.Logger) *WSProvider

func (*WSProvider) Dial

func (p *WSProvider) Dial(ctx context.Context, url string) (Connection, error)

Dial connects to a server (client side)

func (*WSProvider) Listen

func (p *WSProvider) Listen(ctx context.Context, addr string, found chan<- Connection) error

Server is waiting for a connection (server-side) We use a channel to reconnect after the upgrade

type WSService

type WSService interface {
	Listen(addr string, found chan<- Connection) error
	Dial(ctx context.Context, url string) (Connection, error)
}

Jump to

Keyboard shortcuts

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