elio

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 36 Imported by: 1

README ΒΆ

elio

elio means event loop io library.
This library allows you to quickly write epoll-based servers.

github-license Build App Publish App github-license tag version




Apps written using elio library

πŸš€ Running Echo

Echo is a simple echo server.


πŸš€ Running Herald

Herald is a simple MQTT pub/sub test client.




Under the Hood of Echo

app/echo is simple echo server written by elio.
This is the main function of app/echo:

package main

import (
	"github.com/cppis/elio"
)

func main() {
	app := elio.Elio()

	echo := NewEcho(app)
	app.Register(echo)

	app.Run()

	app.Wait()
}

The echo generated by NewEcho is a implementation of elio service interface:
elio service interface has following method signatures:

package elio

import (
	"context"
	"time"
)

// Service service
type Service interface {
	Name() string
	OnInit(ctx context.Context, cancel context.CancelFunc) error
	OnExit()
	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)
}

If network I/O event happens, elio calls proper event method of service.


This is a event implementations of echo service:

func (e *Echo) OnOpen(s *elio.Session) error {
	fmt.Printf("o")

	return nil
}

func (e *Echo) OnClose(s *elio.Session, err error) {
	fmt.Printf("c")
}

func (e *Echo) OnError(s *elio.Session, err error) {
	fmt.Printf("e")
}

func (e *Echo) OnRead(s *elio.Session, in []byte) (processed int) {
	fmt.Printf("+%d", len(in))

	s.Write(in)

	if 'q' == in[0] {
		elio.Elio().End()
	}

	return processed
}

func (e *Echo) OnWrite(s *elio.Session, out []byte) {
	fmt.Printf("-%d", len(out))
}

Service also has loop callback for running logics at regular intervals:

const (
	// defaultFetchLimit default fetch limit
	defaultFetchLimit int = 2000
)

func (e *Echo) OnLoop(host *elio.IoHost, t time.Time, d time.Duration) {
	//host.RunDivision(t, r.callbackDivision)

	_, _ = host.Dispatching(t, defaultFetchLimit)

	e.prev = t
}

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	// CaptureInterval capture interval
	CaptureInterval = 100 * time.Millisecond
	// StatsDInterval capture interval
	StatsDInterval = 2500 * time.Millisecond
	// StatsDAddress statsd address
	StatsDAddress = "127.0.0.1:8125"
)
View Source
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"
	// MetricPubAppStatesf publish app state metric
	MetricPubAppStatesf = "%s.pub.appstates"
	// MetricSubAppStatesf subscribe app state metric
	MetricSubAppStatesf = "%s.sub.appstates"
)
View Source
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

View Source
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

View Source
const (
	ErrNotLoggedon    int32 = 101
	ErrFailToFindRoom int32 = 103

	ErrAlreadyLoginUser int32 = 301

	ErrNotExistInRoom int32 = 313
)

todo μΆ”ν›„ μ‚­μ œ μ˜ˆμ •, μƒ˜ν”Œ μ„œλ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ˜ μ½”λ“œλ‘œ ꡐ체 ν•„μš” (μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ—λ§Œ 쑴재)

View Source
const (
	// DefaultDefIOInCount default def IO in count
	DefaultDefIOInCount = 1
	// DefaultPollInCount default poll in count
	DefaultPollInCount = 4
)
View Source
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"
)
View Source
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
)
View Source
const (
	// ProdLogger production logger
	ProdLogger = "prod"
	// DevLogger development logger
	DevLogger = "dev"
	// ExamLogger example logger
	ExamLogger = "dev"
)
View Source
const (
	// ShutRd shut rd
	ShutRd = unix.SHUT_RD
	// ShutWr shut wr
	ShutWr = unix.SHUT_WR
	// ShutRdWr shut rdwr
	ShutRdWr = unix.SHUT_RDWR

	// SigInt sig int
	SigInt = syscall.SIGINT
	// SigTerm sig term
	SigTerm = syscall.SIGTERM
)
View Source
const DefaultCapacity int = 5000

DefaultCapacity default capacity

View Source
const (
	// DefaultInterval default interval
	DefaultInterval time.Duration = 20 * time.Millisecond
)
View Source
const (
	// Duration5m duration 5 minute
	Duration5m time.Duration = 5 * time.Second
)
View Source
const (
	// InvalidDivIndex partition invalid index
	InvalidDivIndex uint32 = ^uint32(0)
)
View Source
const QueueCapacity int = 5000

QueueCapacity queue default capacity

Variables ΒΆ

View Source
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)
		}
	}
)
View Source
var UIDInvalid = UID(0)

UIDInvalid uid invalid

Functions ΒΆ

func AppDebug ΒΆ

func AppDebug() *zerolog.Event

AppDebug app log debug

func AppError ΒΆ

func AppError() *zerolog.Event

