{"id":13413407,"url":"https://github.com/alexsniffin/gosd","last_synced_at":"2026-01-12T00:47:07.560Z","repository":{"id":56855241,"uuid":"264775039","full_name":"alexsniffin/gosd","owner":"alexsniffin","description":"A library for scheduling when to dispatch a message to a channel","archived":false,"fork":false,"pushed_at":"2022-08-17T01:47:34.000Z","size":73,"stargazers_count":24,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:52:19.301Z","etag":null,"topics":["go","messaging","scheduling","streaming"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexsniffin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-17T23:19:51.000Z","updated_at":"2024-03-20T22:22:12.000Z","dependencies_parsed_at":"2022-09-26T18:21:48.222Z","dependency_job_id":null,"html_url":"https://github.com/alexsniffin/gosd","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsniffin%2Fgosd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsniffin%2Fgosd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsniffin%2Fgosd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsniffin%2Fgosd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexsniffin","download_url":"https://codeload.github.com/alexsniffin/gosd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221498744,"owners_count":16833056,"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":["go","messaging","scheduling","streaming"],"created_at":"2024-07-30T20:01:39.630Z","updated_at":"2026-01-12T00:47:07.517Z","avatar_url":"https://github.com/alexsniffin.png","language":"Go","funding_links":[],"categories":["Messaging","消息","Relational Databases","消息系统","机器学习"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","SQL 查询语句构建库","Advanced Console UIs"],"readme":"# gosd\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n[![Build Status](https://travis-ci.com/alexsniffin/gosd.svg?branch=master)](https://travis-ci.com/alexsniffin/gosd)\n[![Go Report Card](https://goreportcard.com/badge/github.com/alexsniffin/gosd)](https://goreportcard.com/report/github.com/alexsniffin/gosd)\n[![codecov](https://codecov.io/gh/alexsniffin/gosd/branch/master/graph/badge.svg)](https://codecov.io/gh/alexsniffin/gosd)\n\ngo-schedulable-dispatcher (gosd), is a library for scheduling when to dispatch a message to a channel.\n\n## Implementation\nThe implementation provides an interactive API to handle scheduling messages with a dispatcher. Messages are ingested and processed into a heap based priority queue. Order is not guaranteed by default when messages have the same scheduled time, but can be changed through the config. By guaranteeing order, performance will be slightly worse. If strict-ordering isn't critical to your application, it's recommended to keep the default setting.\n\n## Example\n```go\n// create instance of dispatcher\ndispatcher, err := gosd.NewDispatcher[string](\u0026gosd.DispatcherConfig{\n    IngressChannelSize:  100,\n    DispatchChannelSize: 100,\n    MaxMessages:         100,\n    GuaranteeOrder:      false,\n})\ncheckErr(err)\n\n// spawn process\ngo dispatcher.Start()\n\n// schedule a message\ndispatcher.IngressChannel() \u003c- \u0026gosd.ScheduledMessage[string]{\n    At:      time.Now().Add(1 * time.Second),\n    Message: \"Hello World in 1 second!\",\n}\n\n// wait for the message\nmsg := \u003c-dispatcher.DispatchChannel()\n\nfmt.Println(msg)\n// Hello World in 1 second!\n\n// shutdown without deadline\ndispatcher.Shutdown(context.Background(), false)\n```\n\nMore examples under [examples](examples).\n\n## Benchmarking\nTested with Go 1.19 and 1000 messages per iteration.\n```\ngoos: windows\ngoarch: amd64\npkg: github.com/alexsniffin/gosd/v2\ncpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz\nBenchmark_integration_unordered\nBenchmark_integration_unordered-12                           307           3690528 ns/op\nBenchmark_integration_unorderedSmallBuffer\nBenchmark_integration_unorderedSmallBuffer-12                274           4120104 ns/op\nBenchmark_integration_unorderedSmallHeap\nBenchmark_integration_unorderedSmallHeap-12                  348           3452703 ns/op\nBenchmark_integration_ordered\nBenchmark_integration_ordered-12                             135           8650709 ns/op\nBenchmark_integration_orderedSmallBuffer\nBenchmark_integration_orderedSmallBuffer-12                  207           5867338 ns/op\nBenchmark_integration_orderedSmallHeap\nBenchmark_integration_orderedSmallHeap-12                    350           3592990 ns/op\nBenchmark_integration_orderedSameTime\nBenchmark_integration_orderedSameTime-12                     133           8909311 ns/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsniffin%2Fgosd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexsniffin%2Fgosd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsniffin%2Fgosd/lists"}