fnet

package
v0.0.0-...-c3b2f19 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrameConn

type FrameConn interface {
	FrameSize() int

	//Gracefully stop the FrameConn
	Close() error

	// SendFrame sends a bounded-size frame over the connection.
	// PRE: b :->[] bs, len(bs) = FrameSize
	// RET: b :->[] xs, len(xs) = FrameSize
	// EFF: if err = nil then SendFrame(bs) else (SendFrame(xs) OR NoEffects)
	SendFrame(b []byte) error // only frames of valid size or less

	// RecvFrame receives a bounded-size fram over the connection
	// PRE: b :->[] mm, len(mm) = FrameSize.
	// RET: b :->[] bs, len(bs) = FrameSize
	// EFF: if err = nil then RecvFrame(bs) else (RecvFrame(bs) OR NoEffects)
	RecvFrame(b []byte) (err error)
}

func FromOrderedStream

func FromOrderedStream(c net.Conn, frameSize int) FrameConn

FromOrderedStream wraps a net.Conn in a framing layer. PRE: c :-> net.Conn RET: ret :-> FrameConn{FrameSize = frameSize}

func Wrap

func Wrap(c net.Conn, frameSize int) FrameConn

Wrap wraps a net.Conn that already implements framing

type RoundRobin

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

func NewRoundRobin

func NewRoundRobin(frameSize int) *RoundRobin

func (*RoundRobin) AddConn

func (rr *RoundRobin) AddConn(fc FrameConn)

func (*RoundRobin) Close

func (rr *RoundRobin) Close() error

TODO: Make it so that this can be called more than once freely

func (*RoundRobin) FrameSize

func (rr *RoundRobin) FrameSize() int

FrameSize implements FrameConn.FrameSize

func (*RoundRobin) RecvFrame

func (rr *RoundRobin) RecvFrame(b []byte) error

RecvFrame implements FrameConn.RecvFrame It pulls the next frame out of the recv channel This method should be running continously to prevent blocking on the recv chan

func (*RoundRobin) RemoveConn

func (rr *RoundRobin) RemoveConn(fc FrameConn)

TODO: Implement this more efficiently

func (*RoundRobin) SendFrame

func (rr *RoundRobin) SendFrame(b []byte) error

SendFrame implements FrameConn.SendFrame

Jump to

Keyboard shortcuts

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