AppError app log error

func AppFatal ΒΆ

func AppFatal() *zerolog.Event

AppFatal app log fatal

func AppInfo ΒΆ

func AppInfo() *zerolog.Event

AppInfo app log info

func AppPanic ΒΆ

func AppPanic() *zerolog.Event

AppPanic app log panic

func AppTrace ΒΆ

func AppTrace() *zerolog.Event

AppTrace app log trace

func AppWarn ΒΆ

func AppWarn() *zerolog.Event

AppWarn app log warn

func DebugEnabled ΒΆ

func DebugEnabled() bool

DebugEnabled debug enabled

func DeleteSession ΒΆ

func DeleteSession(n *Session)

DeleteSession delete session

func DumpDebug ΒΆ

func DumpDebug() *zerolog.Event

DumpDebug packet log debug

func DumpError ΒΆ

func DumpError() *zerolog.Event

DumpError packet log error

func DumpFatal ΒΆ

func DumpFatal() *zerolog.Event

DumpFatal packet log fatal

func DumpInfo ΒΆ

func DumpInfo() *zerolog.Event

DumpInfo packet log info

func DumpPanic ΒΆ

func DumpPanic() *zerolog.Event

DumpPanic packet log panic

func DumpTrace ΒΆ

func DumpTrace() *zerolog.Event

DumpTrace packet log trace

func DumpWarn ΒΆ

func DumpWarn() *zerolog.Event

DumpWarn packet log warn

func ErrorEnabled ΒΆ

func ErrorEnabled() bool

ErrorEnabled error enabled

func FatalEnabled ΒΆ

func FatalEnabled() bool

FatalEnabled fatal enabled

func GetBaseAndConfig ΒΆ

func GetBaseAndConfig() (base string, config string)

GetBaseAndConfig get base and config

func GetBasename ΒΆ

func GetBasename(path string) string

GetBasename get base name

func GetBasepath ΒΆ

func GetBasepath(path string) string

GetBasepath get base path

func GetFdFromConn ΒΆ

func GetFdFromConn(conn net.Conn) int

GetFdFromConn this function is linux only

func GetFdFromLisener ΒΆ

func GetFdFromLisener(listener net.Listener) int

GetFdFromLisener this function is linux only

func GetMaxInCount ΒΆ

func GetMaxInCount(io string) (c int)

GetMaxInCount get max in count

func InfoEnabled ΒΆ

func InfoEnabled() bool

InfoEnabled info enabled

func InitLog ΒΆ

func InitLog(level string, outs []string, json bool)

InitLog init log

func LogDebug ΒΆ

func LogDebug(name string) *zerolog.Event

LogDebug app log debug

func LogError ΒΆ

func LogError(name string) *zerolog.Event

LogError app log error

func LogFatal ΒΆ

func LogFatal(name string) *zerolog.Event

LogFatal app log fatal

func LogInfo ΒΆ

func LogInfo(name string) *zerolog.Event

LogInfo app log info

func LogPanic ΒΆ

func LogPanic(name string) *zerolog.Event

LogPanic app log panic

func LogParams ΒΆ

func LogParams() *logParams

LogParams get log params

func LogTrace ΒΆ

func LogTrace(name string) *zerolog.Event

LogTrace app log trace

func LogWarn ΒΆ

func LogWarn(name string) *zerolog.Event

LogWarn app log warn

func NewIoDefault ΒΆ

func NewIoDefault() *ioDefault

NewIoDefault new io default

func NewIoPoll ΒΆ

func NewIoPoll() *ioPoll

NewIoPoll new io poll

func PacketDebug ΒΆ

func PacketDebug() *zerolog.Event

PacketDebug packet log debug

func PacketError ΒΆ

func PacketError() *zerolog.Event

PacketError packet log error

func PacketFatal ΒΆ

func PacketFatal() *zerolog.Event

PacketFatal packet log fatal

func PacketInfo ΒΆ

func PacketInfo() *zerolog.Event

PacketInfo packet log info

func PacketPanic ΒΆ

func PacketPanic() *zerolog.Event

PacketPanic packet log panic

func PacketTrace ΒΆ

func PacketTrace() *zerolog.Event

PacketTrace packet log trace

func PacketWarn ΒΆ

func PacketWarn() *zerolog.Event

PacketWarn packet log warn

func PanicEnabled ΒΆ

func PanicEnabled() bool

PanicEnabled panic enabled

func PanicParse ΒΆ

func PanicParse() (string, error)

PanicParse panic parse

func SetLimit ΒΆ

func SetLimit() (err error)

SetLimit set limit

func StackParse ΒΆ

func StackParse(in string) (out string, err error)

StackParse stack parse

func StartUp ΒΆ

func StartUp()

StartUp start up

func StopDown ΒΆ

func StopDown(exit func())

StopDown stop down

