connection

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: AGPL-3.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelDescriptor

type ChannelDescriptor struct {
	ID                  byte
	Priority            int
	SendQueueCapacity   int
	RecvBufferCapacity  int
	RecvMessageCapacity int
}

ChannelDescriptor is the setting of channel

func (*ChannelDescriptor) FillDefaults

func (chDesc *ChannelDescriptor) FillDefaults()

FillDefaults set the channel config if empty

type MConnConfig

type MConnConfig struct {
	SendRate    int64  `mapstructure:"send_rate"`
	RecvRate    int64  `mapstructure:"recv_rate"`
	Compression string `mapstructure:"compression_backend"`
}

MConnConfig is a MConnection configuration.

func DefaultMConnConfig

func DefaultMConnConfig(compression string) *MConnConfig

DefaultMConnConfig returns the default config.

type MConnection

type MConnection struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

MConnection handles message transmission on multiple abstract communication `Channel`s. Each channel has a globally unique byte id. The byte id and the relative priorities of each `Channel` are configured upon initialization of the connection.

There are two methods for sending messages:

func (m MConnection) Send(chID byte, msg interface{}) bool {}
func (m MConnection) TrySend(chID byte, msg interface{}) bool {}

`Send(chID, msg)` is a blocking call that waits until `msg` is successfully queued for the channel with the given id byte `chID`, or until the request times out. The message `msg` is serialized using the `tendermint/wire` submodule's `WriteBinary()` reflection routine.

`TrySend(chID, msg)` is a nonblocking call that returns false if the channel's queue is full.

Inbound message bytes are handled with an onReceive callback function.

func NewMConnectionWithConfig

func NewMConnectionWithConfig(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc, config *MConnConfig) *MConnection

NewMConnectionWithConfig wraps net.Conn and creates multiplex connection with a config

func (*MConnection) CanSend

func (c *MConnection) CanSend(chID byte) bool

CanSend returns true if you can send more data onto the chID, false otherwise

func (*MConnection) OnStart

func (c *MConnection) OnStart() error

OnStart implements BaseService

func (*MConnection) OnStop

func (c *MConnection) OnStop()

OnStop implements BaseService

func (*MConnection) Send

func (c *MConnection) Send(chID byte, msg interface{}) bool

Send will queues a message to be sent to channel(blocking).

func (*MConnection) String

func (c *MConnection) String() string

func (*MConnection) TrafficStatus

func (c *MConnection) TrafficStatus() (*flowrate.Status, *flowrate.Status)

TrafficStatus return the in and out traffic status

func (*MConnection) TrySend

func (c *MConnection) TrySend(chID byte, msg interface{}) bool

TrySend queues a message to be sent to channel(Nonblocking).

type SecretConnection

type SecretConnection struct {
	// contains filtered or unexported fields
}

SecretConnection implements net.Conn

func MakeSecretConnection

func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey signlib.PrivKey) (*SecretConnection, error)

MakeSecretConnection performs handshake and returns a new authenticated SecretConnection.

func (*SecretConnection) Close

func (sc *SecretConnection) Close() error

Close implements net.Conn

func (*SecretConnection) LocalAddr

func (sc *SecretConnection) LocalAddr() net.Addr

LocalAddr implements net.Conn

func (*SecretConnection) Read

func (sc *SecretConnection) Read(data []byte) (n int, err error)

CONTRACT: data smaller than dataMaxSize is read atomically.

func (*SecretConnection) RemoteAddr

func (sc *SecretConnection) RemoteAddr() net.Addr

RemoteAddr implements net.Conn

func (*SecretConnection) RemotePubKey

func (sc *SecretConnection) RemotePubKey() signlib.PubKey

RemotePubKey returns authenticated remote pubkey

func (*SecretConnection) SetDeadline

func (sc *SecretConnection) SetDeadline(t time.Time) error

SetDeadline implements net.Conn

func (*SecretConnection) SetReadDeadline

func (sc *SecretConnection) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn

func (*SecretConnection) SetWriteDeadline

func (sc *SecretConnection) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn

func (*SecretConnection) Write

func (sc *SecretConnection) Write(data []byte) (n int, err error)

Writes encrypted frames of `sealedFrameSize` CONTRACT: data smaller than dataMaxSize is read atomically.

Jump to

Keyboard shortcuts

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