{"id":15857414,"url":"https://github.com/xtuc/schaloop","last_synced_at":"2025-04-01T19:42:35.275Z","repository":{"id":65989958,"uuid":"107600674","full_name":"xtuc/schaloop","owner":"xtuc","description":"Approach for event-driven Golang application","archived":false,"fork":false,"pushed_at":"2017-10-26T07:17:53.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T11:52:46.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xtuc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-19T21:29:44.000Z","updated_at":"2018-05-27T06:17:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"670bd6b5-ce21-4c13-a0cf-2dff8fa6014b","html_url":"https://github.com/xtuc/schaloop","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":"0.33333333333333337","last_synced_commit":"9638fcdc196e786f64d8584d7008dbb7cc91c089"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fschaloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fschaloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fschaloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtuc%2Fschaloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtuc","download_url":"https://codeload.github.com/xtuc/schaloop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246703253,"owners_count":20820378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T20:22:53.176Z","updated_at":"2025-04-01T19:42:35.256Z","avatar_url":"https://github.com/xtuc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schaloop\n--\n    import \"github.com/xtuc/schaloop\"\n\nEvent loop - approach for event-driven Golang application.\n\n\n### Design\n\nIt uses stack of work (that you enqueue, see API) which is processed by a single\nGoroutine. All writes are linearized, that way we can ensure the memory safety\nof the program.\n\n\nWork timeout\n\nTo avoid stopping the loop for too long, schaloop provides a timeout mechanism.\nWe are able to interrupt work using a `panic`. The error won't be propagated.\n\nReal thread (Not implemented)\n\nThe Goroutine impose some technical restrictions: - The work can not be resumed\nor aborted - We don't control the scheduling (where and when the loop runs)\n\nGo has a feature which allows any Goroutine to be assigned to a given system\nthread. Using the kernel primitives we are able to schedule and control the\nprocessing of the work more precisely (rlimits, priority, sleep, ...).\n\nUnfortunately there also some limitations. It seems not possible to properly\nstop/kill the thread without halting the entire program.\n\n## Usage\n\n```go\nvar (\n\t// Error will be returned if the work exceeded the timeout inside the event\n\t// loop.\n\tTIMEOUT_ERROR = errors.New(\"Timeout\")\n\n\t// Frequency at which work will be processed inside of the event loop.\n\tLOOP_FREQ = time.Duration(100 * time.Microsecond)\n)\n```\n\n#### type EventLoop\n\n```go\ntype EventLoop struct {\n}\n```\n\n\n#### func  NewEventLoop\n\n```go\nfunc NewEventLoop() *EventLoop\n```\nInitializes a new event loop Monitoring will be attached by default\n\n#### func (*EventLoop) DumpMonitor\n\n```go\nfunc (eventloop *EventLoop) DumpMonitor() string\n```\nDumps the monitoring inside the loop\n\n#### func (EventLoop) DumpStack\n\n```go\nfunc (eventloop EventLoop) DumpStack() (str string)\n```\nDumps the current execution stack of the loop\n\n#### func (*EventLoop) QueueWork\n\n```go\nfunc (eventloop *EventLoop) QueueWork(name string, fn func())\n```\nAdd new work to be processed eventually. Work resulting in a error will be\nprogragated.\n\n#### func (*EventLoop) QueueWorkFromChannel\n\n```go\nfunc (eventloop *EventLoop) QueueWorkFromChannel(name string, work interface{}, fn func(interface{}))\n```\nAdd new work each time a new message will be send in the channel. Work resulting\nin a error will be progragated.\n\n#### func (*EventLoop) QueueWorkFromChannelWithError\n\n```go\nfunc (eventloop *EventLoop) QueueWorkFromChannelWithError(name string, work interface{}, fn func(interface{}), errorHandler func(err error))\n```\nSame as QueueWorkFromChannel with a custom error handler\n\n#### func (*EventLoop) QueueWorkWithError\n\n```go\nfunc (eventloop *EventLoop) QueueWorkWithError(name string, fn func(), errorHandler func(err error))\n```\nSame as QueueWork with a custom error handler\n\n#### func (*EventLoop) StartWithTimeout\n\n```go\nfunc (eventloop *EventLoop) StartWithTimeout(timeout time.Duration)\n```\nStart the event loop\n\n#### func (*EventLoop) Stop\n\n```go\nfunc (eventloop *EventLoop) Stop()\n```\nStop the loop\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Fschaloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtuc%2Fschaloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtuc%2Fschaloop/lists"}