func T2PParse ΒΆ

func T2PParse(in []byte) (out []string)

T2PParse T2P parse

func T2pOnParse ΒΆ

func T2pOnParse(in []byte) (lenParsed, lenDelimit int, ok bool)

T2pOnParse control on parse

func T2pParseCommand ΒΆ

func T2pParseCommand(in []byte) (out []byte)

T2pParseCommand parse command

func TraceEnabled ΒΆ

func TraceEnabled() bool

TraceEnabled debug enabled

func WarnEnabled ΒΆ

func WarnEnabled() bool

WarnEnabled debug enabled

func WithLevel ΒΆ

func WithLevel(level zerolog.Level) *zerolog.Event

WithLevel with level

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 Elio ΒΆ

func Elio() *App

Elio get elio

func NewApp ΒΆ

func NewApp() *App

NewApp new app

func (*App) Config ΒΆ added in v0.1.5

func (a *App) Config() *Config

Config config

func (*App) End ΒΆ

func (a *App) End()

End call cancel callback

func (*App) MetricCounter ΒΆ

func (a *App) MetricCounter(name string) metrics.Counter

MetricCounter get metric counter

func (*App) MetricGauge ΒΆ

func (a *App) MetricGauge(name string) metrics.Gauge

MetricGauge get metric gauge

func (*App) MetricMeter ΒΆ

func (a *App) MetricMeter(name string) metrics.Meter

MetricMeter get metric meter

func (*App) Metrics ΒΆ

func (a *App) Metrics() *AppMetrics

Metrics get app metrics

func (*App) Register ΒΆ

func (a *App) Register(s Service)

Register register service

func (*App) Run ΒΆ

func (a *App) Run()

func (*App) String ΒΆ

func (a *App) String() string

// public scope String object to string

func (*App) Wait ΒΆ

func (a *App) Wait()

Wait wait app

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
}

//

func (*AppMetrics) Init ΒΆ

func (m *AppMetrics) Init(inMetric int)

Init init

func (*AppMetrics) String ΒΆ

func (m *AppMetrics) String() string

String object to string

type Buffer ΒΆ

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a helper type for managing input streams from inside the Data event.

func (*Buffer) Begin ΒΆ

func (b *Buffer) Begin(pos int) []byte

Begin accepts a new packet and returns a working sequence of unprocessed bytes.

func (*Buffer) Bytes ΒΆ

func (b *Buffer) Bytes() []byte

Bytes get bytes of buffer.

func (*Buffer) Clear ΒΆ

func (b *Buffer) Clear(pos int)

Clear clear buffer

func (*Buffer) Get ΒΆ

func (b *Buffer) Get(begin, end int) []byte

Get get contents

func (*Buffer) GetFrom ΒΆ

func (b *Buffer) GetFrom(begin int) []byte

GetFrom get contents from begin

func (*Buffer) GetTo ΒΆ

func (b *Buffer) GetTo(end int) []byte

GetTo get contents to end

func (*Buffer) Len ΒΆ

func (b *Buffer) Len() int

Len get length of buffer.

func (*Buffer) Put ΒΆ

func (b *Buffer) Put(data []byte) ([]byte, int)

Put put contents to buffer

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 NewClock ΒΆ

func NewClock() *Clock

NewClock new clock

func (*Clock) Count ΒΆ

func (c *Clock) Count() int

Count count

func (*Clock) Register ΒΆ

func (c *Clock) Register(name string, alarm Alarm) bool

Register regiseter alarm

func (*Clock) RegisterWithTime ΒΆ

func (c *Clock) RegisterWithTime(name string, alarm Alarm, t time.Time) bool

RegisterWithTime regiseter alarm with time

func (*Clock) Reset ΒΆ

func (c *Clock) Reset(name string) bool

Reset reset

func (*Clock) Unregister ΒΆ

func (c *Clock) Unregister(name string) bool

Unregister unregister alarm

func (*Clock) UnregisterAll ΒΆ

func (c *Clock) UnregisterAll()

UnregisterAll unregister all alarm

func (*Clock) Update ΒΆ

func (c *Clock) Update(t time.Time)

Update update

type Config ΒΆ

type Config struct {
	// contains filtered or unexported fields
}

Config config

func NewConfig ΒΆ

func NewConfig() (c *Config)

NewConfig new config

func (*Config) Exists ΒΆ

func (c *Config) Exists(path string) bool

Exists check key exists

func (*Config) Get ΒΆ

func (c *Config) Get(key string) interface{}

Get get

func (*Config) GetBool ΒΆ

func (c *Config) GetBool(key string) bool

GetBool get bool value of key

func (*Config) GetBoolOrDefault ΒΆ

func (c *Config) GetBoolOrDefault(key string, d bool) (bool, bool)

GetBoolOrDefault get bool or default value or of key

