Documentation ¶
Index ¶
- Constants
- Variables
- type BufferAllocFunc
- type BufferRecycleFunc
- type Frame
- type Logger
- type Option
- func WithBufferManager(allocFunc BufferAllocFunc, recycleFunc BufferRecycleFunc) Option
- func WithBufferSize(sizeLimit int) Option
- func WithFinalizer(finalizer func()) Option
- func WithHeartBeatInterval(interval time.Duration) Option
- func WithHeartBeatSwitch(choose bool) Option
- func WithHeartBeatTTL(ttl time.Duration) Option
- func WithLogger(logger Logger) Option
- func WithMetrics(...) Option
- func WithRole(role roleType) Option
- type Session
- func (session *Session) AcceptStream(ctx context.Context) (*Stream, error)
- func (session *Session) Close() error
- func (session *Session) CloseWithErr(err error)
- func (session *Session) Ctx() context.Context
- func (session *Session) Err() error
- func (session *Session) IsClose() bool
- func (session *Session) Lifetime() time.Duration
- func (session *Session) OpenStream(ctx context.Context) (*Stream, error)
- func (session *Session) StreamCount() int
- type Stream
- func (stream *Stream) Close() error
- func (stream *Stream) Done() <-chan struct{}
- func (stream *Stream) IsClose() bool
- func (stream *Stream) Lifetime() time.Duration
- func (stream *Stream) LocalAddr() net.Addr
- func (stream *Stream) Read(buffer []byte) (int, error)
- func (stream *Stream) ReadContext(ctx context.Context, buffer []byte) (int, error)
- func (stream *Stream) RemoteAddr() net.Addr
- func (stream *Stream) SetDeadline(t time.Time) error
- func (stream *Stream) SetReadDeadline(t time.Time) error
- func (stream *Stream) SetWriteDeadline(t time.Time) error
- func (stream *Stream) Write(buffer []byte) (int, error)
- func (stream *Stream) WriteContext(ctx context.Context, buffer []byte) (int, error)
Constants ¶
View Source
const ( RoleClient roleType = 1 + iota // client start with odd number, server start with even number RoleServer )
Variables ¶
View Source
var ( BufferSizeLimitErr = errors.New("buffer size limit err") UnknownCmdErr = errors.New("cmd unknown err") )
View Source
var ( NoopLogger = &noopLoggerImpl{} StandardLogger = &standardLoggerImpl{} )
View Source
var ( ErrSessionClosed = errors.New("session closed") ErrSessionTTLExceed = errors.New("session ttl exceed") ErrStreamIdDup = errors.New("stream id duplicated err") ErrStreamIdNotFound = errors.New("stream id not found") ErrBufferLimited = errors.New("buffer length limited") )
View Source
var (
ErrStreamClosed = errors.New("stream has been closed")
)
Functions ¶
This section is empty.
Types ¶
type BufferAllocFunc ¶ added in v0.0.14
type BufferRecycleFunc ¶ added in v0.0.14
type BufferRecycleFunc func([]byte)
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
func NewFrameContext ¶ added in v0.0.27
func (*Frame) MarshalHeader ¶ added in v0.0.28
type Option ¶ added in v0.0.14
type Option func(*Session)
func WithBufferManager ¶ added in v0.0.42
func WithBufferManager(allocFunc BufferAllocFunc, recycleFunc BufferRecycleFunc) Option
func WithBufferSize ¶ added in v0.0.27
func WithFinalizer ¶ added in v0.3.5
func WithFinalizer(finalizer func()) Option
func WithHeartBeatInterval ¶ added in v0.0.29
func WithHeartBeatSwitch ¶ added in v0.0.29
func WithHeartBeatTTL ¶ added in v0.3.2
func WithLogger ¶ added in v0.4.3
func WithMetrics ¶ added in v0.4.2
func WithMetrics(writeFrameDurations, recvFrameDurations, acceptStreamDurations prometheus.Histogram) Option
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(conn io.ReadWriteCloser, options ...Option) *Session
func NewSessionContext ¶ added in v0.0.15
func (*Session) AcceptStream ¶
func (*Session) CloseWithErr ¶
func (*Session) OpenStream ¶
OpenStream create a new established stream connection
func (*Session) StreamCount ¶ added in v0.0.26
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) ReadContext ¶ added in v0.0.40
func (*Stream) RemoteAddr ¶ added in v0.0.27
func (*Stream) SetReadDeadline ¶ added in v0.0.27
func (*Stream) SetWriteDeadline ¶ added in v0.0.27
Click to show internal directories.
Click to hide internal directories.