resonance

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 11 Imported by: 0

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) 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) SendBytes added in v0.10.0

func (c *Connection) SendBytes(msg []byte) bool

SendBytes sends bytes.

func (*Connection) SendProton added in v0.10.0

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

SendProton sends proton message to the peer.

func (*Connection) SendStream added in v0.11.0

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

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) Run added in v0.1.1

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

Run runs the goroutines responsible for copying data between this buffer and the external one.

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 {
	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

Jump to

Keyboard shortcuts

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