func (*Config) GetFloat64 ΒΆ

func (c *Config) GetFloat64(key string) float64

GetFloat64 get float64 value of key

func (*Config) GetFloat64OrDefault ΒΆ

func (c *Config) GetFloat64OrDefault(key string, d float64) (float64, bool)

GetFloat64OrDefault get float64 or default value of key

func (*Config) GetInt ΒΆ

func (c *Config) GetInt(key string) int

GetInt get int value of key

func (*Config) GetInt32 ΒΆ

func (c *Config) GetInt32(key string) int32

GetInt32 get int32 value of key

func (*Config) GetInt32OrDefault ΒΆ

func (c *Config) GetInt32OrDefault(key string, d int32) (int32, bool)

GetInt32OrDefault get int32 or default value of key

func (*Config) GetInt64 ΒΆ

func (c *Config) GetInt64(key string) int64

GetInt64 get int64 value of key

func (*Config) GetInt64OrDefault ΒΆ

func (c *Config) GetInt64OrDefault(key string, d int64) (int64, bool)

GetInt64OrDefault get int64 or default value of key

func (*Config) GetIntOrDefault ΒΆ

func (c *Config) GetIntOrDefault(key string, d int) (int, bool)

GetIntOrDefault get int or default value of key

func (*Config) GetOrDefault ΒΆ

func (c *Config) GetOrDefault(key string, d interface{}) (interface{}, bool)

GetOrDefault get or default

func (*Config) GetString ΒΆ

func (c *Config) GetString(key string) string

GetString get string value of key

func (*Config) GetStringOrDefault ΒΆ

func (c *Config) GetStringOrDefault(key string, d string) (string, bool)

GetStringOrDefault get string or default value of key

func (*Config) GetUint ΒΆ

func (c *Config) GetUint(key string) uint

GetUint get uint value of key

func (*Config) GetUint32 ΒΆ

func (c *Config) GetUint32(key string) uint32

GetUint32 get Uint32 value of key

func (*Config) GetUint32OrDefault ΒΆ

func (c *Config) GetUint32OrDefault(key string, d uint32) (uint32, bool)

GetUint32OrDefault get uint32 or default value of key

func (*Config) GetUint64 ΒΆ

func (c *Config) GetUint64(key string) uint64

GetUint64 get uint64 value of key

func (*Config) GetUint64OrDefault ΒΆ

func (c *Config) GetUint64OrDefault(key string, d uint64) (uint64, bool)

GetUint64OrDefault get uint64 or default value of key

func (*Config) GetUintOrDefault ΒΆ

func (c *Config) GetUintOrDefault(key string, d uint) (uint, bool)

GetUintOrDefault get uint or default value of key

func (*Config) Load ΒΆ

func (c *Config) Load(path string) (err error)

Load load

func (*Config) Set ΒΆ

func (c *Config) Set(key string, value interface{})

Set set interface value of key

func (*Config) SetBool ΒΆ

func (c *Config) SetBool(key string, value bool)

SetBool set bool value of key

func (*Config) String ΒΆ

func (c *Config) String() string

String object to string

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 ΒΆ

func ProvideConfigIo(name string, config *Config) ConfigIo

ProvideConfigIo returns service config

type Context ΒΆ

type Context struct {
	Session *Session
}

Context implementation

func NewContext ΒΆ

func NewContext(n *Session) *Context

NewContext create new context

func (*Context) GetSession ΒΆ

func (c *Context) GetSession() *Session

GetSession get session

func (*Context) SetSession ΒΆ

func (c *Context) SetSession(s *Session)

SetSession set session

func (*Context) String ΒΆ

func (c *Context) String() string

type Contexter ΒΆ

type Contexter interface {
	GetSession() *Session
	String() string
}

Contexter interface

type DivCallback ΒΆ

type DivCallback func(t time.Time, v interface{}) error

DivCallback metric callback

type DivMap ΒΆ

type DivMap struct {
	// contains filtered or unexported fields
}

DivMap division map

func NewDivMap ΒΆ

func NewDivMap(l uint32) *DivMap

NewDivMap new division map

func (*DivMap) Count ΒΆ

func (d *DivMap) Count() int

Count get count

func (*DivMap) Del ΒΆ

func (d *DivMap) Del(i uint32, k uint64) (v interface{}, ok bool)

Del del from partition

func (*DivMap) Get ΒΆ

func (d *DivMap) Get(i uint32) (s *UnsafeMap, err error)

Get get partition

func (*DivMap) GetCounts ΒΆ

func (d *DivMap) GetCounts() []int

GetCounts get partitions count

func (*DivMap) GetCurrent ΒΆ

func (d *DivMap) GetCurrent() (c uint32, s *UnsafeMap)

GetCurrent get current partition

func (*DivMap) GetLeast ΒΆ

