proto

package
v0.0.0-...-b4de4d8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MinExtensionType = 0xFFFFFFFF - 0x100 // 512 extensions
)

Variables

This section is empty.

Functions

func NewStream

func NewStream(id frame.StreamId, priority frame.StreamPriority, streamType frame.StreamType, finLocal bool, finRemote bool, windowSize uint32, sess session) stream

////////////////////////////// public interface //////////////////////////////

Types

type ConcurrentStreamMap

type ConcurrentStreamMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConcurrentStreamMap is a map of stream ids -> streams guarded by a read/write lock

func NewConcurrentStreamMap

func NewConcurrentStreamMap() *ConcurrentStreamMap

func (*ConcurrentStreamMap) Delete

func (m *ConcurrentStreamMap) Delete(id frame.StreamId)

func (*ConcurrentStreamMap) Each

func (m *ConcurrentStreamMap) Each(fn func(frame.StreamId, stream))

func (*ConcurrentStreamMap) Get

func (m *ConcurrentStreamMap) Get(id frame.StreamId) (s stream, ok bool)

func (*ConcurrentStreamMap) Set

func (m *ConcurrentStreamMap) Set(id frame.StreamId, str stream)

type ExtAccept

type ExtAccept func() (IStream, error)

for extensions

type Extension

type Extension interface {
	Start(ISession, ExtAccept) frame.StreamType
}

type ISession

type ISession interface {
	Open() (IStream, error)
	OpenStream(frame.StreamPriority, frame.StreamType, bool) (IStream, error)
	Accept() (IStream, error)
	Kill() error
	GoAway(frame.ErrorCode, []byte) error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	Close() error
	Wait() (frame.ErrorCode, error, []byte)
	NetListener() net.Listener
	NetDial(_, _ string) (net.Conn, error)
}

func NewSession

func NewSession(conn net.Conn, newStream streamFactory, isClient bool, exts []Extension) ISession

type IStream

type IStream interface {
	Write([]byte) (int, error)
	Read([]byte) (int, error)
	Close() error
	SetDeadline(time.Time) error
	SetReadDeadline(time.Time) error
	SetWriteDeadline(time.Time) error
	HalfClose([]byte) (int, error)
	Id() frame.StreamId
	StreamType() frame.StreamType
	Session() ISession
	RemoteAddr() net.Addr
	LocalAddr() net.Addr
}

type Session

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

Session implements a simple streaming session manager. It has the following characteristics:

- When closing the Session, it does not linger, all pending write operations will fail immediately. - It completely ignores stream priority when processing and writing frames - It offers no customization of settings like window size/ping time

func (*Session) Accept

func (s *Session) Accept() (str IStream, err error)

func (*Session) Close

func (s *Session) Close() error

func (*Session) GoAway

func (s *Session) GoAway(errorCode frame.ErrorCode, debug []byte) (err error)

func (*Session) Kill

func (s *Session) Kill() error

func (*Session) LocalAddr

func (s *Session) LocalAddr() net.Addr

func (*Session) NetDial

func (s *Session) NetDial(_, _ string) (net.Conn, error)

//////////////////////////////////////////// net adaptors ////////////////////////////////////////////

func (*Session) NetListener

func (s *Session) NetListener() net.Listener

func (*Session) Open

func (s *Session) Open() (IStream, error)

func (*Session) OpenStream

func (s *Session) OpenStream(priority frame.StreamPriority, streamType frame.StreamType, fin bool) (ret IStream, err error)

func (*Session) RemoteAddr

func (s *Session) RemoteAddr() net.Addr

func (*Session) Wait

func (s *Session) Wait() (frame.ErrorCode, error, []byte)

type Stream

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

func (*Stream) Close

func (s *Stream) Close() error

Close closes the stream in a manner that attempts to emulate a net.Conn's Close(): - It calls HalfClose() with an empty buffer to half-close the stream on the remote side - It calls closeWith() so that all future Read/Write operations will fail - If the stream receives another STREAM_DATA frame from the remote side, it will send a STREAM_RST with a CANCELED error code

func (*Stream) HalfClose

func (s *Stream) HalfClose(buf []byte) (n int, err error)

func (*Stream) Id

func (s *Stream) Id() frame.StreamId

func (*Stream) LocalAddr

func (s *Stream) LocalAddr() net.Addr

func (*Stream) Read

func (s *Stream) Read(buf []byte) (n int, err error)

func (*Stream) RemoteAddr

func (s *Stream) RemoteAddr() net.Addr

func (*Stream) Session

func (s *Stream) Session() ISession

func (*Stream) SetDeadline

func (s *Stream) SetDeadline(deadline time.Time) (err error)

func (*Stream) SetReadDeadline

func (s *Stream) SetReadDeadline(dl time.Time) error

func (*Stream) SetWriteDeadline

func (s *Stream) SetWriteDeadline(dl time.Time) error

func (*Stream) StreamType

func (s *Stream) StreamType() frame.StreamType

func (*Stream) Write

func (s *Stream) Write(buf []byte) (n int, err error)

type StreamMap

type StreamMap interface {
	Get(frame.StreamId) (stream, bool)
	Set(frame.StreamId, stream)
	Delete(frame.StreamId)
	Each(func(frame.StreamId, stream))
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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