Categorygithub.com/cppis/elio
modulepackage
0.2.5
Repository: https://github.com/cppis/elio.git
Documentation: pkg.go.dev

# 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
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AppDebug app log debug.
AppError app log error.
AppFatal app log fatal.
AppInfo app log info.
AppPanic app log panic.
AppTrace app log trace.
AppWarn app log warn.
DebugEnabled debug enabled.
DeleteSession delete session.
DumpDebug packet log debug.
DumpError packet log error.
DumpFatal packet log fatal.
DumpInfo packet log info.
DumpPanic packet log panic.
DumpTrace packet log trace.
DumpWarn packet log warn.
Elio get elio.
ErrorEnabled error enabled.
FatalEnabled fatal enabled.
GenIO gen io.
GetBaseAndConfig get base and config.
GetBasename get base name.
GetBasepath get base path.
GetCurrentIO get current io.
GetFdFromConn this function is linux only.
GetFdFromLisener this function is linux only.
GetMaxInCount get max in count.
Host host.
InfoEnabled info enabled.
InitLog init log.
IOsFromString IO models from string.
LogDebug app log debug.
LogError app log error.
LogFatal app log fatal.
LogInfo app log info.
LogPanic app log panic.
LogParams get log params.
LogTrace app log trace.
LogWarn app log warn.
NewApp new app.
NewClock new clock.
NewConfig new config.
NewContext create new context.
NewDivMap new division map.
NewEventQueue new event queue.
NewIo new server.
NewIoDefault new io default.
NewIoHost new host.
NewIoPoll new io poll.
NewMqttClient new mqtt client.
NewPoll create poll.
NewSafeSlice creates a new safe slice.
NewSession new session.
NewUnsafeMap creates a new unsafe map.
NewUnsafeSlice creates a new concurrent slice.
PacketDebug packet log debug.
PacketError packet log error.
PacketFatal packet log fatal.
PacketInfo packet log info.
PacketPanic packet log panic.
PacketTrace packet log trace.
PacketWarn packet log warn.
PanicEnabled panic enabled.
PanicParse panic parse.
ProvideConfigIo returns service config.
ProvideIo provide service.
SetLimit set limit.
StackParse stack parse.
StartUp start up.
StopDown stop down.
T2pOnParse control on parse.
T2PParse T2P parse.
T2pParseCommand parse command.
TraceEnabled debug enabled.
WarnEnabled debug enabled.
WithLevel with level.

# Constants