func (d *DivMap) GetLeast() (i uint32, s *UnsafeMap)

GetLeast get least partition

func (*DivMap) IsValidIndex ΒΆ

func (d *DivMap) IsValidIndex(i uint32) bool

IsValidIndex is valid index

func (*DivMap) Set ΒΆ

func (d *DivMap) Set(k uint64, v interface{}) (uint32, *UnsafeMap)

Set set to partition

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 Event ΒΆ

type Event interface {
	Handle()
	String() string
}

Event event interface

type EventQueue ΒΆ

type EventQueue struct {
	// contains filtered or unexported fields
}

EventQueue event queue

func NewEventQueue ΒΆ

func NewEventQueue() *EventQueue

NewEventQueue new event queue

func (*EventQueue) AppendAll ΒΆ

func (q *EventQueue) AppendAll(events ...interface{})

AppendAll append all

func (*EventQueue) Convey ΒΆ

func (q *EventQueue) Convey() int

Convey convey await to event queue

func (*EventQueue) ConveySlice ΒΆ

func (q *EventQueue) ConveySlice(s ...interface{})

ConveySlice convey slice to event queue

func (*EventQueue) Dispatching ΒΆ

func (q *EventQueue) Dispatching(t time.Time, l int) (int, int)

Dispatching dispatching

func (*EventQueue) GetClock ΒΆ

func (q *EventQueue) GetClock() *Clock

GetClock get clock

func (*EventQueue) Inject ΒΆ

func (q *EventQueue) Inject(event interface{})

Inject inject

func (*EventQueue) InjectToAwait ΒΆ

func (q *EventQueue) InjectToAwait(event interface{})

InjectToAwait inject to await

func (*EventQueue) Paste ΒΆ

func (q *EventQueue) Paste(events []interface{})

Paste paste

type Fnv32 ΒΆ

type Fnv32 uint32

Fnv32 fnv32 type definition

func (*Fnv32) FromString ΒΆ

func (f *Fnv32) FromString(k string)

FromString from string

func (*Fnv32) FromUint32 ΒΆ

func (f *Fnv32) FromUint32(v uint32)

FromUint32 from uint32

func (*Fnv32) ToUint32 ΒΆ

func (f *Fnv32) ToUint32() uint32

ToUint32 to uint32

type Fnv64 ΒΆ

type Fnv64 uint64

Fnv64 fnv64 type definition

func (*Fnv64) FromPointer ΒΆ

func (f *Fnv64) FromPointer(p unsafe.Pointer)

FromPointer from pointer

func (*Fnv64) FromString ΒΆ

func (f *Fnv64) FromString(k string)

FromString from string

func (*Fnv64) FromUint64 ΒΆ

func (f *Fnv64) FromUint64(v uint64)

FromUint64 from uint64

func (*Fnv64) ToUint64 ΒΆ

func (f *Fnv64) ToUint64() uint64

ToUint64 to uint64

type IOs ΒΆ

type IOs int

IOs io models type definition

const (
	// IoAuto IO auto
	IoAuto IOs = iota
	// IoDefault IO default(golang method)
	IoDefault
	// IoPoll IO poll
	IoPoll
)

func GetCurrentIO ΒΆ

func GetCurrentIO(io string) IOs

GetCurrentIO get current io

func IOsFromString ΒΆ

func IOsFromString(m string) IOs

IOsFromString IO models from string

func (IOs) String ΒΆ

func (i IOs) String() string

String string

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 NewIo ΒΆ added in v0.1.2

func NewIo(h *IoHost, c ConfigIo, s Service) *Io

NewIo new server

func ProvideIo ΒΆ added in v0.1.2

func ProvideIo(h *IoHost, c ConfigIo, s Service) *Io

ProvideIo provide service

func (*Io) End ΒΆ

func (i *Io) End()

End end

func (*Io) GetIoModel ΒΆ added in v0.1.2

func (i *Io) GetIoModel() IoModel

GetIoModel get IO model

func (*Io) Init ΒΆ added in v0.1.2

func (i *Io) Init()

Init init

func (*Io) Listen ΒΆ

func (i *Io) Listen(addr *net.TCPAddr) (ok bool)

Listen listen Io

func (*Io) Run ΒΆ

func (i *Io) Run(addr *net.TCPAddr) (ok bool)

Run run Io

func (*Io) SetIoModel ΒΆ added in v0.1.2

func (i *Io) SetIoModel(ioModel IoModel)

SetIoModel set IO model

func (*Io) Shut ΒΆ

func (i *Io) Shut()

Shut shut

func (*Io) Shutdown ΒΆ

func (i *Io) Shutdown(n *Session, how int) error

Shutdown shutdown

func (*Io) String ΒΆ added in v0.1.2

func (i *Io) String() string

func (*Io) Terminate ΒΆ added in v0.1.2

