resonance

package module
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 11 Imported by: 4

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 Config

type Config struct {
	MaxMessageSize uint64
}

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) BytesSent added in v0.16.0

func (c *Connection) BytesSent() uint64

BytesSent returns the number of bytes sent over the connection, excluding pings.

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, error)

ReceiveBytes receives bytes.

func (*Connection) ReceiveProton added in v0.10.0

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

ReceiveProton receives proton message from the peer.

func (*Connection) ReceiveRawBytes added in v0.14.0

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

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

func (*Connection) SendBytes added in v0.10.0

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

SendBytes sends bytes.

func (*Connection) SendProton added in v0.10.0

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

SendProton sends proton message to the peer.

func (*Connection) SendRawBytes added in v0.14.0

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

SendRawBytes sends bytes with length prefix already included.

func (*Connection) SendStream added in v0.11.0

func (c *Connection) SendStream(r io.Reader) (retErr 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.

Directories

Path Synopsis
compare module
pkg
sim
generate command

Jump to

Keyboard shortcuts

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