Documentation ¶
Index ¶
- Constants
- Variables
- func AppDebug() *zerolog.Event
- func AppError() *zerolog.Event
- func AppFatal() *zerolog.Event
- func AppInfo() *zerolog.Event
- func AppPanic() *zerolog.Event
- func AppTrace() *zerolog.Event
- func AppWarn() *zerolog.Event
- func DebugEnabled() bool
- func DeleteSession(n *Session)
- func DumpDebug() *zerolog.Event
- func DumpError() *zerolog.Event
- func DumpFatal() *zerolog.Event
- func DumpInfo() *zerolog.Event
- func DumpPanic() *zerolog.Event
- func DumpTrace() *zerolog.Event
- func DumpWarn() *zerolog.Event
- func ErrorEnabled() bool
- func FatalEnabled() bool
- func GetBaseAndConfig() (base string, config string)
- func GetBasename(path string) string
- func GetBasepath(path string) string
- func GetFdFromConn(conn net.Conn) int
- func GetFdFromLisener(listener net.Listener) int
- func GetMaxInCount(io string) (c int)
- func InfoEnabled() bool
- func InitLog(level string, outs []string, json bool)
- func LogDebug(name string) *zerolog.Event
- func LogError(name string) *zerolog.Event
- func LogFatal(name string) *zerolog.Event
- func LogInfo(name string) *zerolog.Event
- func LogPanic(name string) *zerolog.Event
- func LogParams() *logParams
- func LogTrace(name string) *zerolog.Event
- func LogWarn(name string) *zerolog.Event
- func NewIoDefault() *ioDefault
- func PacketDebug() *zerolog.Event
- func PacketError() *zerolog.Event
- func PacketFatal() *zerolog.Event
- func PacketInfo() *zerolog.Event
- func PacketPanic() *zerolog.Event
- func PacketTrace() *zerolog.Event
- func PacketWarn() *zerolog.Event
- func PanicEnabled() bool
- func PanicParse() (string, error)
- func SetLimit() (err error)
- func StackParse(in string) (out string, err error)
- func StartUp()
- func StopDown(exit func())
- func T2PParse(in []byte) (out []string)
- func T2pOnParse(in []byte) (lenParsed, lenDelimit int, ok bool)
- func T2pParseCommand(in []byte) (out []byte)
- func TraceEnabled() bool
- func WarnEnabled() bool
- func WithLevel(level zerolog.Level) *zerolog.Event
- type Action
- type Alarm
- type App
- func (a *App) End()
- func (a *App) MetricCounter(name string) metrics.Counter
- func (a *App) MetricGauge(name string) metrics.Gauge
- func (a *App) MetricMeter(name string) metrics.Meter
- func (a *App) Metrics() *AppMetrics
- func (a *App) Register(s Service)
- func (a *App) Run()
- func (a *App) String() string
- func (a *App) Wait()
- type AppMetrics
- func (m *AppMetrics) GetOrRegisterCounter(name string) metrics.Counter
- func (m *AppMetrics) GetOrRegisterEwma(name string) metrics.EWMA
- func (m *AppMetrics) GetOrRegisterGauge(name string) metrics.Gauge
- func (m *AppMetrics) GetOrRegisterGaugeFloat64(name string) metrics.GaugeFloat64
- func (m *AppMetrics) GetOrRegisterHistogram(name string, s metrics.Sample) metrics.Histogram
- func (m *AppMetrics) GetOrRegisterMeter(name string) metrics.Meter
- func (m *AppMetrics) GetOrRegisterTimer(name string) metrics.Timer
- func (m *AppMetrics) Init(inMetric int)
- func (m *AppMetrics) String() string
- type Buffer
- func (b *Buffer) Begin(pos int) []byte
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Clear(pos int)
- func (b *Buffer) Get(begin, end int) []byte
- func (b *Buffer) GetFrom(begin int) []byte
- func (b *Buffer) GetTo(end int) []byte
- func (b *Buffer) Len() int
- func (b *Buffer) Put(data []byte) ([]byte, int)
- type ByteBuffer
- type Clock
- func (c *Clock) Count() int
- func (c *Clock) Register(name string, alarm Alarm) bool
- func (c *Clock) RegisterWithTime(name string, alarm Alarm, t time.Time) bool
- func (c *Clock) Reset(name string) bool
- func (c *Clock) Unregister(name string) bool
- func (c *Clock) UnregisterAll()
- func (c *Clock) Update(t time.Time)
- type Config
- func (c *Config) Exists(path string) bool
- func (c *Config) Get(key string) interface{}
- func (c *Config) GetBool(key string) bool
- func (c *Config) GetBoolOrDefault(key string, d bool) (bool, bool)
- func (c *Config) GetFloat64(key string) float64
- func (c *Config) GetFloat64OrDefault(key string, d float64) (float64, bool)
- func (c *Config) GetInt(key string) int
- func (c *Config) GetInt32(key string) int32
- func (c *Config) GetInt32OrDefault(key string, d int32) (int32, bool)
- func (c *Config) GetInt64(key string) int64
- func (c *Config) GetInt64OrDefault(key string, d int64) (int64, bool)
- func (c *Config) GetIntOrDefault(key string, d int) (int, bool)
- func (c *Config) GetOrDefault(key string, d interface{}) (interface{}, bool)
- func (c *Config) GetString(key string) string
- func (c *Config) GetStringOrDefault(key string, d string) (string, bool)
- func (c *Config) GetUint(key string) uint
- func (c *Config) GetUint32(key string) uint32
- func (c *Config) GetUint32OrDefault(key string, d uint32) (uint32, bool)
- func (c *Config) GetUint64(key string) uint64
- func (c *Config) GetUint64OrDefault(key string, d uint64) (uint64, bool)
- func (c *Config) GetUintOrDefault(key string, d uint) (uint, bool)
- func (c *Config) Load(path string) (err error)
- func (c *Config) Set(key string, value interface{})
- func (c *Config) SetBool(key string, value bool)
- func (c *Config) String() string
- type ConfigIo
- type Context
- type Contexter
- type DivCallback
- type DivMap
- func (d *DivMap) Count() int
- func (d *DivMap) Del(i uint32, k uint64) (v interface{}, ok bool)
- func (d *DivMap) Get(i uint32) (s *UnsafeMap, err error)
- func (d *DivMap) GetCounts() []int
- func (d *DivMap) GetCurrent() (c uint32, s *UnsafeMap)
- func (d *DivMap) GetLeast() (i uint32, s *UnsafeMap)
- func (d *DivMap) IsValidIndex(i uint32) bool
- func (d *DivMap) Set(k uint64, v interface{}) (uint32, *UnsafeMap)
- type EnvApp
- type Event
- type EventQueue
- func (q *EventQueue) AppendAll(events ...interface{})
- func (q *EventQueue) Convey() int
- func (q *EventQueue) ConveySlice(s ...interface{})
- func (q *EventQueue) Dispatching(t time.Time, l int) (int, int)
- func (q *EventQueue) GetClock() *Clock
- func (q *EventQueue) Inject(event interface{})
- func (q *EventQueue) InjectToAwait(event interface{})
- func (q *EventQueue) Paste(events []interface{})
- type Fnv32
- type Fnv64
- type IOs
- type Io
- func (i *Io) End()
- func (i *Io) GetIoModel() IoModel
- func (i *Io) Init()
- func (i *Io) Listen(addr *net.TCPAddr) (ok bool)
- func (i *Io) Run(addr *net.TCPAddr) (ok bool)
- func (i *Io) SetIoModel(ioModel IoModel)
- func (i *Io) Shut()
- func (i *Io) Shutdown(n *Session, how int) error
- func (i *Io) String() string
- func (i *Io) Terminate()
- type IoHost
- func (h *IoHost) AddRoom(key string, room interface{})
- func (h *IoHost) CountUser() int
- func (h *IoHost) DelDivision(d uint32, k uint64) (ok bool)
- func (h *IoHost) DelRoom(key string) bool
- func (h *IoHost) Dispatching(t time.Time, limit int) (int, int)
- func (h *IoHost) End()
- func (h *IoHost) EnterUser(uid UID, i interface{})
- func (h *IoHost) FindOrEnterUser(uid UID, i interface{}) bool
- func (h *IoHost) FindRoom(key string) interface{}
- func (h *IoHost) FindUser(uid UID) (interface{}, bool)
- func (h *IoHost) GetDivision() *DivMap
- func (h *IoHost) GetEventQueue() *EventQueue
- func (h *IoHost) LeaveUser(uid UID)
- func (h *IoHost) ListUser() (out string)
- func (h *IoHost) PostAllToQueue(l []interface{})
- func (h *IoHost) PostToQueue(i interface{})
- func (h *IoHost) Register(p unsafe.Pointer, v interface{}) (d uint32, ok bool)
- func (h *IoHost) RunDivision(t time.Time, callback DivCallback)
- func (h *IoHost) SetDivision(k uint64, v interface{}) (d uint32, ok bool)
- func (h *IoHost) String() string
- func (h *IoHost) Terminate(safe bool)
- func (h *IoHost) Unregister(p unsafe.Pointer, d uint32) (ok bool)
- type IoModel
- type Job
- type Listener
- type OnFilter
- type SafeSlice
- func (s *SafeSlice) Append(item interface{})
- func (s *SafeSlice) AppendAll(items ...interface{})
- func (s *SafeSlice) AppendSlice(ss *SafeSlice)
- func (s *SafeSlice) Count() int
- func (s *SafeSlice) Fetch() []interface{}
- func (s *SafeSlice) FetchWithLimit(limit int) []interface{}
- func (s *SafeSlice) FilterOut(f OnFilter) []interface{}
- func (s *SafeSlice) Iterate() <-chan SafeSliceItem
- func (s *SafeSlice) Paste(items []interface{})
- func (s *SafeSlice) Prepend(item interface{})
- func (s *SafeSlice) Shift() (front interface{}, count int)
- type SafeSliceItem
- type Service
- type Session
- func (n *Session) Close() error
- func (n *Session) CountOutQueue() int
- func (n *Session) DecRef() int32
- func (n *Session) GetAddr() (addr string, ok bool)
- func (n *Session) GetConn() net.Conn
- func (n *Session) GetContext() interface{}
- func (n *Session) GetFd() int
- func (n *Session) GetIo() *Io
- func (n *Session) GetKeepBuffer() *Buffer
- func (n *Session) GetRemoteIP() string
- func (n *Session) GetStats() interface{}
- func (n *Session) IncRef() int32
- func (n *Session) PostWrite(out []byte) (sent int, err error)
- func (n *Session) SetContext(c interface{})
- func (n *Session) SetStats(s interface{})
- func (n *Session) Shutdown(how int) error
- func (n *Session) String() string
- func (n *Session) SubRef(ref int32) int32
- func (n *Session) Write(out []byte) (sent int, err error)
- type Sockaddr
- type UID
- type UnsafeMap
- func (m *UnsafeMap) Count() int
- func (m *UnsafeMap) Del(key uint64)
- func (m *UnsafeMap) Fetch() map[uint64]interface{}
- func (m *UnsafeMap) Get(key uint64) (interface{}, bool)
- func (m *UnsafeMap) Init()
- func (m *UnsafeMap) Iterate() <-chan UnsafeMapItem
- func (m *UnsafeMap) MarshalJSON() ([]byte, error)
- func (m *UnsafeMap) Set(key uint64, value interface{})
- func (m *UnsafeMap) ToSlice() []UnsafeMapItem
- func (m *UnsafeMap) Upsert(key uint64, new interface{}, callback cmap.UpsertCb) (value interface{})
- type UnsafeMapItem
- type UnsafeSlice
- func (s *UnsafeSlice) Append(item interface{})
- func (s *UnsafeSlice) AppendAll(items ...interface{})
- func (s *UnsafeSlice) AppendSlice(ss *UnsafeSlice)
- func (s *UnsafeSlice) Count() int
- func (s *UnsafeSlice) Fetch() []interface{}
- func (s *UnsafeSlice) FetchWithLimit(limit int) []interface{}
- func (s *UnsafeSlice) FilterOut(f OnFilter) []interface{}
- func (s *UnsafeSlice) Iterate() <-chan UnsafeSliceItem
- func (s *UnsafeSlice) Paste(items []interface{})
- func (s *UnsafeSlice) Prepend(item interface{})
- func (s *UnsafeSlice) Shift() (front interface{}, count int)
- type UnsafeSliceItem
- type WriteJob
Constants ¶
const ( // CaptureInterval capture interval CaptureInterval = 100 * time.Millisecond // StatsDInterval capture interval StatsDInterval = 2500 * time.Millisecond // StatsDAddress statsd address StatsDAddress = "127.0.0.1:8125" )
const ( // MetricAppSessionsf app session metric MetricAppSessionsf = "%s.sessions" // MetricAppIoInCountf app io in count metric MetricAppIoInCountf = "%s.io.incount" // MetricAppIoInSizef app io in size metric MetricAppIoInSizef = "%s.io.insize" // MetricAppIoOutCountf app io out count metric MetricAppIoOutCountf = "%s.io.outcount" // MetricAppIoOutSizef app io out size metric MetricAppIoOutSizef = "%s.io.outsize" // MetricPubEchosf publish app echo metric MetricPubEchosf = "%s.pub.echos" // MetricSubEchosf subscribe app echo metric MetricSubEchosf = "%s.sub.echos" // MetricPubAppStatesf publish app state metric MetricPubAppStatesf = "%s.pub.appstates" // MetricSubAppStatesf subscribe app state metric MetricSubAppStatesf = "%s.sub.appstates" )
const ( Success int32 = 0 CurlSuccess int32 = 200 ResponseCodeUnpackError int32 = 11 // packet unpack error ResponseCodeMarshalError int32 = 12 // message marshal error ResponseCodeHttpError int32 = 13 // http 통신 에러 )
todo range 별 클라 액션을 정하는게..? ex) 100번대는 에러리턴 후 타이틀로 이동 200번대는 에러만 출력 이런식으로... Common
const ( ResponseCodeNotLoggedIn int32 = 101 // 로그인 상태가 아닌 경우 ResponseCodeAlreadyLoggedOn int32 = 102 // 이미 로그인 상태인 경우 ResponseCodeDuplicateLogin int32 = 103 // 중복로그인. 클라이언트는 이 에러코드를 받으면 타이틀로 이동. ResponseCodeNotInTheRoom int32 = 104 // 방안에 있는 상태가 아닌 경우 ResponseCodeAlreadyInTheRoom int32 = 105 // 이미 방안에 있는 상태인 경우 ResponseCodeNotWaitingRoom int32 = 104 // 방이 존재 & 유저를 기다리는 상태가 아닌 경우 ResponseCodeFailToLogon int32 = 201 ResponseCodeFailToLogoff int32 = 202 ResponseCodeFailToReqPvPRandomMatching int32 = 203 ResponseCodeFailToEnterRoom int32 = 204 ResponseCodeFailToReadyPvPGame int32 = 205 )
Frontend & Relayer
const ( ErrNotLoggedon int32 = 101 ErrFailToFindRoom int32 = 103 ErrAlreadyLoginUser int32 = 301 ErrNotExistInRoom int32 = 313 )
todo 추후 삭제 예정, 샘플 서버에서 사용하는 코드는 상단의 코드로 교체 필요 (사용하는 코드는 상단에만 존재)
const ( // DefaultDefIOInCount default def IO in count DefaultDefIOInCount = 1 // DefaultPollInCount default poll in count DefaultPollInCount = 4 )
const ( // LogDump dump LogDump = "dump" // LogName name LogName = "name" // LogProject project LogProject = "project" // LogService service LogService = "service" // LogStage stage LogStage = "stage" // LogSuid server unique id LogSuid = "suid" // LogHost host LogHost = "host" // LogObject object LogObject = "object" // LogSession session LogSession = "session" // LogUuid user unique id LogUuid = "uuid" // LogIP ip LogIP = "ip" // LogCode code LogCode = "code" // LogMatchKey match key LogMatchKey = "matchkey" // LogState state LogState = "state" // LogWalltime walltime LogWalltime = "walltime" // LogErrorCode errorcode LogErrorCode = "errorcode" // LogRoom room LogRoom = "room" // LogContext context LogContext = "context" // LogPayload payload LogPayload = "payload" // LogGitHash git last commit hash LogGitHash = "githash" // LogRecover recover LogRecover = "recover" )
const ( // FlagNone default none flag FlagNone int = iota // FlagTerminate terminate flag FlagTerminate // FlagSafeTerminate safe terminate flag FlagSafeTerminate // FlagStop stop listen flag FlagStop // FlagAllout disconnect all flag FlagAllout // FlagTerminateAfter5m exit after 5 minute flag FlagTerminateAfter5m )
const ( // ProdLogger production logger ProdLogger = "prod" // DevLogger development logger DevLogger = "dev" // ExamLogger example logger ExamLogger = "dev" )
const ( ShutRd = 0x0 ShutWr = 0x1 ShutRdWr = 0x2 SigInt = syscall.SIGINT SigTerm = syscall.SIGTERM )
const DefaultCapacity int = 5000
DefaultCapacity default capacity
const ( // DefaultInterval default interval DefaultInterval time.Duration = 20 * time.Millisecond )
const ( // Duration5m duration 5 minute Duration5m time.Duration = 5 * time.Second )
const ( // InvalidDivIndex partition invalid index InvalidDivIndex uint32 = ^uint32(0) )
const QueueCapacity int = 5000
QueueCapacity queue default capacity
Variables ¶
var ( // GetByteBuffer returns an empty byte buffer from the pool, exported from gnet/bytebuffer. GetByteBuffer = bytebufferpool.Get // PutByteBuffer returns byte buffer to the pool, exported from gnet/bytebuffer. PutByteBuffer = func(b *ByteBuffer) { if b != nil { bytebufferpool.Put(b) } } )
var UIDInvalid = UID(0)
UIDInvalid uid invalid
Functions ¶
func GetBaseAndConfig ¶
GetBaseAndConfig get base and config
func GetFdFromConn ¶
GetFdFromConn this function is linux only
func GetFdFromLisener ¶
GetFdFromLisener this function is linux only
func T2pOnParse ¶
T2pOnParse control on parse
Types ¶
type Action ¶
type Action int
Action is an action that occurs after the completion of an event.
const ( // None indicates that no action should occur following an event. None Action = iota // Listen listen. Listen // Shut close the listen. Shut // SafeTermiate close the listen and exit when no user. SafeTermiate // Termiate terminate the server. Termiate // TermiateAfter5m shutdown after 5 minute. TermiateAfter5m // CloseAll disconnect all connections. CloseAll // Close disconnect connection. Close )
type Alarm ¶
type Alarm interface { Reset() Check(t time.Time, d time.Duration) bool Ring(name string, t time.Time, c *Clock) bool // returns continue flag }
Alarm alarm interface
type App ¶
type App struct {
// contains filtered or unexported fields
}
App app
func (*App) MetricCounter ¶
MetricCounter get metric counter
func (*App) MetricGauge ¶
MetricGauge get metric gauge
func (*App) MetricMeter ¶
MetricMeter get metric meter
type AppMetrics ¶
type AppMetrics struct {
Registry metrics.Registry
}
AppMetrics app metrics
func (*AppMetrics) GetOrRegisterCounter ¶
func (m *AppMetrics) GetOrRegisterCounter(name string) metrics.Counter
GetOrRegisterCounter get or register counter // // Counters hold an int64 value that can be incremented and decremented.
type Counter interface { Clear() Count() int64 Dec(int64) Inc(int64) Snapshot() Counter }
//
func (*AppMetrics) GetOrRegisterEwma ¶
func (m *AppMetrics) GetOrRegisterEwma(name string) metrics.EWMA
GetOrRegisterEwma get or register EWMA // // EWMAs continuously calculate an exponentially-weighted moving average // based on an outside source of clock ticks.
type EWMA interface { Rate() float64 Snapshot() EWMA Tick() Update(int64) }
//
func (*AppMetrics) GetOrRegisterGauge ¶
func (m *AppMetrics) GetOrRegisterGauge(name string) metrics.Gauge
GetOrRegisterGauge get or register gauge // // Gauges hold an int64 value that can be set arbitrarily.
type Gauge interface { Snapshot() Gauge Update(int64) Value() int64 }
//
func (*AppMetrics) GetOrRegisterGaugeFloat64 ¶
func (m *AppMetrics) GetOrRegisterGaugeFloat64(name string) metrics.GaugeFloat64
GetOrRegisterGaugeFloat64 get or register gauge float64 // // GaugeFloat64s hold a float64 value that can be set arbitrarily.
type GaugeFloat64 interface { Snapshot() GaugeFloat64 Update(float64) Value() float64 }
//
func (*AppMetrics) GetOrRegisterHistogram ¶
func (m *AppMetrics) GetOrRegisterHistogram(name string, s metrics.Sample) metrics.Histogram
GetOrRegisterHistogram get or register histogram // // Histograms calculate distribution statistics from a series of int64 values.
type Histogram interface { Clear() Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Sample() Sample Snapshot() Histogram StdDev() float64 Sum() int64 Update(int64) Variance() float64 }
//
func (*AppMetrics) GetOrRegisterMeter ¶
func (m *AppMetrics) GetOrRegisterMeter(name string) metrics.Meter
GetOrRegisterMeter get or register meter // // Meters count events to produce exponentially-weighted moving average rates // at one-, five-, and fifteen-minutes and a mean rate.
type Meter interface { Count() int64 Mark(int64) Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Meter Stop() }
//
func (*AppMetrics) GetOrRegisterTimer ¶
func (m *AppMetrics) GetOrRegisterTimer(name string) metrics.Timer
GetOrRegisterTimer get or register timer // // Timers capture the duration and rate of events.
type Timer interface { Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Timer StdDev() float64 Stop() Sum() int64 Time(func()) Update(time.Duration) UpdateSince(time.Time) Variance() float64 }
//
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a helper type for managing input streams from inside the Data event.
type ByteBuffer ¶
type ByteBuffer = bytebufferpool.ByteBuffer
ByteBuffer is the alias of bytebufferpool.ByteBuffer.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock clock
func (*Clock) RegisterWithTime ¶
RegisterWithTime regiseter alarm with time
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config config
func (*Config) GetBoolOrDefault ¶
GetBoolOrDefault get bool or default value or of key
func (*Config) GetFloat64 ¶
GetFloat64 get float64 value of key
func (*Config) GetFloat64OrDefault ¶
GetFloat64OrDefault get float64 or default value of key
func (*Config) GetInt32OrDefault ¶
GetInt32OrDefault get int32 or default value of key
func (*Config) GetInt64OrDefault ¶
GetInt64OrDefault get int64 or default value of key
func (*Config) GetIntOrDefault ¶
GetIntOrDefault get int or default value of key
func (*Config) GetOrDefault ¶
GetOrDefault get or default
func (*Config) GetStringOrDefault ¶
GetStringOrDefault get string or default value of key
func (*Config) GetUint32OrDefault ¶
GetUint32OrDefault get uint32 or default value of key
func (*Config) GetUint64OrDefault ¶
GetUint64OrDefault get uint64 or default value of key
func (*Config) GetUintOrDefault ¶
GetUintOrDefault get uint or default value of key
type ConfigIo ¶
type ConfigIo struct { ReadBufferLen int InURL string InModel string InCount int InWaitCount int InNoDelay bool InRecvTimeo int InRcvBuff int InSndBuff int InReusePort bool }
ConfigIo config service
func ProvideConfigIo ¶
ProvideConfigIo returns service config
type DivCallback ¶
DivCallback metric callback
type DivMap ¶
type DivMap struct {
// contains filtered or unexported fields
}
DivMap division map
func (*DivMap) GetCurrent ¶
GetCurrent get current partition
func (*DivMap) IsValidIndex ¶
IsValidIndex is valid index
type EnvApp ¶
type EnvApp struct {
// contains filtered or unexported fields
}
EnvApp env app
ELIO_LOG_LEVEL ELIO_LOG_OUTS ELIO_LOG_JSON ELIO_LOG_NOCOLOR ELIO_IN_METRIC ELIO_IN_PPROF
type EventQueue ¶
type EventQueue struct {
// contains filtered or unexported fields
}
EventQueue event queue
func (*EventQueue) AppendAll ¶
func (q *EventQueue) AppendAll(events ...interface{})
AppendAll append all
func (*EventQueue) ConveySlice ¶
func (q *EventQueue) ConveySlice(s ...interface{})
ConveySlice convey slice to event queue
func (*EventQueue) Dispatching ¶
Dispatching dispatching
func (*EventQueue) InjectToAwait ¶
func (q *EventQueue) InjectToAwait(event interface{})
InjectToAwait inject to await
type Io ¶
type Io struct { Listener *Listener //net.Listener Config ConfigIo Host *IoHost Service Service InAddr atomic.String //*net.TCPAddr InCount atomic.Int32 // contains filtered or unexported fields }
Io IO
func (*Io) SetIoModel ¶ added in v0.1.2
SetIoModel set IO model
type IoHost ¶
type IoHost struct { Ios []*Io Wg *sync.WaitGroup Url *net.TCPAddr Users map[UID]interface{} Rooms map[string]interface{} //*Room EventQueue *EventQueue Divs *DivMap DivChecked uint32 }
IoHost host
func (*IoHost) DelDivision ¶
DelDivision del division
func (*IoHost) Dispatching ¶
Dispatching dispatching
func (*IoHost) FindOrEnterUser ¶
FindOrEnterUser find or add user
func (*IoHost) GetEventQueue ¶
func (h *IoHost) GetEventQueue() *EventQueue
GetEventQueue get event queue
func (*IoHost) PostAllToQueue ¶
func (h *IoHost) PostAllToQueue(l []interface{})
PostAllToQueue post all to queue
func (*IoHost) PostToQueue ¶
func (h *IoHost) PostToQueue(i interface{})
PostToQueue post to event queue
func (*IoHost) RunDivision ¶
func (h *IoHost) RunDivision(t time.Time, callback DivCallback)
RunDivision run division
func (*IoHost) SetDivision ¶
SetDivision set division
type IoModel ¶ added in v0.1.2
type IoModel interface { GetIo() *Io SetIo(c *Io) Listen(addr string) bool Run() bool Shut() // close listen End() // end service Read(n *Session, in []byte) (receipt int, err error) Write(n *Session, out []byte) (sent int, err error) PostWrite(n *Session, out []byte) (sent int, err error) Trigger(job interface{}) error Close(n *Session) error Shutdown(n *Session, how int) error CloseAll() }
Io I/O model
type SafeSlice ¶
SafeSlice safe slice
func (*SafeSlice) Append ¶
func (s *SafeSlice) Append(item interface{})
Append adds an item to the concurrent slice
func (*SafeSlice) AppendAll ¶
func (s *SafeSlice) AppendAll(items ...interface{})
AppendAll adds an items to the concurrent slice
func (*SafeSlice) AppendSlice ¶
AppendSlice adds an items to the concurrent slice
func (*SafeSlice) FetchWithLimit ¶
FetchWithLimit fetch slice with limit
func (*SafeSlice) Iterate ¶
func (s *SafeSlice) Iterate() <-chan SafeSliceItem
Iterate iterates over the items in the concurrent slice Each item is sent over a channel, so that we can iterate over the slice using the builin range keyword
func (*SafeSlice) Paste ¶
func (s *SafeSlice) Paste(items []interface{})
Paste paste an items to the concurrent slice
type SafeSliceItem ¶
type SafeSliceItem struct { Index int Value interface{} }
SafeSliceItem contains the index/value pair of an item in a concurrent slice
type Service ¶
type Service interface { Name() string OnInit(ctx context.Context, cancel context.CancelFunc) error OnExit() //OnListen(i *IoCore) //OnShut(i *IoCore) OnOpen(s *Session) error OnClose(s *Session, err error) OnError(s *Session, err error) OnRead(s *Session, in []byte) int OnWrite(s *Session, out []byte) OnLoop(host *IoHost, t time.Time, d time.Duration) }
Service service
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session session
func (*Session) GetKeepBuffer ¶
GetKeepBuffer get keep buffer
type UnsafeMap ¶
type UnsafeMap struct {
Map map[uint64]interface{}
}
UnsafeMap safe map
func (*UnsafeMap) Iterate ¶
func (m *UnsafeMap) Iterate() <-chan UnsafeMapItem
Iterate iterates over the items in a concurrent map Each item is sent over a channel, so that we can iterate over the map using the builtin range keyword
func (*UnsafeMap) MarshalJSON ¶
MarshalJSON marshal json
type UnsafeMapItem ¶
type UnsafeMapItem struct { Key uint64 Value interface{} }
UnsafeMapItem contains a key/value pair item of a concurrent map
type UnsafeSlice ¶
type UnsafeSlice struct {
// contains filtered or unexported fields
}
UnsafeSlice safe slice
func NewUnsafeSlice ¶
func NewUnsafeSlice(c int) *UnsafeSlice
NewUnsafeSlice creates a new concurrent slice
func (*UnsafeSlice) Append ¶
func (s *UnsafeSlice) Append(item interface{})
Append adds an item to the concurrent slice
func (*UnsafeSlice) AppendAll ¶
func (s *UnsafeSlice) AppendAll(items ...interface{})
AppendAll adds an items to the concurrent slice
func (*UnsafeSlice) AppendSlice ¶
func (s *UnsafeSlice) AppendSlice(ss *UnsafeSlice)
AppendSlice adds an items to the concurrent slice
func (*UnsafeSlice) FetchWithLimit ¶
func (s *UnsafeSlice) FetchWithLimit(limit int) []interface{}
FetchWithLimit fetch slice with limit
func (*UnsafeSlice) FilterOut ¶
func (s *UnsafeSlice) FilterOut(f OnFilter) []interface{}
FilterOut filter an items out from the concurrent slice
func (*UnsafeSlice) Iterate ¶
func (s *UnsafeSlice) Iterate() <-chan UnsafeSliceItem
Iterate iterates over the items in the concurrent slice Each item is sent over a channel, so that we can iterate over the slice using the builin range keyword
func (*UnsafeSlice) Paste ¶
func (s *UnsafeSlice) Paste(items []interface{})
Paste paste an items to the concurrent slice
func (*UnsafeSlice) Prepend ¶
func (s *UnsafeSlice) Prepend(item interface{})
Prepend prepend an item to the concurrent slice
func (*UnsafeSlice) Shift ¶
func (s *UnsafeSlice) Shift() (front interface{}, count int)
Shift shift slice and renew
type UnsafeSliceItem ¶
type UnsafeSliceItem struct { Index int Value interface{} }
UnsafeSliceItem contains the index/value pair of an item in a concurrent slice
Source Files ¶
- app.go
- app.metrics.go
- buffer.go
- byte.buffer.go
- clock.alarm.go
- config.go
- config.io.go
- context.go
- debug.go
- div.map.go
- elio.go
- env.app.go
- error.code.go
- event.clock.go
- event.go
- event.queue.go
- io.env.go
- io.env.win.go
- io.go
- io.host.go
- io.listener.go
- io.listener.win.go
- io.model.default.go
- io.model.go
- io.provider.go
- job.go
- job.win.go
- log.go
- log.params.go
- safe.slice.go
- service.go
- session.go
- session.win.go
- sys.const.win.go
- t2p.parse.go
- types.go
- unsafe.map.go
- unsafe.slice.go
- util.fnv.go
- util.path.go