func (i *Io) Terminate()

Terminate terminate

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 Host ΒΆ

func Host(config ConfigIo, service Service) (host *IoHost, err error)

Host host

func NewIoHost ΒΆ

func NewIoHost(divs int) (h *IoHost)

NewIoHost new host

func (*IoHost) AddRoom ΒΆ

func (h *IoHost) AddRoom(key string, room interface{})

AddRoom add room

func (*IoHost) CountUser ΒΆ

func (h *IoHost) CountUser() int

CountUser count user

func (*IoHost) DelDivision ΒΆ

func (h *IoHost) DelDivision(d uint32, k uint64) (ok bool)

DelDivision del division

func (*IoHost) DelRoom ΒΆ

func (h *IoHost) DelRoom(key string) bool

DelRoom delete room

func (*IoHost) Dispatching ΒΆ

func (h *IoHost) Dispatching(t time.Time, limit int) (int, int)

Dispatching dispatching

func (*IoHost) End ΒΆ

func (h *IoHost) End()

End end

func (*IoHost) EnterUser ΒΆ

func (h *IoHost) EnterUser(uid UID, i interface{})

EnterUser enter user

func (*IoHost) FindOrEnterUser ΒΆ

func (h *IoHost) FindOrEnterUser(uid UID, i interface{}) bool

FindOrEnterUser find or add user

func (*IoHost) FindRoom ΒΆ

func (h *IoHost) FindRoom(key string) interface{}

FindRoom find room

func (*IoHost) FindUser ΒΆ

func (h *IoHost) FindUser(uid UID) (interface{}, bool)

FindUser find user

func (*IoHost) GetDivision ΒΆ

func (h *IoHost) GetDivision() *DivMap

GetDivision get division

func (*IoHost) GetEventQueue ΒΆ

func (h *IoHost) GetEventQueue() *EventQueue

GetEventQueue get event queue

func (*IoHost) LeaveUser ΒΆ

func (h *IoHost) LeaveUser(uid UID)

LeaveUser leave user

func (*IoHost) ListUser ΒΆ

func (h *IoHost) ListUser() (out string)

ListUser list user

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) Register ΒΆ

func (h *IoHost) Register(p unsafe.Pointer, v interface{}) (d uint32, ok bool)

Register register

func (*IoHost) RunDivision ΒΆ

func (h *IoHost) RunDivision(t time.Time, callback DivCallback)

RunDivision run division

func (*IoHost) SetDivision ΒΆ

func (h *IoHost) SetDivision(k uint64, v interface{}) (d uint32, ok bool)

SetDivision set division

func (*IoHost) String ΒΆ

func (h *IoHost) String() string

String string

func (*IoHost) Terminate ΒΆ

func (h *IoHost) Terminate(safe bool)

Terminate terminate

func (*IoHost) Unregister ΒΆ

func (h *IoHost) Unregister(p unsafe.Pointer, d uint32) (ok bool)

Unregister unregister

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

func GenIO ΒΆ

func GenIO(io string) IoModel

GenIO gen io

type Job ΒΆ

type Job interface {
	String() string
	Work() error
}

Job job interface

type Listener ΒΆ

type Listener struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Listener listener

func (*Listener) Close ΒΆ

func (l *Listener) Close()

Close close

func (*Listener) Listen ΒΆ

func (l *Listener) Listen(network, address string) (err error)

Listen listen

func (*Listener) String ΒΆ

func (l *Listener) String() string

func (*Listener) ToFd ΒΆ

func (l *Listener) ToFd() int

ToFd to file descriptor

func (*Listener) ToFile ΒΆ

func (l *Listener) ToFile() (err error)

ToFile to file

type MqttClient ΒΆ added in v0.1.6

type MqttClient struct {
	// contains filtered or unexported fields
}

MqttClient mqtt client

func NewMqttClient ΒΆ added in v0.1.6

func NewMqttClient(broker string, onConnect mqtt.OnConnectHandler) (m *MqttClient)

NewMqttClient new mqtt client

func (*MqttClient) Close ΒΆ added in v0.1.6

func (m *MqttClient) Close()

Close close

func (*MqttClient) Connect ΒΆ added in v0.1.6

func (m *MqttClient) Connect() (err error)

Connect connect

func (*MqttClient) IsConnected ΒΆ added in v0.1.6

func (m *MqttClient) IsConnected() bool

IsConnected is connected

func (*MqttClient) Publish ΒΆ added in v0.1.6

func (m *MqttClient) Publish(topic string, retained bool, payload []byte) (err error)

Publish publish

token.Wait(): Can also use '<-t.Done()' in releases > 1.2.0

func (*MqttClient) PublishNoWait ΒΆ added in v0.1.6

func (m *MqttClient) PublishNoWait(topic string, retained bool, payload []byte)

