common

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKeepaliveInteval is default keepalive interval duration.
	DefaultKeepaliveInteval = 20 * time.Second
	// DefaultKeepaliveMaxLifetime is default keepalive max lifetime.
	DefaultKeepaliveMaxLifetime = 90 * time.Second
)
View Source
const MaxUint24 = 16777215

MaxUint24 is the max value of Uint24.

Variables

View Source
var (
	ErrFrameLengthExceed  = errors.New("rsocket: frame length is greater than 24bits")
	ErrInvalidTransport   = errors.New("rsocket: invalid Transport")
	ErrInvalidFrame       = errors.New("rsocket: invalid frame")
	ErrInvalidContext     = errors.New("rsocket: invalid context")
	ErrInvalidFrameLength = errors.New("rsocket: invalid frame length")
	ErrReleasedResource   = errors.New("rsocket: resource has been released")
	ErrInvalidEmitter     = errors.New("rsocket: invalid emitter")
	ErrHandlerNil         = errors.New("rsocket: handler cannot be nil")
	ErrHandlerExist       = errors.New("rsocket: handler exists already")
	ErrSendFull           = errors.New("rsocket: frame send channel is full")
)

Error defines.

Functions

func RandAlphabetic

func RandAlphabetic(n int) (s string)

RandAlphabetic returns a string with random alphabets.

func RandAlphanumeric

func RandAlphanumeric(n int) (s string)

RandAlphanumeric returns a string with random alphabets and numbers.

func RandFloat64

func RandFloat64() (v float64)

RandFloat64 returns a random float64.

func RandIntn

func RandIntn(n int) (v int)

RandIntn returns a random int.

Types

type ByteBuff

type ByteBuff bytes.Buffer

ByteBuff provides byte buffer, which can be used for minimizing.

func NewByteBuff added in v0.5.0

func NewByteBuff() *ByteBuff

NewByteBuff creates a new ByteBuff.

func (*ByteBuff) Bytes

func (p *ByteBuff) Bytes() []byte

Bytes returns all bytes in ByteBuff.

func (*ByteBuff) Len

func (p *ByteBuff) Len() (n int)

Len returns size of ByteBuff.

func (*ByteBuff) Write

func (p *ByteBuff) Write(bs []byte) (int, error)

Writer write bytes to current ByteBuff.

func (*ByteBuff) WriteByte

func (p *ByteBuff) WriteByte(b byte) error

WriteByte write a byte to current ByteBuff.

func (*ByteBuff) WriteTo

func (p *ByteBuff) WriteTo(w io.Writer) (int64, error)

WriteTo write bytes to writer.

func (*ByteBuff) WriteUint24

func (p *ByteBuff) WriteUint24(n int) (err error)

WriteUint24 encode and write Uint24 to current ByteBuff.

type ErrorCode

type ErrorCode uint32

ErrorCode is code for RSocket error.

const (
	// ErrorCodeInvalidSetup means the setup frame is invalid for the server.
	ErrorCodeInvalidSetup ErrorCode = 0x00000001
	// ErrorCodeUnsupportedSetup means some (or all) of the parameters specified by the client are unsupported by the server.
	ErrorCodeUnsupportedSetup ErrorCode = 0x00000002
	// ErrorCodeRejectedSetup means server rejected the setup, it can specify the reason in the payload.
	ErrorCodeRejectedSetup ErrorCode = 0x00000003
	// ErrorCodeRejectedResume means server rejected the resume, it can specify the reason in the payload.
	ErrorCodeRejectedResume ErrorCode = 0x00000004
	// ErrorCodeConnectionError means the connection is being terminated.
	ErrorCodeConnectionError ErrorCode = 0x00000101
	// ErrorCodeConnectionClose means the connection is being terminated.
	ErrorCodeConnectionClose ErrorCode = 0x00000102
	// ErrorCodeApplicationError means application layer logic generating a Reactive Streams onError event.
	ErrorCodeApplicationError ErrorCode = 0x00000201
	// ErrorCodeRejected means Responder reject it.
	ErrorCodeRejected ErrorCode = 0x00000202
	// ErrorCodeCanceled means the Responder canceled the request but may have started processing it (similar to REJECTED but doesn't guarantee lack of side-effects).
	ErrorCodeCanceled ErrorCode = 0x00000203
	// ErrorCodeInvalid means the request is invalid.
	ErrorCodeInvalid ErrorCode = 0x00000204
)

func (ErrorCode) String

func (p ErrorCode) String() string

type Uint24

type Uint24 [3]byte

Uint24 is 3 bytes unsigned integer.

func NewUint24

func NewUint24(n int) (v Uint24)

NewUint24 returns a new uint24.

func NewUint24Bytes

func NewUint24Bytes(bs []byte) Uint24

NewUint24Bytes returns a new uint24 from bytes.

func (Uint24) AsInt

func (p Uint24) AsInt() int

AsInt converts to int.

func (Uint24) Bytes

func (p Uint24) Bytes() []byte

Bytes returns bytes encoded.

func (Uint24) WriteTo

func (p Uint24) WriteTo(w io.Writer) (int64, error)

WriteTo encode and write bytes to a writer.

type Version

type Version [2]uint16

Version define the version of protocol. It inclues major and minor version.

var DefaultVersion Version = [2]uint16{1, 0}

DefaultVersion is default protocol version.

func (Version) Bytes

func (p Version) Bytes() []byte

Bytes returns raw bytes of current version.

func (Version) Major

func (p Version) Major() uint16

Major returns major version.

func (Version) Minor

func (p Version) Minor() uint16

Minor returns minor version.

func (Version) String

func (p Version) String() string

func (Version) WriteTo

func (p Version) WriteTo(w io.Writer) (n int64, err error)

WriteTo write raw version bytes to a writer.

Jump to

Keyboard shortcuts

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