Documentation
¶
Index ¶
- func RunClient(ctx context.Context, addr string, config Config, ...) error
- func RunServer(ctx context.Context, ls net.Listener, config Config, ...) error
- type Config
- type Connection
- type Peer
- type PeerBuffer
- func (b PeerBuffer) Close() error
- func (b PeerBuffer) OtherPeer() PeerBuffer
- func (b PeerBuffer) Read(buf []byte) (int, error)
- func (b PeerBuffer) ReadFrom(r io.Reader) (int64, error)
- func (b PeerBuffer) Run(ctx context.Context, peer Peer) error
- func (b PeerBuffer) Write(buf []byte) (int, error)
- func (b PeerBuffer) WriteTo(w io.Writer) (int64, error)
- type ProtonMarshaller
- type ProtonUnmarshaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 PeerBuffer ¶
type PeerBuffer struct {
// contains filtered or unexported fields
}
PeerBuffer simulates the network connection from the peer's view.
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.
type ProtonMarshaller ¶ added in v0.10.0
ProtonMarshaller is the proton's interface marshalling messages.