PublishNoWait publish no wait

func (*MqttClient) SafeClose ΒΆ added in v0.1.6

func (m *MqttClient) SafeClose()

SafeClose safe close

func (*MqttClient) String ΒΆ added in v0.1.6

func (m *MqttClient) String() string

String object to string

func (*MqttClient) Subscribe ΒΆ added in v0.1.6

func (m *MqttClient) Subscribe(topic string, callback mqtt.MessageHandler) (err error)

Subscribe subscribe

func (*MqttClient) SubscribeMulti ΒΆ added in v0.1.6

func (m *MqttClient) SubscribeMulti(topics map[string]byte, callback mqtt.MessageHandler) (err error)

SubscribeMulti subscribe multi

func (*MqttClient) SubscribeMultiNoWait ΒΆ added in v0.1.6

func (m *MqttClient) SubscribeMultiNoWait(topics map[string]byte, callback mqtt.MessageHandler)

SubscribeMultiNoWait subscribe multi no wait

func (*MqttClient) SubscribeNoWait ΒΆ added in v0.1.6

func (m *MqttClient) SubscribeNoWait(topic string, callback mqtt.MessageHandler)

SubscribeNoWait subscribe async no wait

func (*MqttClient) Unsubscribe ΒΆ added in v0.1.6

func (m *MqttClient) Unsubscribe(topics ...string) (err error)

Unsubscribe unsubscribe

func (*MqttClient) UnsubscribeNoWait ΒΆ added in v0.1.6

func (m *MqttClient) UnsubscribeNoWait(topics ...string)

UnsubscribeNoWait unsubscribe no wait

type OnFilter ΒΆ

type OnFilter func(x interface{}) bool

OnFilter on filter

type Poll ΒΆ

type Poll struct {
	// contains filtered or unexported fields
}

Poll event poll object

func NewPoll ΒΆ

func NewPoll() (p *Poll)

NewPoll create poll

func (*Poll) Begin ΒΆ

func (p *Poll) Begin() (err error)

Begin begin poll

func (*Poll) ControlAdd ΒΆ

func (p *Poll) ControlAdd(fd int, events uint32) error

ControlAdd control add

func (*Poll) ControlDel ΒΆ

func (p *Poll) ControlDel(fd int, events uint32) error

ControlDel control del

func (*Poll) ControlMod ΒΆ

func (p *Poll) ControlMod(fd int, events uint32) error

ControlMod control mod

func (*Poll) End ΒΆ

func (p *Poll) End()

End ...

func (*Poll) String ΒΆ

func (p *Poll) String() string

String object to string

func (*Poll) Trigger ΒΆ

func (p *Poll) Trigger(job interface{}) error

Trigger ...

func (*Poll) Wait ΒΆ

func (p *Poll) Wait(events []unix.EpollEvent, timeout int) (waits int, err error)

Wait ...

type PollEvent ΒΆ

type PollEvent struct {
	unix.EpollEvent
	Session *Session
}

PollEvent poll event

type SafeSlice ΒΆ

type SafeSlice struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SafeSlice safe slice

func NewSafeSlice ΒΆ

func NewSafeSlice(c int) *SafeSlice

NewSafeSlice creates a new 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 ΒΆ

func (s *SafeSlice) AppendSlice(ss *SafeSlice)

AppendSlice adds an items to the concurrent slice

func (*SafeSlice) Count ΒΆ

func (s *SafeSlice) Count() int

Count count

func (*SafeSlice) Fetch ΒΆ

func (s *SafeSlice) Fetch() []interface{}

Fetch fetch slice and renew

func (*SafeSlice) FetchWithLimit ΒΆ

func (s *SafeSlice) FetchWithLimit(limit int) []interface{}

FetchWithLimit fetch slice with limit

func (*SafeSlice) FilterOut ΒΆ

func (s *SafeSlice) FilterOut(f OnFilter) []interface{}

FilterOut filter an items out from the concurrent slice

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

func (*SafeSlice) Prepend ΒΆ

func (s *SafeSlice) Prepend(item interface{})

Prepend prepend an item to the concurrent slice

func (*SafeSlice) Shift ΒΆ

func (s *SafeSlice) Shift() (front interface{}, count int)

Shift shift slice and renew

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 NewSession ΒΆ

func NewSession(f int, c net.Conn, i *Io) *Session

NewSession new session

func (*Session) Close ΒΆ

func (n *Session) Close() error

Close close

func (*Session) CountOutQueue ΒΆ

func (n *Session) CountOutQueue() int

CountOutQueue count out queue

func (*Session) DecRef ΒΆ

func (n *Session) DecRef() int32

DecRef decrease reference count

func (*Session) GetAddr ΒΆ

func (n *Session) GetAddr() (string, bool)

GetAddr ...

func (*Session) GetConn ΒΆ

