Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(encrypted []byte, key []byte) ([]byte, error)
- func AesDecryptBase64(encryptedBase64 string, keyBase64 string) ([]byte, error)
- func AesEncrypt(origData []byte, key []byte) ([]byte, error)
- func AesEncryptBase64(origData []byte, keyBase64 string) (string, error)
- func ConfigLogger(cfg *LogConf, printFunc func(lv LogLv, logStr string))
- func Crc16CheckSum(data []byte) (uint16, error)
- func Daemon(program string, args []string, restartDelay uint16, shutdownFile string) error
- func EcdsaGenerateKey(ellType ElliptcType) (pubKey []byte, priKey []byte, err error)
- func EcdsaGenerateKeyPem(ellType ElliptcType) (pemPubKey string, pemPriKey string, err error)
- func EcdsaSign(origData []byte, priKey []byte) ([]byte, []byte, error)
- func EcdsaSignPem(origData []byte, pemPriKey string) ([]byte, []byte, error)
- func EcdsaVerify(origData []byte, rText []byte, sText []byte, pubKey []byte) (bool, error)
- func EcdsaVerifyPem(origData []byte, rText []byte, sText []byte, pemPubKey string) (bool, error)
- func FormatInt(num int64, maxLength uint32, bFillZero bool, builder *strings.Builder) string
- func FormatTimeStr(format string, t time.Time, builder *strings.Builder) (string, error)
- func FormatUint(num uint64, maxLength uint32, bFillZero bool, builder *strings.Builder) string
- func GetClassName(classReflectName string) string
- func GetClassReflectName(obj interface{}) (string, error)
- func GetFilePackageClassName(classReflectName string) string
- func GetFilePackageName(fullPackName string) string
- func GetFileSize(path string) (int64, error)
- func GetFullPackageName(classReflectName string) string
- func GetReflectNameByType(t reflect.Type) string
- func IsFileExist(path string) (bool, error)
- func LoadJsonConf(v interface{}, path string, decodeCb func(data []byte) ([]byte, error)) error
- func LogArgs(a ...interface{}) []interface{}
- func PKCS7Padding(origData []byte, blockSize int) []byte
- func PKCS7Unpadding(decrypted []byte) ([]byte, error)
- func PowerOfTen(power uint32) uint64
- func ProtectRun(entry func())
- func Random(min int, max int) int
- func RandomIntn(n int) int
- func RsaDecrypt(encrypted []byte, priKey []byte) ([]byte, error)
- func RsaDecryptPem(encrypted []byte, pemPriKey string) ([]byte, error)
- func RsaEncrypt(origData []byte, pubKey []byte) ([]byte, error)
- func RsaEncryptPem(origData []byte, pemPubKey string) ([]byte, error)
- func RsaGenerateKey(bits int) (pubKey []byte, priKey []byte, err error)
- func RsaGenerateKeyPem(bits int) (pemPubKey string, pemPriKey string, err error)
- func RsaSign(origData []byte, priKey []byte) ([]byte, error)
- func RsaSignPem(origData []byte, pemPriKey string) ([]byte, error)
- func RsaVerify(origData []byte, signData []byte, pubKey []byte) (bool, error)
- func RsaVerifyPem(origData []byte, signData []byte, pemPubKey string) (bool, error)
- func RunDangerCode(entry func(), bDebugMode bool)
- func SendMail(m *Mail) error
- func SetLogLevel(lv LogLv)
- func SetPrintFunc(printFunc func(lv LogLv, logStr string))
- func StartDumpLog(file string, dumpFileSize int, dumpThreshold int, dumpIntervalMs uint32)
- func StartDumpLogDefault(file string)
- func StartLogger()
- func StopDumpLog()
- func StopLogger()
- type AsyncDispatcher
- type BaseDispatcher
- type BuffFactory
- type BuffPool
- type Dispatcher
- type ElliptcType
- type ErrCatcher
- func (c *ErrCatcher) Catch(methodName string, errRef *error)
- func (c *ErrCatcher) DeferThrow(methodName string, errRef *error)
- func (c *ErrCatcher) Throw(methodName string, err error) error
- func (c *ErrCatcher) TryCodeFunc(methodName string, f func() (int32, error)) (int32, error)
- func (c *ErrCatcher) TryFunc(methodName string, f func() error) error
- type Event
- type IdGenerator
- type InvokeInfo
- type InvokeStack
- type LinkedQueue
- type LinkedQueueNode
- type LogConf
- type LogInfo
- type LogLv
- type Logger
- type Mail
- type NotifyCenter
- func (c *NotifyCenter) AddDispatcher(msgName string, dispatcher Dispatcher)
- func (c *NotifyCenter) AddObserver(msgName string, o Observer)
- func (c *NotifyCenter) GetDispatcher(msgName string) (Dispatcher, bool)
- func (c *NotifyCenter) Notify(msgName string, params ...interface{})
- func (c *NotifyCenter) RemoveDispatcher(msgName string)
- func (c *NotifyCenter) RemoveObserver(msgName string, o Observer)
- type NotifyMsg
- type ObjectFactory
- func (f *ObjectFactory) CreateObject(name string) (interface{}, error)
- func (f *ObjectFactory) GetReflectType(name string) (reflect.Type, bool)
- func (f *ObjectFactory) RegisterObject(obj interface{}, newFunc func() interface{}, maxPoolCapacity uint64) (string, error)
- func (f *ObjectFactory) ReuseObject(v interface{}, name string) error
- type Observer
- type Queue
- type Set
- type SetType
- type SimpleBuffer
- func (buff *SimpleBuffer) GetData() []byte
- func (buff *SimpleBuffer) GetDataLen() int
- func (buff *SimpleBuffer) GetWriteBuff() []byte
- func (buff *SimpleBuffer) GetWriteBuffSize() int
- func (buff *SimpleBuffer) MoveDataToBegin()
- func (buff *SimpleBuffer) Read(b []byte) (n int, err error)
- func (buff *SimpleBuffer) SimulateRead(b []byte) (n int, err error)
- func (buff *SimpleBuffer) Skip(skipLen uint32)
- func (buff *SimpleBuffer) UpdateWriteOffset(addLen uint32)
- type SyncDispatcher
- type SyncLimitQueue
- type SyncLinkedQueue
Constants ¶
const ( BP_MIN_BUFF_SIZE = 64 BP_MAX_BUFF_SIZE = 4 * 1024 BP_QUEUE_STEP = 64 )
const ( LOG_BATCH_DUMP_COUNT = 100 LOG_MAX_CACHE_SIZE = 64 * 1024 LOG_DEFAULT_DUMP_SIZE = 32 * 1024 * 1024 LOG_DEFAULT_DUMP_THRESHOLD = 32 * 1024 LOG_DEFAULT_DUMP_INTV = 100 LOG_STR_BUILD_INIT_CAP = 128 )
const LOG_DEBUG_SWITCH_FILE = "debug.sf"
Variables ¶
var ( ErrAesDataLenZero = errors.New("data len is 0") ErrAesKeyLenZero = errors.New("key len is 0") ErrAesUnpaddingTooMuch = errors.New("unpadding count more than data len") )
var ( ErrEcdsaDataLenZero = errors.New("data len is 0") ErrEcdsaKeyLenZero = errors.New("key len is 0") ErrEcdsaParsePubKeyFail = errors.New("parse public key failed") )
var ( ErrEvtWaitTimeout = errors.New("event wait time out") ErrEvtClosed = errors.New("event closed") )
var ( ErrObjFactObjIsNil = errors.New("object is nil") ErrObjFactWsExist = errors.New("object workshop is exist") ErrObjFactWsNotExist = errors.New("object workshop is not exist") ErrObjFactNotTheSameType = errors.New("not the same type") )
var ( ErrQueEmptyQueue = errors.New("empty queue") ErrQueFullQueue = errors.New("full queue") )
var ( ErrRsaDataLenZero = errors.New("data len is 0") ErrRsaKeyLenZero = errors.New("key len is 0") )
var ( ErrNoSpaceToRead = errors.New("no space to read data") ErrBuffEmpty = errors.New("buffer empty") ErrReachEnd = errors.New("buffer reach end") )
var ( ErrUtilObjIsNil = errors.New("object is nil") ErrWrongTimeFormat = errors.New("wrong time format") )
var (
ErrCrc16DataLenZero = errors.New("data len is 0")
)
var (
ErrIdGenIdUseOut = errors.New("id use out")
)
var (
ErrMailIsNil = errors.New("mail is nil")
)
Functions ¶
func AesDecrypt ¶
Aes decrypt. @param encrypted, data need to decrypt. @param key, aes decrypt key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. @return []byte, original data. @return error, error.
func AesDecryptBase64 ¶
Aes decrypt with string key which encode by base64. @param encryptedBase64, data need to decrypt which encode by base64. @param keyBase64, aes decrypt key which encode by base64. @return []byte, original data. @return error, error.
func AesEncrypt ¶
Aes encrypt. @param origData, data need to encrypt. @param key, aes encrypt key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. @return []byte, data encrypted. @return error, error.
func AesEncryptBase64 ¶
Aes encrypt with string key which encode by base64. @param origData, data need to encrypt. @param keyBase64, aes encrypt key which encode by base64. @return string, data encrypted which encode by base64. @return error, error.
func ConfigLogger ¶ added in v0.1.5
func Crc16CheckSum ¶
Calculation check sum with CRC-16/MODBUS. @param data, data need to calculation check sum. @return uint16, the check sum. @return error, error.
func EcdsaGenerateKey ¶ added in v0.2.0
func EcdsaGenerateKey(ellType ElliptcType) (pubKey []byte, priKey []byte, err error)
func EcdsaGenerateKeyPem ¶ added in v0.2.0
func EcdsaGenerateKeyPem(ellType ElliptcType) (pemPubKey string, pemPriKey string, err error)
func EcdsaSignPem ¶ added in v0.2.0
func EcdsaVerify ¶ added in v0.2.0
func EcdsaVerifyPem ¶ added in v0.2.0
func FormatInt ¶ added in v0.2.1
Format integer. @param num, the number to format. @param maxLength, the max length in decimal. @param bFillZero, is fill zero to prefix. @param builder, a string builder. if not nil, only build string, not return @return string, the format string of time.
func FormatTimeStr ¶ added in v0.2.1
Format the string of time. @param format, format of the string with YY MM DD hh mm ss. @param t, the time object to format. @param builder, a string builder. if not nil, only build string, not return @return string, the format string of time. @return error, the error
func FormatUint ¶ added in v0.2.1
Format unsigned integer. @param num, the number to format. @param maxLength, the max length in decimal. @param bFillZero, is fill zero to prefix. @param builder, a string builder. if not nil, only build string, not return @return string, the format string of time.
func GetClassName ¶ added in v0.1.6
func GetClassReflectName ¶ added in v0.1.6
func GetFilePackageClassName ¶ added in v0.1.6
func GetFilePackageName ¶ added in v0.1.6
func GetFileSize ¶
Get the size of file. @param path, the file path. @return int64, the size. @return error, error.
func GetFullPackageName ¶ added in v0.1.6
func GetReflectNameByType ¶ added in v0.1.12
func IsFileExist ¶
Is the file exist. @param path, the file path. @return bool, if error is nil, true mean exist, false mean not exist. @return error, error.
func LoadJsonConf ¶ added in v0.1.2
Load config from a json file. @param v, config object. @param path, path of the json file. @param decodeCb, a callback function to decode the content of the file. @return error, error.
func PKCS7Padding ¶
func PKCS7Unpadding ¶
func PowerOfTen ¶ added in v0.2.1
Get the power of ten. @param power, the power. @return uint64, the result
func ProtectRun ¶
func ProtectRun(entry func())
Protect run, if panic, it will recover. @param entry, the function of danger code.
func Random ¶ added in v0.3.2
return a non-negative pseudo-random number in [min,max) from the default Source. It panics if max <= min.
func RandomIntn ¶ added in v0.3.2
return a non-negative pseudo-random number in [0,n) from the default Source. It panics if n <= 0.
func RsaDecryptPem ¶ added in v0.2.0
func RsaEncryptPem ¶ added in v0.2.0
func RsaGenerateKey ¶ added in v0.2.0
func RsaGenerateKeyPem ¶ added in v0.2.0
func RsaSignPem ¶ added in v0.2.0
func RsaVerifyPem ¶ added in v0.2.0
func RunDangerCode ¶
func RunDangerCode(entry func(), bDebugMode bool)
Run danger code. @param entry, the function of danger code. @param bDebugMode, true will run in normal mode, false will run in protect mode.
func SetPrintFunc ¶ added in v0.3.2
Set a new print func to instead of the default one. eg: PowerShell print.
var (
kernel32 *syscall.LazyDLL = syscall.NewLazyDLL(`kernel32.dll`) SetConsoleTextAttribute *syscall.LazyProc = nil CloseHandle *syscall.LazyProc = nil BgColor int = 0x50 FontColor Color = Color{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}
)
type Color struct { black int blue int green int cyan int red int purple int yellow int light_gray int gray int light_blue int light_green int light_cyan int light_red int light_purple int light_yellow int white int }
func PowerShellPrint(lv yx.LogLv, logStr string) { if SetConsoleTextAttribute == nil { SetConsoleTextAttribute = kernel32.NewProc(`SetConsoleTextAttribute`) } if CloseHandle == nil { CloseHandle = kernel32.NewProc(`CloseHandle`) } color := FontColor.white if lv == yx.LOG_LV_ERROR { color = FontColor.light_red } else if lv == yx.LOG_LV_WARN { color = FontColor.light_yellow } handle, _, _ := SetConsoleTextAttribute.Call(uintptr(syscall.Stdout), uintptr(BgColor|color)) fmt.Print(logStr) CloseHandle.Call(handle) }
func StartDumpLog ¶
Start dump log. @param file, the relative/full path of a file. @param dumpFileSize, max size of the dump file. @param dumpThreshold, max count of logs in buffer to cause dump. @param dumpIntervalMs, dump interval in millisecond.
func StartDumpLogDefault ¶
func StartDumpLogDefault(file string)
Start dump log by default params. @param file, the relative/full path of a file.
func StartLogger ¶ added in v0.1.4
func StartLogger()
========================
global method
========================
func StopLogger ¶ added in v0.1.4
func StopLogger()
Types ¶
type AsyncDispatcher ¶
type AsyncDispatcher struct { *BaseDispatcher // contains filtered or unexported fields }
=====================================================
AsyncDispatcher
=====================================================
func NewAsyncDispatcher ¶
func NewAsyncDispatcher(msgName string, maxMsgBuffSize uint16) *AsyncDispatcher
func (*AsyncDispatcher) Notify ¶
func (d *AsyncDispatcher) Notify(params ...interface{})
func (*AsyncDispatcher) Start ¶
func (d *AsyncDispatcher) Start()
func (*AsyncDispatcher) Stop ¶
func (d *AsyncDispatcher) Stop()
type BaseDispatcher ¶
type BaseDispatcher struct {
// contains filtered or unexported fields
}
=====================================================
BaseDispatcher
=====================================================
func NewBaseDispatcher ¶
func NewBaseDispatcher(msgName string) *BaseDispatcher
func (*BaseDispatcher) AddObserver ¶
func (d *BaseDispatcher) AddObserver(o Observer)
func (*BaseDispatcher) GetMsgName ¶
func (d *BaseDispatcher) GetMsgName() string
func (*BaseDispatcher) Notify ¶
func (d *BaseDispatcher) Notify(params ...interface{})
func (*BaseDispatcher) RemoveObserver ¶
func (d *BaseDispatcher) RemoveObserver(o Observer)
type BuffFactory ¶ added in v0.1.13
type BuffFactory struct {
// contains filtered or unexported fields
}
func NewBuffFactory ¶ added in v0.1.13
func NewBuffFactory() *BuffFactory
func (*BuffFactory) CreateBuff ¶ added in v0.1.13
func (p *BuffFactory) CreateBuff(size uint32) *[]byte
func (*BuffFactory) ReuseBuff ¶ added in v0.1.13
func (p *BuffFactory) ReuseBuff(buffRef *[]byte)
type BuffPool ¶ added in v0.1.9
type BuffPool struct {
// contains filtered or unexported fields
}
func NewBuffPool ¶ added in v0.1.9
type Dispatcher ¶
type Dispatcher interface { // Add an observer to the dispatcher. // @param o, the observer to be added. AddObserver(o Observer) // Remove an observer from the dispatcher. // @param o, the observer to be removed. RemoveObserver(o Observer) // Notify message. // @param params, the params of the message. Notify(params ...interface{}) }
type ElliptcType ¶ added in v0.2.0
type ElliptcType int
const ( ELLIPTIC_TYPE_P521 ElliptcType = iota ELLIPTIC_TYPE_P384 ELLIPTIC_TYPE_P256 ELLIPTIC_TYPE_P224 )
type ErrCatcher ¶
type ErrCatcher struct {
// contains filtered or unexported fields
}
func NewErrCatcher ¶
func NewErrCatcher(className string) *ErrCatcher
func (*ErrCatcher) Catch ¶
func (c *ErrCatcher) Catch(methodName string, errRef *error)
Catch error. @param methodName, the name of method which catch the error. @param errRef, reference of an error.
func (*ErrCatcher) DeferThrow ¶
func (c *ErrCatcher) DeferThrow(methodName string, errRef *error)
Throw error with defer. @param methodName, the name of method which throw the error. @param errRef, reference of an error.
func (*ErrCatcher) Throw ¶
func (c *ErrCatcher) Throw(methodName string, err error) error
Throw error. @param methodName, the name of method which throw the error. @param err, an error. @return error, return the same error of param err.
func (*ErrCatcher) TryCodeFunc ¶ added in v0.3.1
type Event ¶
type Event struct { C chan byte // contains filtered or unexported fields }
func (*Event) WaitUntilTimeout ¶
Wait event until timeout. @param timeoutMSec, timeout after millisecond. 0 mean check at once, only can use in one waiter scene. @return error, ErrEvtWaitTimeout mean timeout.
type IdGenerator ¶
type IdGenerator struct {
// contains filtered or unexported fields
}
func NewIdGenerator ¶
func NewIdGenerator(min uint64, max uint64) *IdGenerator
func (*IdGenerator) GetId ¶
func (g *IdGenerator) GetId() (uint64, error)
Assign an id. @return uint64, the assign id. @return error, ErrIdGenIdUseOut mean use out.
func (*IdGenerator) ReuseId ¶
func (g *IdGenerator) ReuseId(id uint64)
Reuse an id. @param id, the reuse id.
type InvokeInfo ¶
type InvokeInfo struct {
// contains filtered or unexported fields
}
func NewInvokeInfo ¶
func NewInvokeInfo(className string, methodName string) *InvokeInfo
type InvokeStack ¶
type InvokeStack = []*InvokeInfo
type LinkedQueue ¶
type LinkedQueue struct {
// contains filtered or unexported fields
}
========================
LinkedQueue
========================
func NewLinkedQueue ¶
func NewLinkedQueue() *LinkedQueue
func (*LinkedQueue) Dequeue ¶
func (q *LinkedQueue) Dequeue() (interface{}, error)
func (*LinkedQueue) Enqueue ¶
func (q *LinkedQueue) Enqueue(item interface{}) error
func (*LinkedQueue) GetSize ¶
func (q *LinkedQueue) GetSize() uint64
type LinkedQueueNode ¶
type LinkedQueueNode struct { Data interface{} Next *LinkedQueueNode }
========================
LinkedQueueNode
========================
func NewLinkedQueueNode ¶
func NewLinkedQueueNode(data interface{}) *LinkedQueueNode
type LogConf ¶ added in v0.1.5
type LogConf struct { Level int `json:"level"` // IsPowerShellRun bool `json:"power_shell_run"` IsDump bool `json:"is_dump"` DumpPath string `json:"dump_path"` DumpFileSize int `json:"dump_file_size"` DumpThreshold int `json:"dump_threshold"` DumpInterval uint32 `json:"dump_interval"` }
========================
log config
========================
type LogInfo ¶ added in v0.1.4
==============================================
logger
==============================================
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
========================
Logger
========================
type NotifyCenter ¶
type NotifyCenter struct {
// contains filtered or unexported fields
}
=====================================================
NotifyCenter
=====================================================
func NewNotifyCenter ¶
func NewNotifyCenter() *NotifyCenter
func (*NotifyCenter) AddDispatcher ¶
func (c *NotifyCenter) AddDispatcher(msgName string, dispatcher Dispatcher)
Add an dispatcher to the notify center. @param msgName, the name of message which the dispatcher will notify. @param dispatcher, the dispatcher to be added.
func (*NotifyCenter) AddObserver ¶
func (c *NotifyCenter) AddObserver(msgName string, o Observer)
Add an observer to the notify center. @param msgName, the name of message which the observer will listen to. @param o, the observer to be added.
func (*NotifyCenter) GetDispatcher ¶
func (c *NotifyCenter) GetDispatcher(msgName string) (Dispatcher, bool)
Get an dispatcher from the notify center. @param msgName, the name of message which the dispatcher is notify. @return Dispatcher, the dispatcher @return bool, true mean success, false mean failed
func (*NotifyCenter) Notify ¶
func (c *NotifyCenter) Notify(msgName string, params ...interface{})
Notify message. @param msgName, the name of message. @param params, the params of the message.
func (*NotifyCenter) RemoveDispatcher ¶
func (c *NotifyCenter) RemoveDispatcher(msgName string)
Remove an dispatcher from the notify center. @param msgName, the name of message which the dispatcher is notify.
func (*NotifyCenter) RemoveObserver ¶
func (c *NotifyCenter) RemoveObserver(msgName string, o Observer)
Remove an observer from the notify center. @param msgName, the name of message which the observer listening to. @param o, the observer to be removed.
type ObjectFactory ¶ added in v0.1.3
type ObjectFactory struct {
// contains filtered or unexported fields
}
=========================
ObjectFactory
=========================
func NewObjectFactory ¶ added in v0.1.3
func NewObjectFactory() *ObjectFactory
func (*ObjectFactory) CreateObject ¶ added in v0.1.3
func (f *ObjectFactory) CreateObject(name string) (interface{}, error)
create an object by the name. @param name, the name. @return interface{}, the object is created. @return error, the error.
func (*ObjectFactory) GetReflectType ¶ added in v0.1.3
func (f *ObjectFactory) GetReflectType(name string) (reflect.Type, bool)
Get reflect type by the name. @param name, the name. @return reflect.Type, the reflect type. @return bool, true mean success, false mean failed.
func (*ObjectFactory) RegisterObject ¶ added in v0.1.3
func (f *ObjectFactory) RegisterObject(obj interface{}, newFunc func() interface{}, maxPoolCapacity uint64) (string, error)
Register object. @param obj, the reuseabe object. @param initReuseCnt, the init count in the pool. @param maxPoolCapacity, the max count in the pool. @return error, the error.
func (*ObjectFactory) ReuseObject ¶ added in v0.1.3
func (f *ObjectFactory) ReuseObject(v interface{}, name string) error
reuse an object by the name. @param v, the object. @param name, the name. @return error, the error.
type Observer ¶
type Observer interface { // Callback when dispatcher notify message. // @param msg, the message notifying. OnNotify(msg *NotifyMsg) }
type Queue ¶
type Queue interface { // Enqueue. // @param item, item to enqueue. // @return error, error. Enqueue(item interface{}) error // Dequeue. // @return interface{}, dequeue item. // @return error, error. Dequeue() (interface{}, error) // Get queue size. // @return uint64, queue size. GetSize() uint64 }
========================
Queue
========================
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func (*Set) GetElements ¶
func (s *Set) GetElements() []interface{}
Get all items. @return []interface{}, all item array.
type SimpleBuffer ¶
type SimpleBuffer struct {
// contains filtered or unexported fields
}
func NewSimpleBuffer ¶
func NewSimpleBuffer(capacity int) *SimpleBuffer
func (*SimpleBuffer) GetData ¶
func (buff *SimpleBuffer) GetData() []byte
Get the data. @return []byte, the data.
func (*SimpleBuffer) GetDataLen ¶
func (buff *SimpleBuffer) GetDataLen() int
Get the length of data. @return int, the length of data.
func (*SimpleBuffer) GetWriteBuff ¶
func (buff *SimpleBuffer) GetWriteBuff() []byte
Get the write buffer. @return []byte, the write buffer.
func (*SimpleBuffer) GetWriteBuffSize ¶
func (buff *SimpleBuffer) GetWriteBuffSize() int
Get the size of write buffer. @return int, the size of write buffer.
func (*SimpleBuffer) MoveDataToBegin ¶
func (buff *SimpleBuffer) MoveDataToBegin()
Move the data to offset = 0.
func (*SimpleBuffer) Read ¶
func (buff *SimpleBuffer) Read(b []byte) (n int, err error)
Read data, get the data, and update the read offset. @param b, the dest buffer. @return int, the length of data has read @return error, error
func (*SimpleBuffer) SimulateRead ¶
func (buff *SimpleBuffer) SimulateRead(b []byte) (n int, err error)
Simulate reading data, only get the data, the read offset is not update. @param b, the dest buffer. @return int, the length of data has read @return error, error
func (*SimpleBuffer) Skip ¶
func (buff *SimpleBuffer) Skip(skipLen uint32)
Skip the data. @param skipLen, the length to skip.
func (*SimpleBuffer) UpdateWriteOffset ¶
func (buff *SimpleBuffer) UpdateWriteOffset(addLen uint32)
Update the write offset. @param addLen, the length to add.
type SyncDispatcher ¶
type SyncDispatcher struct {
*BaseDispatcher
}
=====================================================
SyncDispatcher
=====================================================
func NewSyncDispatcher ¶
func NewSyncDispatcher(msgName string) *SyncDispatcher
func (*SyncDispatcher) Notify ¶
func (d *SyncDispatcher) Notify(params ...interface{})
type SyncLimitQueue ¶ added in v0.1.9
type SyncLimitQueue struct { *SyncLinkedQueue // contains filtered or unexported fields }
========================
SyncLimitQueue
========================
func NewSyncLimitQueue ¶ added in v0.1.9
func NewSyncLimitQueue(maxSize uint64) *SyncLimitQueue
func (*SyncLimitQueue) Enqueue ¶ added in v0.1.9
func (q *SyncLimitQueue) Enqueue(item interface{}) error
type SyncLinkedQueue ¶
type SyncLinkedQueue struct {
// contains filtered or unexported fields
}
========================
SyncLinkedQueue
========================
func NewSyncLinkedQueue ¶
func NewSyncLinkedQueue() *SyncLinkedQueue
func (*SyncLinkedQueue) Dequeue ¶
func (q *SyncLinkedQueue) Dequeue() (interface{}, error)
func (*SyncLinkedQueue) Enqueue ¶
func (q *SyncLinkedQueue) Enqueue(item interface{}) error
func (*SyncLinkedQueue) GetSize ¶
func (q *SyncLinkedQueue) GetSize() uint64