CaptureInterval capture interval.
Close disconnect connection.
CloseAll disconnect all connections.
todo range 별 클라 μ•‘μ…˜μ„ μ •ν•˜λŠ”κ²Œ..? ex) 100λ²ˆλŒ€λŠ” μ—λŸ¬λ¦¬ν„΄ ν›„ νƒ€μ΄ν‹€λ‘œ 이동 200λ²ˆλŒ€λŠ” μ—λŸ¬λ§Œ 좜λ ₯ μ΄λŸ°μ‹μœΌλ‘œ..
DefaultCapacity default capacity.
DefaultDefIOInCount default def IO in count.
DefaultInterval default interval.
DefaultPollInCount default poll in count.
DevLogger development logger.
Duration5m duration 5 minute.
todo μΆ”ν›„ μ‚­μ œ μ˜ˆμ •, μƒ˜ν”Œ μ„œλ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ˜ μ½”λ“œλ‘œ ꡐ체 ν•„μš” (μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ—λ§Œ 쑴재).
todo μΆ”ν›„ μ‚­μ œ μ˜ˆμ •, μƒ˜ν”Œ μ„œλ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ˜ μ½”λ“œλ‘œ ꡐ체 ν•„μš” (μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ—λ§Œ 쑴재).
todo μΆ”ν›„ μ‚­μ œ μ˜ˆμ •, μƒ˜ν”Œ μ„œλ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ˜ μ½”λ“œλ‘œ ꡐ체 ν•„μš” (μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ—λ§Œ 쑴재).
todo μΆ”ν›„ μ‚­μ œ μ˜ˆμ •, μƒ˜ν”Œ μ„œλ²„μ—μ„œ μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ˜ μ½”λ“œλ‘œ ꡐ체 ν•„μš” (μ‚¬μš©ν•˜λŠ” μ½”λ“œλŠ” μƒλ‹¨μ—λ§Œ 쑴재).
ExamLogger example logger.
FlagAllout disconnect all flag.
FlagNone default none flag.
FlagSafeTerminate safe terminate flag.
FlagStop stop listen flag.
FlagTerminate terminate flag.
FlagTerminateAfter5m exit after 5 minute flag.
InvalidDivIndex partition invalid index.
IoAuto IO auto.
IoDefault IO default(golang method).
IoPoll IO poll.
Listen listen.
LogCode code.
LogContext context.
LogDump dump.
LogErrorCode errorcode.
LogGitHash git last commit hash.
LogHost host.
LogIP ip.
LogMatchKey match key.
LogName name.
LogObject object.
LogPayload payload.
LogProject project.
LogRecover recover.
LogRoom room.
LogService service.
LogSession session.
LogStage stage.
LogState state.
LogSuid server unique id.
LogUuid user unique id.
LogWalltime walltime.
MetricAppIoInCountf app io in count metric.
MetricAppIoInSizef app io in size metric.
MetricAppIoOutCountf app io out count metric.
MetricAppIoOutSizef app io out size metric.
MetricAppSessionsf app session metric.
MetricPubAppStatesf publish app state metric.
MetricSubAppStatesf subscribe app state metric.
None indicates that no action should occur following an event.
No description provided by the author
ProdLogger production logger.
QueueCapacity queue default capacity.
이미 λ°©μ•ˆμ— μžˆλŠ” μƒνƒœμΈ 경우.
이미 둜그인 μƒνƒœμΈ 경우.
μ€‘λ³΅λ‘œκ·ΈμΈ.
Frontend & Relayer.
Frontend & Relayer.
Frontend & Relayer.
Frontend & Relayer.
Frontend & Relayer.
http 톡신 μ—λŸ¬.
message marshal error.
λ°©μ•ˆμ— μžˆλŠ” μƒνƒœκ°€ μ•„λ‹Œ 경우.
둜그인 μƒνƒœκ°€ μ•„λ‹Œ 경우.
방이 쑴재 & μœ μ €λ₯Ό κΈ°λ‹€λ¦¬λŠ” μƒνƒœκ°€ μ•„λ‹Œ 경우.
packet unpack error.
SafeTermiate close the listen and exit when no user.
Shut close the listen.
ShutRd shut rd.
ShutRdWr shut rdwr.
ShutWr shut wr.
SigInt sig int.
SigTerm sig term.
StatsDAddress statsd address.
StatsDInterval capture interval.
todo range 별 클라 μ•‘μ…˜μ„ μ •ν•˜λŠ”κ²Œ..? ex) 100λ²ˆλŒ€λŠ” μ—λŸ¬λ¦¬ν„΄ ν›„ νƒ€μ΄ν‹€λ‘œ 이동 200λ²ˆλŒ€λŠ” μ—λŸ¬λ§Œ 좜λ ₯ μ΄λŸ°μ‹μœΌλ‘œ..
Termiate terminate the server.
TermiateAfter5m shutdown after 5 minute.

# Variables

GetByteBuffer returns an empty byte buffer from the pool, exported from gnet/bytebuffer.
PutByteBuffer returns byte buffer to the pool, exported from gnet/bytebuffer.
UIDInvalid uid invalid.

# Structs

App app.
AppMetrics app metrics.
Buffer is a helper type for managing input streams from inside the Data event.
Clock clock.
Config config.
ConfigIo config service.
Context implementation.
DivMap division map.
EnvApp env app ELIO_LOG_LEVEL ELIO_LOG_OUTS ELIO_LOG_JSON ELIO_LOG_NOCOLOR ELIO_IN_METRIC ELIO_IN_PPROF.
EventQueue event queue.
Io IO.
IoHost host.
Listener listener.
MqttClient mqtt client.
Poll event poll object.
PollEvent poll event.
SafeSlice safe slice.
SafeSliceItem contains the index/value pair of an item in a concurrent slice.
Session session.
UnsafeMap safe map.
UnsafeMapItem contains a key/value pair item of a concurrent map.
UnsafeSlice safe slice.
UnsafeSliceItem contains the index/value pair of an item in a concurrent slice.
WaitResult wait result.
WriteJob write job.

# Interfaces

Alarm alarm interface.
Contexter interface.
Event event interface.
Io I/O model.
Job job interface.
Service service.

# Type aliases

Action is an action that occurs after the completion of an event.
ByteBuffer is the alias of bytebufferpool.ByteBuffer.
DivCallback metric callback.
Fnv32 fnv32 type definition.
Fnv64 fnv64 type definition.
IOs io models type definition.
OnFilter on filter.
Sockaddr sockaddr type definition.
UID uid μ‚¬μš©μž ID μ •μ˜ νƒ€μž… KBO(CPB)의 uid, MLB의 vid κ°’.