Documentation ¶
Index ¶
- Constants
- Variables
- func Byte2Int(data []byte) int
- func Byte2Int64(data []byte) int64
- func Byte2UInt32(data []byte) uint32
- func Byte2UInt64(data []byte) uint64
- func BytesToUint64(b []byte) (uint64, error)
- func FormatFloat64ToBytes(v float64) []byte
- func FormatInt64ToBytes(v int64) []byte
- func Int2Bytes(v int) []byte
- func Int2BytesTo(v int, ret []byte)
- func Int64ToBytes(v int64) []byte
- func Int64ToBytesTo(v int64, ret []byte)
- func NewKey() string
- func NewV1Bytes() []byte
- func NewV1UUID() string
- func NewV4Bytes() []byte
- func NewV4UUID() string
- func ReadInt(r io.Reader) (int, error)
- func ReadN(r io.Reader, n int) ([]byte, error)
- func SliceToString(b []byte) (s string)
- func StrFloat64(v []byte) (float64, error)
- func StrInt64(v []byte) (int64, error)
- func StringToSlice(s string) (b []byte)
- func Uint64ToBytes(v uint64) []byte
- func Uint64ToBytesTo(v uint64, ret []byte)
- func UseMemPool(min, max int)
- type AddressBasedPool
- type BaseMiddleware
- func (sm *BaseMiddleware) Closed(conn IOSession)
- func (sm *BaseMiddleware) Connected(conn IOSession)
- func (sm *BaseMiddleware) PostRead(msg interface{}, conn IOSession) (bool, interface{}, error)
- func (sm *BaseMiddleware) PostWrite(msg interface{}, conn IOSession) (bool, error)
- func (sm *BaseMiddleware) PreRead(conn IOSession) (bool, interface{}, error)
- func (sm *BaseMiddleware) PreWrite(msg interface{}, conn IOSession) (bool, interface{}, error)
- func (sm *BaseMiddleware) ReadError(err error, conn IOSession) error
- func (sm *BaseMiddleware) WriteError(err error, conn IOSession)
- type ByteBuf
- func (b *ByteBuf) Capacity() int
- func (b *ByteBuf) Clear()
- func (b *ByteBuf) Expansion(n int)
- func (b *ByteBuf) GetMarkedRemind() int
- func (b *ByteBuf) GetMarkedRemindData() []byte
- func (b *ByteBuf) GetMarkerIndex() int
- func (b *ByteBuf) GetReaderIndex() int
- func (b *ByteBuf) GetWriteIndex() int
- func (b *ByteBuf) MarkIndex(index int) error
- func (b *ByteBuf) MarkN(n int) error
- func (b *ByteBuf) MarkedBytesReaded()
- func (b *ByteBuf) PeekByte(offset int) (byte, error)
- func (b *ByteBuf) PeekInt(offset int) (int, error)
- func (b *ByteBuf) PeekN(offset int, n int) ([]byte, error)
- func (b *ByteBuf) RawBuf() []byte
- func (b *ByteBuf) Read(p []byte) (n int, err error)
- func (b *ByteBuf) ReadAll() (int, []byte, error)
- func (b *ByteBuf) ReadByte() (byte, error)
- func (b *ByteBuf) ReadBytes(n int) (int, []byte, error)
- func (b *ByteBuf) ReadFrom(r io.Reader) (n int64, err error)
- func (b *ByteBuf) ReadInt() (int, error)
- func (b *ByteBuf) ReadInt64() (int64, error)
- func (b *ByteBuf) ReadMarkedBytes() (int, []byte, error)
- func (b *ByteBuf) ReadRawBytes(n int) (int, []byte, error)
- func (b *ByteBuf) ReadUInt32() (uint32, error)
- func (b *ByteBuf) ReadUInt64() (uint64, error)
- func (b *ByteBuf) Readable() int
- func (b *ByteBuf) Release()
- func (b *ByteBuf) Resume(capacity int)
- func (b *ByteBuf) SetReaderIndex(newReaderIndex int) error
- func (b *ByteBuf) SetWriterIndex(newWriterIndex int) error
- func (b *ByteBuf) Skip(n int) error
- func (b *ByteBuf) Write(p []byte) (int, error)
- func (b *ByteBuf) WriteByte(v byte) error
- func (b *ByteBuf) WriteByteBuf(from *ByteBuf) error
- func (b *ByteBuf) WriteInt(v int) (n int, err error)
- func (b *ByteBuf) WriteInt64(v int64) (n int, err error)
- func (b *ByteBuf) WriteString(v string) error
- func (b *ByteBuf) WriteUint64(v uint64) (n int, err error)
- func (b *ByteBuf) Writeable() int
- type ClientOption
- func WithClientConnectTimeout(timeout time.Duration) ClientOption
- func WithClientDecoder(decoder Decoder) ClientOption
- func WithClientEncoder(encoder Encoder) ClientOption
- func WithClientMiddleware(middlewares ...Middleware) ClientOption
- func WithClientReadBufSize(readBufSize int) ClientOption
- func WithClientWriteBufSize(writeBufSize int) ClientOption
- func WithClientWriteTimeoutHandler(timeout time.Duration, handler func(string, IOSession), ...) ClientOption
- type Closer
- type ConnStatusHandler
- type Decoder
- type Encoder
- type Factory
- type IDGenerator
- type IOSession
- type IOSessionPool
- type Int64IDGenerator
- type IntLengthFieldBasedDecoder
- type IntLengthFieldBasedEncoder
- type MessageReader
- type MessageWriter
- type Middleware
- type OffsetQueue
- type Option
- type Pool
- type RawDecoder
- type Server
- type ServerOption
- func WithServerDecoder(decoder Decoder) ServerOption
- func WithServerEncoder(encoder Encoder) ServerOption
- func WithServerIDGenerator(generator IDGenerator) ServerOption
- func WithServerMiddleware(middlewares ...Middleware) ServerOption
- func WithServerReadBufSize(readBufSize int) ServerOption
- func WithServerWriteBufSize(writeBufSize int) ServerOption
- type StringCodec
- type SyncCodec
- type SyncPool
- type Timeout
- type TimeoutWheel
- type UUID
- func And(u1 UUID, u2 UUID) UUID
- func FromBytes(input []byte) (u UUID, err error)
- func FromBytesOrNil(input []byte) UUID
- func FromString(input string) (u UUID, err error)
- func FromStringOrNil(input string) UUID
- func NewV1() UUID
- func NewV2(domain byte) UUID
- func NewV3(ns UUID, name string) UUID
- func NewV4() UUID
- func NewV5(ns UUID, name string) UUID
- func Or(u1 UUID, u2 UUID) UUID
- func (u UUID) Bytes() []byte
- func (u UUID) MarshalBinary() (data []byte, err error)
- func (u UUID) MarshalText() (text []byte, err error)
- func (u *UUID) Scan(src interface{}) error
- func (u *UUID) SetVariant()
- func (u *UUID) SetVersion(v byte)
- func (u UUID) String() string
- func (u *UUID) UnmarshalBinary(data []byte) (err error)
- func (u *UUID) UnmarshalText(text []byte) (err error)
- func (u UUID) Value() (driver.Value, error)
- func (u UUID) Variant() uint
- func (u UUID) Version() uint
- type UUIDV4IdGenerator
Constants ¶
const ( // DefaultSessionBucketSize default bucket size of session map DefaultSessionBucketSize = 64 // DefaultReadBuf read buf size DefaultReadBuf = 256 // DefaultWriteBuf write buf size DefaultWriteBuf = 256 )
const ( // KB kb KB = 1024 // MB mb MB = 1024 * 1024 )
const ( VariantNCS = iota VariantRFC4122 VariantMicrosoft VariantFuture )
UUID layout variants.
const ( DomainPerson = iota DomainGroup DomainOrg )
UUID DCE domains.
const (
// FieldLength field length bytes
FieldLength = 4
)
Variables ¶
var ( // ErrWrite write error ErrWrite = errors.New("goetty.net: Write failed") // ErrEmptyServers empty server error ErrEmptyServers = errors.New("goetty.Connector: Empty servers pool") // ErrIllegalState illegal state error ErrIllegalState = errors.New("goetty.Connector: Not connected") )
var (
NamespaceDNS, _ = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
NamespaceURL, _ = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
NamespaceOID, _ = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
)
Predefined namespace UUIDs.
var ( // ErrClosed is the error resulting if the pool is closed via pool.Close(). ErrClosed = errors.New("pool is closed") )
var ( // ErrConnectServerSide error for can't connect to client at server side ErrConnectServerSide = errors.New("can't connect to client at server side") )
var ( // ErrSystemStopped is returned when a user tries to schedule a timeout after stopping the // timeout system. ErrSystemStopped = errors.New("Timeout System is stopped") )
var ErrTooLarge = errors.New("goetty.ByteBuf: too large")
ErrTooLarge too larger error
var Nil = UUID{}
Nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
Functions ¶
func Byte2Int64 ¶
Byte2Int64 byte array to int64 value using big order
func Byte2UInt32 ¶
Byte2UInt32 byte array to uint32 value using big order
func Byte2UInt64 ¶
Byte2UInt64 byte array to int64 value using big order
func FormatFloat64ToBytes ¶
FormatFloat64ToBytes float64 -> string
func FormatInt64ToBytes ¶
FormatInt64ToBytes int64 -> string
func Int2BytesTo ¶
Int2BytesTo int value to bytes array using big order
func Int64ToBytes ¶
Int64ToBytes int64 value to bytes array using big order
func Int64ToBytesTo ¶
Int64ToBytesTo int64 value to bytes array using big order
func SliceToString ¶
SliceToString slice to string with out data copy
func StringToSlice ¶
StringToSlice string to slice with out data copy
func Uint64ToBytesTo ¶
Uint64ToBytesTo uint64 value to bytes array using big order
Types ¶
type AddressBasedPool ¶
AddressBasedPool is a address based conn pool. Only one conn per address in the pool.
func NewAddressBasedPool ¶
func NewAddressBasedPool(factory func(string) IOSession, handler ConnStatusHandler) *AddressBasedPool
NewAddressBasedPool returns a AddressBasedPool with a factory fun
func (*AddressBasedPool) GetConn ¶
func (pool *AddressBasedPool) GetConn(addr string) (IOSession, error)
GetConn returns a IOSession that connected to the address Every address has only one connection in the pool
func (*AddressBasedPool) RemoveConn ¶
func (pool *AddressBasedPool) RemoveConn(addr string)
RemoveConn close the conn, and remove from the pool
func (*AddressBasedPool) RemoveConnIfMatches ¶
func (pool *AddressBasedPool) RemoveConnIfMatches(addr string, target IOSession) bool
RemoveConnIfMatches close the conn, and remove from the pool if the conn in the pool is match the given
type BaseMiddleware ¶
type BaseMiddleware struct { }
BaseMiddleware defined default reutrn value
func (*BaseMiddleware) Closed ¶
func (sm *BaseMiddleware) Closed(conn IOSession)
Closed default option
func (*BaseMiddleware) Connected ¶
func (sm *BaseMiddleware) Connected(conn IOSession)
Connected default option
func (*BaseMiddleware) PostRead ¶
func (sm *BaseMiddleware) PostRead(msg interface{}, conn IOSession) (bool, interface{}, error)
PostRead default reutrn value
func (*BaseMiddleware) PostWrite ¶
func (sm *BaseMiddleware) PostWrite(msg interface{}, conn IOSession) (bool, error)
PostWrite default reutrn value
func (*BaseMiddleware) PreRead ¶
func (sm *BaseMiddleware) PreRead(conn IOSession) (bool, interface{}, error)
PreRead default reutrn value
func (*BaseMiddleware) PreWrite ¶
func (sm *BaseMiddleware) PreWrite(msg interface{}, conn IOSession) (bool, interface{}, error)
PreWrite default reutrn value
func (*BaseMiddleware) ReadError ¶
func (sm *BaseMiddleware) ReadError(err error, conn IOSession) error
ReadError conn read err
func (*BaseMiddleware) WriteError ¶
func (sm *BaseMiddleware) WriteError(err error, conn IOSession)
WriteError conn write err
type ByteBuf ¶
type ByteBuf struct {
// contains filtered or unexported fields
}
ByteBuf a buf with byte arrays
| discardable bytes | readable bytes | writeable bytes | | | | | | | | | 0 <= readerIndex <= writerIndex <= capacity
func NewByteBufPool ¶
NewByteBufPool create a new bytebuf using a mem pool
func (*ByteBuf) GetMarkedRemind ¶
GetMarkedRemind returns size in [readerIndex, markedIndex)
func (*ByteBuf) GetMarkedRemindData ¶
GetMarkedRemindData returns data in [readerIndex, markedIndex)
func (*ByteBuf) GetMarkerIndex ¶
GetMarkerIndex returns markerIndex
func (*ByteBuf) GetReaderIndex ¶
GetReaderIndex get the read index
func (*ByteBuf) GetWriteIndex ¶
GetWriteIndex get the write index
func (*ByteBuf) MarkedBytesReaded ¶
func (b *ByteBuf) MarkedBytesReaded()
MarkedBytesReaded reset reader index
func (*ByteBuf) PeekByte ¶
PeekByte get byte value from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) PeekInt ¶
PeekInt get int value from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) PeekN ¶
PeekN get bytes from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) ReadAll ¶
ReadAll read all data from buf It's will copy the data to a new byte arrary return readedBytesCount, byte array, error
func (*ByteBuf) ReadBytes ¶
ReadBytes read bytes from buf It's will copy the data to a new byte arrary return readedBytesCount, byte array, error
func (*ByteBuf) ReadFrom ¶
ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with ErrTooLarge.
func (*ByteBuf) ReadMarkedBytes ¶
ReadMarkedBytes read data from buf in the range [readerIndex, markedIndex)
func (*ByteBuf) ReadRawBytes ¶
ReadRawBytes read bytes from buf without mem copy Note. If used complete, you must call b.Skip(n) to reset reader index
func (*ByteBuf) ReadUInt32 ¶
ReadUInt32 get uint32 value from buf
func (*ByteBuf) ReadUInt64 ¶
ReadUInt64 get uint64 value from buf
func (*ByteBuf) SetReaderIndex ¶
SetReaderIndex set the read index
func (*ByteBuf) SetWriterIndex ¶
SetWriterIndex set the write index
func (*ByteBuf) Write ¶
Write appends the contents of p to the buffer, growing the buffer as needed.
func (*ByteBuf) WriteByteBuf ¶
WriteByteBuf write all readable data to this buf
func (*ByteBuf) WriteInt ¶
WriteInt write int value to buf using big order return write bytes count, error
func (*ByteBuf) WriteInt64 ¶
WriteInt64 write int64 value to buf using big order return write bytes count, error
func (*ByteBuf) WriteString ¶
WriteString write a string value to buf
func (*ByteBuf) WriteUint64 ¶
WriteUint64 write uint64 value to buf using big order return write bytes count, error
type ClientOption ¶
type ClientOption func(*clientOptions)
ClientOption option of client side
func WithClientConnectTimeout ¶
func WithClientConnectTimeout(timeout time.Duration) ClientOption
WithClientConnectTimeout option of timeout to connect to server
func WithClientDecoder ¶
func WithClientDecoder(decoder Decoder) ClientOption
WithClientDecoder option of client's decoder
func WithClientEncoder ¶
func WithClientEncoder(encoder Encoder) ClientOption
WithClientEncoder option of client's encoder
func WithClientMiddleware ¶
func WithClientMiddleware(middlewares ...Middleware) ClientOption
WithClientMiddleware option of handle write timeout
func WithClientReadBufSize ¶
func WithClientReadBufSize(readBufSize int) ClientOption
WithClientReadBufSize option of client's read buf size
func WithClientWriteBufSize ¶
func WithClientWriteBufSize(writeBufSize int) ClientOption
WithClientWriteBufSize option of client's write buf size
func WithClientWriteTimeoutHandler ¶
func WithClientWriteTimeoutHandler(timeout time.Duration, handler func(string, IOSession), timeWheel *TimeoutWheel) ClientOption
WithClientWriteTimeoutHandler option of handle write timeout
type ConnStatusHandler ¶
type ConnStatusHandler interface { ConnectFailed(addr string, err error) Connected(addr string, conn IOSession) }
ConnStatusHandler handler for conn status
type Decoder ¶
Decoder decoder interface
func NewIntLengthFieldBasedDecoder ¶
NewIntLengthFieldBasedDecoder create a IntLengthFieldBasedDecoder
func NewIntLengthFieldBasedDecoderSize ¶
func NewIntLengthFieldBasedDecoderSize(base Decoder, lengthFieldOffset, lengthAdjustment, initialBytesToStrip int) Decoder
NewIntLengthFieldBasedDecoderSize create a IntLengthFieldBasedDecoder initialBytesToStrip + lengthFieldOffset + 4(length) lengthAdjustment, some case as below: 1. 0 : base decoder received: body 2. -4: base decoder received: 4(length) + body 3. -(4 + lengthFieldOffset): base decoder received: lengthFieldOffset + 4(length) + body 4. -(4 + lengthFieldOffset + initialBytesToStrip): base decoder received: initialBytesToStrip + lengthFieldOffset + 4(length)
type Encoder ¶
Encoder encode interface
func NewIntLengthFieldBasedEncoder ¶
NewIntLengthFieldBasedEncoder returns a encoder with base
type IDGenerator ¶
type IDGenerator interface {
NewID() interface{}
}
IDGenerator ID Generator interface
func NewInt64IDGenerator ¶
func NewInt64IDGenerator() IDGenerator
NewInt64IDGenerator create a uuid v4 generator
func NewUUIDV4IdGenerator ¶
func NewUUIDV4IdGenerator() IDGenerator
NewUUIDV4IdGenerator create a uuid v4 generator
type IOSession ¶
type IOSession interface { ID() interface{} Hash() int Close() error IsConnected() bool Connect() (bool, error) Read() (interface{}, error) ReadTimeout(timeout time.Duration) (interface{}, error) Write(msg interface{}) error WriteAndFlush(msg interface{}) error Flush() error InBuf() *ByteBuf OutBuf() *ByteBuf SetAttr(key string, value interface{}) GetAttr(key string) interface{} RemoteAddr() string RemoteIP() string }
IOSession session
func NewConnector ¶
func NewConnector(svrAddr string, opts ...ClientOption) IOSession
NewConnector create a new connector with opts
type IOSessionPool ¶
type IOSessionPool interface { // Get returns a new connection from the pool. Closing the connections puts // it back to the Pool. Closing it when the pool is destroyed or full will // be counted as an error. Get() (IOSession, error) // Put puts the connection back to the pool. If the pool is full or closed, // conn is simply closed. A nil conn will be rejected. Put(IOSession) error // Close closes the pool and all its connections. After Close() the pool is // no longer usable. Close() // Len returns the current number of connections of the pool. Len() int }
IOSessionPool interface describes a pool implementation. A pool should have maximum capacity. An ideal pool is threadsafe and easy to use.
func NewIOSessionPool ¶
func NewIOSessionPool(initialCap, maxCap int, factory Factory) (IOSessionPool, error)
NewIOSessionPool returns a new pool based on buffered channels with an initial capacity and maximum capacity. Factory is used when initial capacity is greater than zero to fill the pool. A zero initialCap doesn't fill the Pool until a new Get() is called. During a Get(), If there is no new connection available in the pool, a new connection will be created via the Factory() method.
type Int64IDGenerator ¶
type Int64IDGenerator struct {
// contains filtered or unexported fields
}
Int64IDGenerator int64 id Generator
type IntLengthFieldBasedDecoder ¶
type IntLengthFieldBasedDecoder struct {
// contains filtered or unexported fields
}
IntLengthFieldBasedDecoder decoder based on length filed + data
type IntLengthFieldBasedEncoder ¶
type IntLengthFieldBasedEncoder struct {
// contains filtered or unexported fields
}
IntLengthFieldBasedEncoder encoder based on length filed + data
func (*IntLengthFieldBasedEncoder) Encode ¶
func (encoder *IntLengthFieldBasedEncoder) Encode(data interface{}, out *ByteBuf) error
Encode encode
type MessageReader ¶
type MessageReader interface { Read() (interface{}, error) ReadTimeout(timeout time.Duration) (interface{}, error) }
MessageReader is a message reader
type MessageWriter ¶
type MessageWriter interface {
Write(msg interface{}) error
}
MessageWriter is a message writer
type Middleware ¶
type Middleware interface { PreRead(conn IOSession) (bool, interface{}, error) PostRead(msg interface{}, conn IOSession) (bool, interface{}, error) PreWrite(msg interface{}, conn IOSession) (bool, interface{}, error) PostWrite(msg interface{}, conn IOSession) (bool, error) Closed(conn IOSession) Connected(conn IOSession) WriteError(err error, conn IOSession) ReadError(err error, conn IOSession) error }
Middleware goetty middleware
func NewSyncProtocolClientMiddleware ¶
func NewSyncProtocolClientMiddleware(bizDecoder Decoder, bizEncoder Encoder, writer func(IOSession, interface{}) error, maxReadTimeouts int) Middleware
NewSyncProtocolClientMiddleware return a middleware to process sync protocol
func NewSyncProtocolServerMiddleware ¶
func NewSyncProtocolServerMiddleware(bizDecoder Decoder, bizEncoder Encoder, writer func(IOSession, interface{}) error) Middleware
NewSyncProtocolServerMiddleware return a middleware to process sync protocol
type OffsetQueue ¶
OffsetQueue is a queue for sync.
func (*OffsetQueue) Add ¶
func (q *OffsetQueue) Add(item interface{}) uint64
Add add a item to the queue
func (*OffsetQueue) Get ¶
func (q *OffsetQueue) Get(offset uint64) ([]interface{}, uint64)
Get returns all the items after the offset, and remove all items before this offset
func (*OffsetQueue) GetMaxOffset ¶
func (q *OffsetQueue) GetMaxOffset() uint64
GetMaxOffset returns the max offset in the queue
type Option ¶
type Option func(*opts)
Option is a configuration option to NewTimeoutWheel
func WithBucketsExponent ¶
WithBucketsExponent sets the number of buckets in the hash table.
func WithLocksExponent ¶
WithLocksExponent sets the number locks in the lockpool used to lock the time buckets. If the number is greater than the number of buckets, the number of buckets will be used instead.
func WithTickInterval ¶
WithTickInterval sets the frequency of ticks.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server tcp server
func (*Server) GetSession ¶
GetSession get session by id
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption option of server side
func WithServerDecoder ¶
func WithServerDecoder(decoder Decoder) ServerOption
WithServerDecoder option of server's decoder
func WithServerEncoder ¶
func WithServerEncoder(encoder Encoder) ServerOption
WithServerEncoder option of server's encoder
func WithServerIDGenerator ¶
func WithServerIDGenerator(generator IDGenerator) ServerOption
WithServerIDGenerator option of server's id generator
func WithServerMiddleware ¶
func WithServerMiddleware(middlewares ...Middleware) ServerOption
WithServerMiddleware option of handle write timeout
func WithServerReadBufSize ¶
func WithServerReadBufSize(readBufSize int) ServerOption
WithServerReadBufSize option of server's read buf size
func WithServerWriteBufSize ¶
func WithServerWriteBufSize(writeBufSize int) ServerOption
WithServerWriteBufSize option of server's write buf size
type StringCodec ¶
type StringCodec struct{}
StringCodec a simple string encoder and decoder
func (*StringCodec) Decode ¶
func (codec *StringCodec) Decode(in *ByteBuf) (bool, interface{}, error)
Decode decode
func (*StringCodec) Encode ¶
func (codec *StringCodec) Encode(data interface{}, out *ByteBuf) error
Encode encode
type SyncCodec ¶
type SyncCodec struct{}
SyncCodec sync protocol dercoder and encoder
type SyncPool ¶
type SyncPool struct {
// contains filtered or unexported fields
}
SyncPool is a sync.Pool base slab allocation memory pool
func NewSyncPool ¶
NewSyncPool create a sync.Pool base slab allocation memory pool. minSize is the smallest chunk size. maxSize is the lagest chunk size. factor is used to control growth of chunk size.
type Timeout ¶
type Timeout struct {
// contains filtered or unexported fields
}
Timeout represents a single timeout function pending expiration.
type TimeoutWheel ¶
type TimeoutWheel struct {
// contains filtered or unexported fields
}
TimeoutWheel is a bucketed collection of Timeouts that have a deadline in the future. (current tick granularity is 1ms).
func NewTimeoutWheel ¶
func NewTimeoutWheel(options ...Option) *TimeoutWheel
NewTimeoutWheel creates and starts a new TimeoutWheel collection.
func (*TimeoutWheel) Schedule ¶
func (t *TimeoutWheel) Schedule( d time.Duration, expireCb func(interface{}), arg interface{}, ) (Timeout, error)
Schedule adds a new function to be called after some duration of time has elapsed. The returned Timeout can be used to cancel calling the function. If the duration falls between two ticks, the latter tick is used.
func (*TimeoutWheel) Start ¶
func (t *TimeoutWheel) Start()
Start starts a stopped timeout wheel. Subsequent calls to Start panic.
func (*TimeoutWheel) Stop ¶
func (t *TimeoutWheel) Stop()
Stop stops tick processing, and deletes any remaining timeouts.
type UUID ¶
type UUID [16]byte
UUID representation compliant with specification described in RFC 4122.
func FromBytes ¶
FromBytes returns UUID converted from raw byte slice input. It will return error if the slice isn't 16 bytes long.
func FromBytesOrNil ¶
FromBytesOrNil returns UUID converted from raw byte slice input. Same behavior as FromBytes, but returns a Nil UUID on error.
func FromString ¶
FromString returns UUID parsed from string input. Input is expected in a form accepted by UnmarshalText.
func FromStringOrNil ¶
FromStringOrNil returns UUID parsed from string input. Same behavior as FromString, but returns a Nil UUID on error.
func (UUID) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (UUID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by String.
func (*UUID) Scan ¶
Scan implements the sql.Scanner interface. A 16-byte slice is handled by UnmarshalBinary, while a longer byte slice or a string is handled by UnmarshalText.
func (*UUID) SetVariant ¶
func (u *UUID) SetVariant()
SetVariant sets variant bits as described in RFC 4122.
func (UUID) String ¶
Returns canonical string representation of UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. It will return error if the slice isn't 16 bytes long.
func (*UUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. Following formats are supported: "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"