Documentation ¶
Overview ¶
Package base ...
Index ¶
- Constants
- Variables
- func AddFileLine(header string, skip uint) string
- func AddPrefixPerLine(text string, prefix string) string
- func BytesToStringUnsafe(bytes []byte) (ret string)
- func ConcatString(args ...string) string
- func ConvertOrdinalToString(n uint) string
- func ConvertToIsoDateString(date time.Time) string
- func DecryptSessionEndpoint(sessionEndpoint string) (uint64, uint64, bool)
- func EncryptSessionEndpoint(gatewayID uint64, sessionID uint64) (string, bool)
- func GetClientTLSConfig(verifyServerCert bool, caFiles []string) (*tls.Config, error)
- func GetFileLine(skip uint) string
- func GetRandString(strLen int) string
- func GetSeed() int64
- func GetServerTLSConfig(certFile string, keyFile string) (*tls.Config, error)
- func IsNil(val interface{}) (ret bool)
- func IsTCPPortOccupied(port uint16) bool
- func IsTimeApproximatelyEqual(t1 time.Time, t2 time.Time) bool
- func MaxInt(v1 int, v2 int) int
- func MaxInt64(v1 int64, v2 int64) int64
- func MinInt(v1 int, v2 int) int
- func MinInt64(v1 int64, v2 int64) int64
- func NewAssert(t interface{ ... }) func(args ...interface{}) *Assert
- func NewLogger(isLogToScreen bool, outFile string) (*Logger, *Error)
- func PublishPanic(err *Error)
- func ReadFromFile(filePath string) (string, error)
- func RunWithCatchPanic(fn func()) (ret interface{})
- func RunWithLogOutput(fn func()) string
- func StringToBytesUnsafe(s string) (ret []byte)
- func TimeNow() time.Time
- func TimeNowISOString() string
- func WaitWhileRunning(startNS int64, isRunning func() bool, duration time.Duration)
- type Assert
- type Error
- func DefineActionError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func DefineConfigError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func DefineDevelopError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func DefineKernelError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func DefineNetError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func DefineSecurityError(idx ErrorIndex, level ErrorLevel, msg string) *Error
- func NewError(code uint32, message string) *Error
- func RunWithSubscribePanic(fn func()) *Error
- func (p *Error) AddDebug(debug string) *Error
- func (p *Error) Error() string
- func (p *Error) GetCode() uint32
- func (p *Error) GetIndex() ErrorIndex
- func (p *Error) GetLevel() ErrorLevel
- func (p *Error) GetMessage() string
- func (p *Error) GetType() ErrorType
- func (p *Error) ReportString(machineID uint64, sessionID uint64) string
- func (p *Error) Standardize() *Error
- type ErrorIndex
- type ErrorLevel
- type ErrorType
- type GlobalID
- type IORCService
- type Logger
- type ORCManager
- type PanicSubscription
- type PerformanceIndicator
- type SpeedCounter
- type StringBuilder
- func (p *StringBuilder) AppendByte(byte byte)
- func (p *StringBuilder) AppendBytes(bytes []byte)
- func (p *StringBuilder) AppendString(str string)
- func (p *StringBuilder) IsEmpty() bool
- func (p *StringBuilder) Merge(builder *StringBuilder)
- func (p *StringBuilder) Release()
- func (p *StringBuilder) Reset()
- func (p *StringBuilder) String() string
- type SyncPool
- type SyncPoolDebug
Constants ¶
const ( // ErrorTypeConfig ... ErrorTypeConfig = ErrorType(1) // ErrorTypeNet ... ErrorTypeNet = ErrorType(2) // ErrorTypeAction ... ErrorTypeAction = ErrorType(3) // ErrorTypeDevelop ... ErrorTypeDevelop = ErrorType(4) // ErrorTypeKernel ... ErrorTypeKernel = ErrorType(5) // ErrorTypeSecurity .. ErrorTypeSecurity = ErrorType(6) )
const ( // ErrorLevelInfo ... ErrorLevelInfo = ErrorLevel(1 << 0) // ErrorLevelWarn ... ErrorLevelWarn = ErrorLevel(1 << 1) // ErrorLevelError ... ErrorLevelError = ErrorLevel(1 << 2) // ErrorLevelFatal ... ErrorLevelFatal = ErrorLevel(1 << 3) // ErrorLogAll ... ErrorLogAll = ErrorLevelInfo | ErrorLevelWarn | ErrorLevelError | ErrorLevelFatal )
const ErrNetClosingSuffix = "use of closed network connection"
ErrNetClosingSuffix ...
Variables ¶
var ( // ErrStream ... ErrStream = DefineSecurityError( generalErrorSeg|1, ErrorLevelWarn, "stream error", ) // ErrUnsupportedValue ... ErrUnsupportedValue = DefineDevelopError( generalErrorSeg|2, ErrorLevelError, "", ) // ErrServiceName ... * ErrServiceName = DefineDevelopError( generalErrorSeg|3, ErrorLevelFatal, "", ) // ErrServiceIsNil ... * ErrServiceIsNil = DefineDevelopError( generalErrorSeg|4, ErrorLevelFatal, "service is nil", ) // ErrServiceOverflow ... * ErrServiceOverflow = DefineDevelopError( generalErrorSeg|5, ErrorLevelFatal, "", ) // ErrActionName ... * ErrActionName = DefineDevelopError( generalErrorSeg|6, ErrorLevelFatal, "", ) // ErrActionHandler ... * ErrActionHandler = DefineDevelopError( generalErrorSeg|7, ErrorLevelFatal, "", ) // ErrActionCloseTimeout ... * ErrActionCloseTimeout = DefineDevelopError( generalErrorSeg|8, ErrorLevelError, "", ) // ErrAction ... ErrAction = DefineActionError( generalErrorSeg|9, ErrorLevelError, "", ) // ErrActionPanic ... ErrActionPanic = DefineDevelopError( generalErrorSeg|10, ErrorLevelFatal, "", ) // ErrTargetNotExist ... ErrTargetNotExist = DefineSecurityError( generalErrorSeg|11, ErrorLevelError, "", ) // ErrCallOverflow ... ErrCallOverflow = DefineSecurityError( generalErrorSeg|12, ErrorLevelError, "", ) // ErrArgumentsNotMatch ... ErrArgumentsNotMatch = DefineSecurityError( generalErrorSeg|13, ErrorLevelError, "", ) // ErrRuntimeIllegalInCurrentGoroutine ... ErrRuntimeIllegalInCurrentGoroutine = DefineDevelopError( generalErrorSeg|14, ErrorLevelFatal, "Runtime is illegal in current goroutine", ) // ErrRuntimeReplyHasBeenCalled ... ErrRuntimeReplyHasBeenCalled = DefineDevelopError( generalErrorSeg|15, ErrorLevelError, "Runtime.Reply has been called before", ) // ErrRuntimePostEndpoint ... ErrRuntimePostEndpoint = DefineDevelopError( generalErrorSeg|16, ErrorLevelFatal, "Runtime.Post endpoint parse error", ) // ErrRuntimeExternalReturn ... ErrRuntimeExternalReturn = DefineDevelopError( generalErrorSeg|17, ErrorLevelError, "action must be return through Runtime.OK or Runtime.Error", ) // ErrRTArrayIndexOverflow ... ErrRTArrayIndexOverflow = DefineDevelopError( generalErrorSeg|18, ErrorLevelFatal, "", ) // ErrRTMapNameNotFound ... ErrRTMapNameNotFound = DefineDevelopError( generalErrorSeg|19, ErrorLevelFatal, "", ) // ErrNumOfThreadsIsWrong ... * ErrNumOfThreadsIsWrong = DefineConfigError( generalErrorSeg|20, ErrorLevelFatal, "numOfThreads is wrong", ) // ErrThreadBufferSizeIsWrong ... * ErrThreadBufferSizeIsWrong = DefineConfigError( generalErrorSeg|21, ErrorLevelFatal, "threadBufferSize is wrong", ) // ErrMaxNodeDepthIsWrong ... * ErrMaxNodeDepthIsWrong = DefineConfigError( generalErrorSeg|22, ErrorLevelFatal, "maxNodeDepth is wrong", ) // ErrCacheMkdirAll ... * ErrCacheMkdirAll = DefineConfigError( generalErrorSeg|23, ErrorLevelFatal, "create directory error", ) // ErrCacheWriteFile ... * ErrCacheWriteFile = DefineConfigError( generalErrorSeg|24, ErrorLevelFatal, "write to file error", ) )
var ( // ErrFnCacheIllegalKindString ... * ErrFnCacheIllegalKindString = DefineKernelError( coreErrorSeg|1, ErrorLevelFatal, "", ) // ErrFnCacheDuplicateKindString ... * ErrFnCacheDuplicateKindString = DefineKernelError( coreErrorSeg|2, ErrorLevelFatal, "", ) // ErrProcessorMaxCallDepthIsWrong ... * ErrProcessorMaxCallDepthIsWrong = DefineKernelError( coreErrorSeg|4, ErrorLevelFatal, "maxCallDepth is wrong", ) // ErrProcessorNodeMetaIsNil ... * ErrProcessorNodeMetaIsNil = DefineKernelError( coreErrorSeg|5, ErrorLevelFatal, "node meta is nil", ) // ErrProcessorActionMetaIsNil ... * ErrProcessorActionMetaIsNil = DefineKernelError( coreErrorSeg|6, ErrorLevelFatal, "action meta is nil", ) // ErrThreadEvalFatal ... ErrThreadEvalFatal = DefineKernelError( coreErrorSeg|7, ErrorLevelFatal, "", ) // ErrProcessorIsNotRunning ... * ErrProcessorIsNotRunning = DefineKernelError( coreErrorSeg|8, ErrorLevelFatal, "processor is not running", ) // ErrLogOpenFile ... ErrLogOpenFile = DefineKernelError( coreErrorSeg|9, ErrorLevelError, "", ) // ErrLogCloseFile ... ErrLogCloseFile = DefineKernelError( coreErrorSeg|11, ErrorLevelError, "", ) )
var ( // ErrServerAlreadyRunning ... ErrServerAlreadyRunning = DefineConfigError( serverErrorSeg|1, ErrorLevelFatal, "it is already running", ) // ErrServerNotRunning ... ErrServerNotRunning = DefineConfigError( serverErrorSeg|2, ErrorLevelFatal, "it is not running", ) // ErrServerNoListenersAvailable ... ErrServerNoListenersAvailable = DefineConfigError( serverErrorSeg|3, ErrorLevelFatal, "no listeners available on the server", ) // ErrServerSessionNotFound ... ErrServerSessionNotFound = DefineConfigError( serverErrorSeg|4, ErrorLevelWarn, "server session not found", ) // ErrServerSessionSeedOverflows ... ErrServerSessionSeedOverflows = DefineConfigError( serverErrorSeg|5, ErrorLevelWarn, "server session seed overflows", ) )
var ( // ErrClientTimeout ... ErrClientTimeout = DefineNetError( clientErrorSeg|1, ErrorLevelWarn, "timeout", ) // ErrClientConfig ... ErrClientConfig = DefineConfigError( clientErrorSeg|2, ErrorLevelWarn, "client config error", ) )
var ( // ErrRouterIDInvalid ... ErrRouterIDInvalid = DefineNetError( routerErrorSeg|1, ErrorLevelFatal, "", ) // ErrRouterConnDial ... ErrRouterConnDial = DefineNetError( routerErrorSeg|2, ErrorLevelWarn, "", ) // ErrRouterConnConnect ... ErrRouterConnConnect = DefineNetError( routerErrorSeg|3, ErrorLevelFatal, "", ) // ErrRouterConnRead ... ErrRouterConnRead = DefineNetError( routerErrorSeg|4, ErrorLevelWarn, "", ) // ErrRouterConnWrite ... ErrRouterConnWrite = DefineNetError( routerErrorSeg|5, ErrorLevelWarn, "", ) // ErrRouterConnProtocol ... ErrRouterConnProtocol = DefineNetError( routerErrorSeg|6, ErrorLevelWarn, "", ) // ErrRouterConnListen ... ErrRouterConnListen = DefineNetError( routerErrorSeg|7, ErrorLevelFatal, "", ) // ErrRouterConnClose ... ErrRouterConnClose = DefineNetError( routerErrorSeg|8, ErrorLevelFatal, "", ) )
var ( // ErrUnsupportedProtocol ... ErrUnsupportedProtocol = DefineNetError( goAdapterErrorSeg|1, ErrorLevelFatal, "", ) // ErrSyncTCPServerServiceListen ... ErrSyncTCPServerServiceListen = DefineNetError( goAdapterErrorSeg|2, ErrorLevelFatal, "", ) // ErrSyncTCPServerServiceAccept ... ErrSyncTCPServerServiceAccept = DefineNetError( goAdapterErrorSeg|3, ErrorLevelFatal, "", ) // ErrSyncTCPServerServiceClose ... ErrSyncTCPServerServiceClose = DefineNetError( goAdapterErrorSeg|4, ErrorLevelFatal, "", ) // ErrSyncWSServerServiceListen ... ErrSyncWSServerServiceListen = DefineNetError( goAdapterErrorSeg|5, ErrorLevelFatal, "", ) // ErrSyncWSServerServiceUpgrade ... ErrSyncWSServerServiceUpgrade = DefineNetError( goAdapterErrorSeg|6, ErrorLevelFatal, "", ) // ErrSyncWSServerServiceServe ... ErrSyncWSServerServiceServe = DefineNetError( goAdapterErrorSeg|7, ErrorLevelFatal, "", ) // ErrSyncWSServerServiceClose ... ErrSyncWSServerServiceClose = DefineNetError( goAdapterErrorSeg|8, ErrorLevelFatal, "", ) // ErrSyncClientServiceDial ... ErrSyncClientServiceDial = DefineNetError( goAdapterErrorSeg|9, ErrorLevelWarn, "", ) // ErrConnClose ... ErrConnClose = DefineNetError( goAdapterErrorSeg|10, ErrorLevelWarn, "", ) // ErrConnRead ... ErrConnRead = DefineNetError( goAdapterErrorSeg|11, ErrorLevelWarn, "", ) // ErrConnWrite ... ErrConnWrite = DefineNetError( goAdapterErrorSeg|12, ErrorLevelWarn, "", ) // ErrOnFillWriteFatal ... ErrOnFillWriteFatal = DefineKernelError( goAdapterErrorSeg|13, ErrorLevelFatal, "kernel error", ) )
Functions ¶
func AddPrefixPerLine ¶
AddPrefixPerLine ...
func BytesToStringUnsafe ¶
BytesToStringUnsafe ...
func ConvertToIsoDateString ¶
ConvertToIsoDateString convert time.Time to iso string return format "2019-09-09T09:47:16.180+08:00"
func DecryptSessionEndpoint ¶
DecryptSessionEndpoint ...
func EncryptSessionEndpoint ¶
EncryptSessionEndpoint ...
func GetClientTLSConfig ¶ added in v0.0.3
GetClientTLSConfig ...
func GetServerTLSConfig ¶ added in v0.0.3
GetServerTLSConfig ...
func IsTimeApproximatelyEqual ¶
IsTimeApproximatelyEqual ...
func NewAssert ¶
func NewAssert(t interface{ Fail() }) func(args ...interface{}) *Assert
NewAssert ...
func TimeNowISOString ¶
func TimeNowISOString() string
TimeNowISOString get now iso string like this: 2019-09-09T09:47:16.180+08:00
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error ...
func DefineActionError ¶
func DefineActionError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineActionError ...
func DefineConfigError ¶
func DefineConfigError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineConfigError ...
func DefineDevelopError ¶
func DefineDevelopError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineDevelopError ...
func DefineKernelError ¶
func DefineKernelError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineKernelError ...
func DefineNetError ¶
func DefineNetError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineNetError ...
func DefineSecurityError ¶
func DefineSecurityError(idx ErrorIndex, level ErrorLevel, msg string) *Error
DefineSecurityError ...
func (*Error) ReportString ¶ added in v0.0.2
type GlobalID ¶ added in v0.0.2
type GlobalID struct {
// contains filtered or unexported fields
}
GlobalID ...
type Logger ¶ added in v0.0.2
type Logger struct {
// contains filtered or unexported fields
}
Logger ...
type ORCManager ¶
type ORCManager struct {
// contains filtered or unexported fields
}
ORCManager ...
func (*ORCManager) Close ¶
func (p *ORCManager) Close(willClose func(), didClose func()) bool
Close close the ORCManager willClose will be called immediately if ORCManager is opened correctly. didClose will be called when ORCManager is opened correctly and all onRun functions (if present) have completed
func (*ORCManager) IsClosed ¶ added in v0.0.2
func (p *ORCManager) IsClosed() bool
func (*ORCManager) IsClosing ¶ added in v0.0.2
func (p *ORCManager) IsClosing() bool
func (*ORCManager) IsRunning ¶ added in v0.0.2
func (p *ORCManager) IsRunning() bool
type PanicSubscription ¶
type PanicSubscription struct {
// contains filtered or unexported fields
}
PanicSubscription ...
func SubscribePanic ¶
func SubscribePanic(onPanic func(*Error)) *PanicSubscription
SubscribePanic ...
type PerformanceIndicator ¶
type PerformanceIndicator struct {
// contains filtered or unexported fields
}
PerformanceIndicator ...
func NewPerformanceIndicator ¶
func NewPerformanceIndicator() *PerformanceIndicator
NewPerformanceIndicator ...
type SpeedCounter ¶
type SpeedCounter struct {
// contains filtered or unexported fields
}
SpeedCounter count the speed
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder high performance string builder
func NewStringBuilder ¶
func NewStringBuilder() *StringBuilder
NewStringBuilder create a string builder
func (*StringBuilder) AppendByte ¶
func (p *StringBuilder) AppendByte(byte byte)
AppendByte append byte to the buffer
func (*StringBuilder) AppendBytes ¶
func (p *StringBuilder) AppendBytes(bytes []byte)
AppendBytes append bytes to the buffer
func (*StringBuilder) AppendString ¶
func (p *StringBuilder) AppendString(str string)
AppendString append a string to string builder
func (*StringBuilder) IsEmpty ¶
func (p *StringBuilder) IsEmpty() bool
IsEmpty return is the string builder is empty
func (*StringBuilder) Merge ¶
func (p *StringBuilder) Merge(builder *StringBuilder)
Merge write a string builder to current string builder
func (*StringBuilder) String ¶
func (p *StringBuilder) String() string
String get the builder string
type SyncPoolDebug ¶
type SyncPoolDebug struct { New func() interface{} // contains filtered or unexported fields }
SyncPoolDebug ...