Documentation ¶
Index ¶
- type ChannelDescriptor
- type MConnConfig
- type MConnection
- func (c *MConnection) CanSend(chID byte) bool
- func (c *MConnection) OnStart() error
- func (c *MConnection) OnStop()
- func (c *MConnection) Send(chID byte, msg interface{}) bool
- func (c *MConnection) String() string
- func (c *MConnection) TrafficStatus() (*flowrate.Status, *flowrate.Status)
- func (c *MConnection) TrySend(chID byte, msg interface{}) bool
- type SecretConnection
- func (sc *SecretConnection) Close() error
- func (sc *SecretConnection) LocalAddr() net.Addr
- func (sc *SecretConnection) Read(data []byte) (n int, err error)
- func (sc *SecretConnection) RemoteAddr() net.Addr
- func (sc *SecretConnection) RemotePubKey() signlib.PubKey
- func (sc *SecretConnection) SetDeadline(t time.Time) error
- func (sc *SecretConnection) SetReadDeadline(t time.Time) error
- func (sc *SecretConnection) SetWriteDeadline(t time.Time) error
- func (sc *SecretConnection) Write(data []byte) (n int, err error)
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"` }
MConnConfig is a MConnection configuration.
func DefaultMConnConfig ¶
func DefaultMConnConfig() *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) 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