resonance

package module
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 19 Imported by: 3 modules, 4 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.

README

resonance

Communication library using proton messages

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunClient added in v0.2.0

func RunClient(
	ctx context.Context,
	addr string,
	config Config,
	handler func(ctx context.Context, c *Connection) error,
) error

RunClient runs client.

func RunServer added in v0.2.0

func RunServer(
	ctx context.Context,
	ls net.Listener,
	config Config,
	handler func(ctx context.Context, c *Connection) error,
) error

RunServer runs server.

Types

type CA added in v0.27.0

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

CA represents certificate authority issuing TLS configs.

func NewCA added in v0.27.0

func NewCA(r io.Reader) (*CA, error)

NewCA creates new CA.

func (*CA) Generate added in v0.27.0

func (ca *CA) Generate() (*tls.Config, error)

Generate generates new TLS config with resh client certificate.

type CASource added in v0.27.0

type CASource interface {
	Generate() (*tls.Config, error)
}

CASource represents CA TLS config generator.

type Config

type Config struct {
	MaxMessageSize uint64
	CA             CASource
}

Config is the configuration of connection.

type Connection

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

Connection allows to communicate with the peer.

func NewConnection

func NewConnection(peer Peer, config Config) *Connection

NewConnection creates new connection.

func (*Connection) BufferReads added in v0.17.0

func (c *Connection) BufferReads()

BufferReads turns on read buffer.

func (*Connection) BufferWrites added in v0.17.0

func (c *Connection) BufferWrites()

BufferWrites turns on write buffer.

func (*Connection) Close added in v0.12.0

func (c *Connection) Close()

Close closes connection.

func (*Connection) ReceiveBytes added in v0.10.0

func (c *Connection) ReceiveBytes() ([]byte, uint64, error)

ReceiveBytes receives bytes.

func (*Connection) ReceiveProton added in v0.10.0

func (c *Connection) ReceiveProton(m ProtonUnmarshaller) (any, uint64, error)

ReceiveProton receives proton message from the peer.

func (*Connection) ReceiveRawBytes added in v0.14.0

func (c *Connection) ReceiveRawBytes() ([]byte, uint64, error)

ReceiveRawBytes receives bytes and returns them with together with length prefix.

func (*Connection) Run added in v0.1.1

func (c *Connection) Run(ctx context.Context) error

Run runs connection's goroutines.

func (*Connection) SendBytes added in v0.10.0

func (c *Connection) SendBytes(msg []byte) (uint64, error)

SendBytes sends bytes.

func (*Connection) SendProton added in v0.10.0

func (c *Connection) SendProton(msg any, m ProtonMarshaller) (uint64, error)

SendProton sends proton message to the peer.

func (*Connection) SendRawBytes added in v0.14.0

func (c *Connection) SendRawBytes(msg []byte) (uint64, error)

SendRawBytes sends bytes with length prefix already included.

func (*Connection) SendStream added in v0.11.0

func (c *Connection) SendStream(r io.Reader) error

SendStream sends stream of data taken from the reader.

type Peer added in v0.1.1

type Peer io.ReadWriteCloser

Peer represents the connected peer.

type PeerBuffer

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

PeerBuffer simulates the network connection from the peer's view.

func NewPeerBuffer

func NewPeerBuffer() PeerBuffer

NewPeerBuffer returns new peer buffer.

func (PeerBuffer) Close added in v0.1.1

func (b PeerBuffer) Close() error

Close closes the streams.

func (PeerBuffer) OtherPeer

func (b PeerBuffer) OtherPeer() PeerBuffer

OtherPeer returns the corresponding buffer for the other peer in the connection.

func (PeerBuffer) Read

func (b PeerBuffer) Read(buf []byte) (int, error)

Read reads data from the read buffer.

func (PeerBuffer) ReadFrom added in v0.1.1

func (b PeerBuffer) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads data from the incoming stream.

func (PeerBuffer) RunReader added in v0.15.0

func (b PeerBuffer) RunReader(ctx context.Context, peer Peer) error

RunReader reads data from peer.

func (PeerBuffer) RunWriter added in v0.15.0

func (b PeerBuffer) RunWriter(ctx context.Context, peer Peer) error

RunWriter writes data to peer.

func (PeerBuffer) Write

func (b PeerBuffer) Write(buf []byte) (int, error)

Write writes data to the write buffer.

func (PeerBuffer) WriteTo added in v0.1.1

func (b PeerBuffer) WriteTo(w io.Writer) (int64, error)

WriteTo writes data to the outgoing stream.

type ProtonMarshaller added in v0.10.0

type ProtonMarshaller interface {
	Size(msg any) (uint64, error)
	Marshal(msg any, buf []byte) (uint64, uint64, error)
}

ProtonMarshaller is the proton's interface marshalling messages.

type ProtonUnmarshaller added in v0.10.0

type ProtonUnmarshaller interface {
	Unmarshal(id uint64, buf []byte) (any, uint64, error)
}

ProtonUnmarshaller is the proton's interface unmarshalling messages.

type Reader added in v0.28.0

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

Reader reads packets from stream.

func NewReader added in v0.28.0

func NewReader(r io.Reader, maxMessageSize uint64) *Reader

NewReader creates new reader.

func (*Reader) ReceiveBytes added in v0.28.0

func (r *Reader) ReceiveBytes() ([]byte, uint64, error)

ReceiveBytes receives bytes.

func (*Reader) ReceiveProton added in v0.28.0

func (r *Reader) ReceiveProton(m ProtonUnmarshaller) (any, uint64, error)

ReceiveProton receives proton message from the peer.

func (*Reader) ReceiveRawBytes added in v0.28.0

func (r *Reader) ReceiveRawBytes() ([]byte, uint64, error)

ReceiveRawBytes receives bytes and returns them with together with length prefix.

type Writer added in v0.28.0

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

Writer writes packets to stream.

func NewWriter added in v0.28.0

func NewWriter(w io.Writer, maxMessageSize uint64) *Writer

NewWriter creates new writer.

func (*Writer) SendBytes added in v0.28.0

func (w *Writer) SendBytes(msg []byte) (uint64, error)

SendBytes sends bytes.

func (*Writer) SendPing added in v0.28.0

func (w *Writer) SendPing() error

SendPing sends ping.

func (*Writer) SendProton added in v0.28.0

func (w *Writer) SendProton(msg any, m ProtonMarshaller) (uint64, error)

SendProton sends proton message to the peer.

func (*Writer) SendRawBytes added in v0.28.0

func (w *Writer) SendRawBytes(msg []byte) (uint64, error)

SendRawBytes sends bytes with length prefix already included.

func (*Writer) SendStream added in v0.28.0

func (w *Writer) SendStream(r io.Reader) error

SendStream sends stream of data taken from the reader.

Directories

Path Synopsis
compare module
pkg
Package test provides marshaller for entities.
Package test provides marshaller for entities.
generate command

Jump to

Keyboard shortcuts

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