resonance

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 4 Imported by: 4

README

resonance

Communication library using proton messages

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxMessageSize uint64
	MsgToIDFunc    func(m any) (uint64, error)
	IDToMsgFunc    func(id uint64) (any, error)
}

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 io.ReadWriter, config Config) *Connection

NewConnection creates new connection.

func (*Connection) Ping

func (c *Connection) Ping() error

Ping sends the 0x00 byte to ensure connection works.

func (*Connection) Receive

func (c *Connection) Receive() (any, error)

Receive receives message from the peer.

func (*Connection) Send

func (c *Connection) Send(msg Marshalable) error

Send sends message to the peer.

type Marshalable

type Marshalable interface {
	Marshal(buf []byte) uint64
}

Marshalable is the interface for messages.

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) 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) (n int, err error)

Read reads data from the read buffer.

func (PeerBuffer) ReadByte

func (b PeerBuffer) ReadByte() (byte, error)

ReadByte reads byte from the read buffer.

func (PeerBuffer) Write

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

Write writes data to the write buffer.

Directories

Path Synopsis
compare module

Jump to

Keyboard shortcuts

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