Documentation
¶
Index ¶
- Variables
- func H(i []byte) (res common.MessageID)
- func PayloadSize(c Transport) int
- type BufferedStream
- func (b *BufferedStream) CBORDecode(instance interface{}) error
- func (b *BufferedStream) CBORDecodeAsync(instance interface{}) chan interface{}
- func (s *BufferedStream) Close() error
- func (s *BufferedStream) Read(p []byte) (n int, err error)
- func (b *BufferedStream) Start()
- func (s *BufferedStream) Write(p []byte) (n int, err error)
- type Frame
- type FrameType
- type ReTx
- type Stream
- func Dial(c Transport, network, addr string) (*Stream, error)
- func DialDuplex(s *client.Session, network, addr string) (*Stream, error)
- func Listen(c Transport, network, addr string) (*Stream, error)
- func ListenDuplex(s *client.Session, network, addr string) (*Stream, error)
- func LoadStream(s *client.Session, state []byte) (*Stream, error)
- func NewDuplex(s *client.Session) (*Stream, error)
- func NewMulticastStream(s *client.Session) *Stream
- func NewStream(s *client.Session) *Stream
- func (s *Stream) Close() error
- func (s *Stream) LocalAddr() *StreamAddr
- func (s *Stream) Read(p []byte) (n int, err error)
- func (s *Stream) RemoteAddr() *StreamAddr
- func (s *Stream) Save() ([]byte, error)
- func (s *Stream) Start()
- func (s *Stream) Sync() error
- func (s *Stream) Write(p []byte) (n int, err error)
- type StreamAddr
- type StreamMode
- type StreamState
- type Transport
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func PayloadSize ¶
Types ¶
type BufferedStream ¶
BufferedStream holds a Stream and Buffer of bytes that are used with cbor.Decoder
func (*BufferedStream) CBORDecode ¶
func (b *BufferedStream) CBORDecode(instance interface{}) error
CBORDecode deserializes CBOR from Stream into the instance passed
func (*BufferedStream) CBORDecodeAsync ¶
func (b *BufferedStream) CBORDecodeAsync(instance interface{}) chan interface{}
CBORDecodeAsync is the routine that reads from the Stream until an instance is deserialized or the stream is closed. It returns the deserialiezd instance or error via a channel
type Frame ¶
type Frame struct {
Type FrameType
// Ack is the sequence number of last consequtive frame seen by peer
Id uint64
Ack uint64
Payload []byte // transported data
}
Frame is the container for Stream payloads and contains Stream metadata that indicates whether the Frame is the first, last, or an intermediary block. This
type Stream ¶
type Stream struct {
worker.Worker
// address of the Stream
Addr *StreamAddr
// Initiator is true if Stream is created by NewStream or Listen methods
Initiator bool
// Mode indicates what type of Stream, e.g. EndToEnd or Finite
Mode StreamMode
// frame encryption secrets
WriteKey *[keySize]byte // secretbox key to encrypt with
ReadKey *[keySize]byte // secretbox key to decrypt with
// read/write secrets initialized from handshake
WriteIDBase common.MessageID
ReadIDBase common.MessageID
// buffers
WriteBuf *bytes.Buffer // buffer to enqueue data before being transmitted
ReadBuf *bytes.Buffer // buffer to reassumble data from Frames
// our frame pointers
ReadIdx uint64
WriteIdx uint64
// idx of last ack
AckIdx uint64
// last ack received from peer
PeerAckIdx uint64
// TQ is used to schedule retransmission events of unacknowledged messages
TQ *client.TimerQueue
// R holds state needed to reschedule unacknowledged messages expiring in TQ
R *ReTx
// PayloadSize is the stream frame payload length, and must not change once
// a stream has been initialized.
PayloadSize int
// WindowSize is the number of messages ahead of peer's
// ackknowledgement that the writeworker will periodically retransmit
WindowSize uint64
// MaxWriteBufSize is the number of bytes to buffer before blocking calls to Write()
MaxWriteBufSize int
// RState indicates Reader State
RState StreamState
// RState indicates Writer State
WState StreamState
// timeout value used internally before failing a blocking call
Timeout time.Duration
// contains filtered or unexported fields
}
func DialDuplex ¶
DialDuplex returns a stream using capability backed pigeonhole storage (Duplex)
func ListenDuplex ¶
ListenDuplex returns a Stream using capability pigeonhole storage (Duplex) as initiator
func LoadStream ¶
LoadStream initializes a Stream from state saved by Save()
func NewMulticastStream ¶
NewMulticastStream generates a new address and starts the read/write workers with Multicast mode
func NewStream ¶
NewStream generates a new address and starts the read/write workers with End to End mode func NewStream(c Transport, identity sign.PrivateKey, sign.PublicKey) *Stream {
func (*Stream) Close ¶
Close terminates the Stream with a final Frame and blocks future Writes it does *not* drain WriteBuf, call Sync() to flush WriteBuf first.
func (*Stream) LocalAddr ¶
func (s *Stream) LocalAddr() *StreamAddr
LocalAddr implements net.Addr LocalAddr()
func (*Stream) RemoteAddr ¶
func (s *Stream) RemoteAddr() *StreamAddr
LocalAddr implements net.Conn RemoteAddr()
type StreamAddr ¶
type StreamAddr struct {
// contains filtered or unexported fields
}
StreamAddr implements net.Addr
func (*StreamAddr) String ¶
func (s *StreamAddr) String() string
String implements net.Addr String()
type StreamMode ¶
type StreamMode uint8
StreamMode is the type of stream.
EndToEnd streams require the reader to acknowledge frames of data read before a sender will continue transmitting. Multicast streams are suitable for multiple readers and do not ACK frames nor block the writer by waiting for ACKs. The default StreamMode is EndToEnd.
const ( Multicast StreamMode = iota // no Acknowledgements EndToEnd // requires interactive Acknowledge )
type StreamState ¶
type StreamState uint8
StreamState are the states that the reader and writer routines can be in
const ( StreamOpen StreamState = iota StreamClosing StreamClosed )
type Transport ¶
type Transport mClient.ReadWriteClient
Transport describes the interface to Get or Put Frames