func (n *Session) GetConn() net.Conn

GetConn get conn

func (*Session) GetContext ΒΆ

func (n *Session) GetContext() interface{}

GetContext get context

func (*Session) GetFd ΒΆ

func (n *Session) GetFd() int

GetFd get fd

func (*Session) GetIo ΒΆ added in v0.1.2

func (n *Session) GetIo() *Io

GetService get service

func (*Session) GetKeepBuffer ΒΆ

func (n *Session) GetKeepBuffer() *Buffer

GetKeepBuffer get keep buffer

func (*Session) GetRemoteIP ΒΆ

func (n *Session) GetRemoteIP() string

GetRemoteIP get remote ip

func (*Session) GetStats ΒΆ

func (n *Session) GetStats() interface{}

GetStats get stats

func (*Session) IncRef ΒΆ

func (n *Session) IncRef() int32

IncRef increase reference count

func (*Session) PostWrite ΒΆ

func (n *Session) PostWrite(out []byte) (sent int, err error)

PostWrite post write

func (*Session) SetContext ΒΆ

func (n *Session) SetContext(c interface{})

SetContext set context

func (*Session) SetStats ΒΆ

func (n *Session) SetStats(s interface{})

SetStats set stats

func (*Session) Shutdown ΒΆ

func (n *Session) Shutdown(how int) error

Shutdown shutdown

func (*Session) String ΒΆ

func (n *Session) String() string

String ...

func (*Session) SubRef ΒΆ

func (n *Session) SubRef(ref int32) int32

SubRef subscribe reference count

func (*Session) Write ΒΆ

func (n *Session) Write(out []byte) (sent int, err error)

Write write

type Sockaddr ΒΆ

type Sockaddr unix.Sockaddr

Sockaddr sockaddr type definition

type UID ΒΆ

type UID int64

UID uid μ‚¬μš©μž ID μ •μ˜ νƒ€μž… KBO(CPB)의 uid, MLB의 vid κ°’

func (*UID) FromInt ΒΆ

func (u *UID) FromInt(i int64)

FromInt uid from int

func (*UID) FromString ΒΆ

func (u *UID) FromString(s string)

FromString uid from string

func (UID) IsInvalid ΒΆ

func (u UID) IsInvalid() bool

IsInvalid uid is invalid

func (*UID) ToInt ΒΆ

func (u *UID) ToInt() int64

ToInt uid to int

func (*UID) ToString ΒΆ

func (u *UID) ToString() string

ToString uid to string

type UnsafeMap ΒΆ

type UnsafeMap struct {
	Map map[uint64]interface{}
}

UnsafeMap safe map

func NewUnsafeMap ΒΆ

func NewUnsafeMap() *UnsafeMap

NewUnsafeMap creates a new unsafe map

func (*UnsafeMap) Count ΒΆ

func (m *UnsafeMap) Count() int

Count count

func (*UnsafeMap) Del ΒΆ

func (m *UnsafeMap) Del(key uint64)

Del deletes an item to a concurrent map

func (*UnsafeMap) Fetch ΒΆ

func (m *UnsafeMap) Fetch() map[uint64]interface{}

Fetch fetch map and renew

func (*UnsafeMap) Get ΒΆ

func (m *UnsafeMap) Get(key uint64) (interface{}, bool)

Get retrieves the value for a concurrent map item

func (*UnsafeMap) Init ΒΆ

func (m *UnsafeMap) Init()

Init init

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 ΒΆ

func (m *UnsafeMap) MarshalJSON() ([]byte, error)

MarshalJSON marshal json

func (*UnsafeMap) Set ΒΆ

func (m *UnsafeMap) Set(key uint64, value interface{})

Set adds an item to a concurrent map

func (*UnsafeMap) ToSlice ΒΆ

func (m *UnsafeMap) ToSlice() []UnsafeMapItem

ToSlice to slice

func (*UnsafeMap) Upsert ΒΆ

func (m *UnsafeMap) Upsert(key uint64, new interface{}, callback cmap.UpsertCb) (value interface{})

Upsert update or insert

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) Count ΒΆ

func (s *UnsafeSlice) Count() int

Count count

func (*UnsafeSlice) Fetch ΒΆ

func (s *UnsafeSlice) Fetch() []interface{}

Fetch fetch slice and renew

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

type WaitResult ΒΆ

type WaitResult struct {
	// contains filtered or unexported fields
}

WaitResult wait result

type WriteJob ΒΆ

type WriteJob struct {
	// contains filtered or unexported fields
}

WriteJob write job

func (*WriteJob) String ΒΆ

func (j *WriteJob) String() string

String string

func (*WriteJob) Work ΒΆ

func (j *WriteJob) Work() (err error)

Work work

Directories ΒΆ

Path Synopsis
app
test
tool

Jump to

Keyboard shortcuts

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