resonance

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 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[M proton.Marshaller](
	ctx context.Context,
	addr string,
	config Config[M],
	handler func(ctx context.Context, c *Connection[M]) error,
) error

RunClient runs client.

func RunServer added in v0.2.0

func RunServer[M proton.Marshaller](
	ctx context.Context,
	ls net.Listener,
	config Config[M],
	handler func(ctx context.Context, c *Connection[M]) error,
) error

RunServer runs server.

Types

type Config

type Config[M proton.Marshaller] struct {
	MaxMessageSize uint64
	Marshaller     M
}

Config is the configuration of connection.

type Connection

type Connection[M proton.Marshaller] struct {
	// contains filtered or unexported fields
}

Connection allows to communicate with the peer.

func NewConnection

func NewConnection[M proton.Marshaller](peer Peer, config Config[M]) *Connection[M]

NewConnection creates new connection.

func (*Connection[M]) Receive

func (c *Connection[M]) Receive() (any, bool)

Receive receives message from the peer.

func (*Connection[M]) Run added in v0.1.1

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

Run runs the connection.

func (*Connection[M]) Send

func (c *Connection[M]) Send(msg proton.Marshallable) bool

Send sends message to the peer.

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.

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