{"id":21682336,"url":"https://github.com/beevik/timerqueue","last_synced_at":"2025-07-30T11:38:59.288Z","repository":{"id":27108322,"uuid":"30575941","full_name":"beevik/timerqueue","owner":"beevik","description":"A priority queue for timed events, written in go.","archived":false,"fork":false,"pushed_at":"2024-05-30T02:17:22.000Z","size":9,"stargazers_count":34,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T06:52:57.978Z","etag":null,"topics":["go","priority-queue","priorityqueue","scheduler","scheduling","scheduling-timers","timer","timer-queue","timerqueue"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beevik.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-10T05:07:07.000Z","updated_at":"2025-01-29T20:58:56.000Z","dependencies_parsed_at":"2024-05-30T04:47:42.289Z","dependency_job_id":"6ebb06db-cd4b-409b-b2b1-507e402f6063","html_url":"https://github.com/beevik/timerqueue","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/beevik/timerqueue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Ftimerqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Ftimerqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Ftimerqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Ftimerqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beevik","download_url":"https://codeload.github.com/beevik/timerqueue/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beevik%2Ftimerqueue/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267858872,"owners_count":24155980,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","priority-queue","priorityqueue","scheduler","scheduling","scheduling-timers","timer","timer-queue","timerqueue"],"created_at":"2024-11-25T15:35:43.013Z","updated_at":"2025-07-30T11:38:59.261Z","avatar_url":"https://github.com/beevik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/beevik/timerqueue?status.svg)](https://godoc.org/github.com/beevik/timerqueue)\n\ntimerqueue\n==========\n\nThe timerqueue package implements a priority queue for objects scheduled to\nperform actions at clock times.\n\n## Example: Scheduling timers\n\nThe following code declares an object implementing the `Timer` interface,\ncreates a timerqueue, and adds three events to the timerqueue.\n\n```go\ntype event int\n\nfunc (e event) OnTimer(t time.Time) {\n    fmt.Printf(\"event.OnTimer %d fired at %v\\n\", int(e), t)\n}\n\nqueue := timerqueue.New()\nqueue.Schedule(event(1), time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC))\nqueue.Schedule(event(2), time.Date(2015, 1, 3, 0, 0, 0, 0, time.UTC))\nqueue.Schedule(event(3), time.Date(2015, 1, 2, 0, 0, 0, 0, time.UTC))\n\n```\n\n## Example: Peeking at the next timer to be scheduled\n\nUsing the queue initialized in the first example, the following code\nexamines the head of the timerqueue and outputs the id and time of\nthe event found there.\n\n```go\ne, t := queue.PeekFirst()\nif e != nil {\n    fmt.Printf(\"Event %d will be first to fire at %v.\\n\", int(e.(event)), t)\n    fmt.Printf(\"%d events remain in the timerqueue.\", queue.Len())\n}\n```\n\nOutput:\n```\nEvent 1 will be first to fire at 2015-01-01 00:00:00 +0000 UTC.\n3 events remain in the timerqueue.\n```\n\n## Example: Popping the next timer to be scheduled\n\nUsing the queue initialized in the first example, this code\nremoves the next timer to be executed until the queue is empty.\n\n```go\nfor queue.Len() \u003e 0 {\n    e, t := queue.PopFirst()\n    fmt.Printf(\"Event %d fires at %v.\\n\", int(e.(event)), t)\n}\n```\n\nOutput:\n```\nEvent 1 fires at 2015-01-01 00:00:00 +0000 UTC.\nEvent 3 fires at 2015-01-02 00:00:00 +0000 UTC.\nEvent 2 fires at 2015-01-03 00:00:00 +0000 UTC.\n```\n\n## Example: Issuing OnTimer callbacks with Advance\n\nThe final example shows how to dispatch OnTimer callbacks to\ntimers using the timerqueue's Advance method.\n\nAdvance calls the OnTimer method for each timer scheduled\nbefore the requested time. Timers are removed from the timerqueue\nin order of their scheduling.\n\n```go\n// Call the OnTimer method for each event scheduled before\n// January 10, 2015. Pop the called timer from the queue.\nqueue.Advance(time.Date(2015, 1, 10, 0, 0, 0, 0, time.UTC))\n```\n\nOutput:\n```\nevent.OnTimer 1 fired at 2015-01-01 00:00:00 +0000 UTC.\nevent.OnTimer 3 fired at 2015-01-02 00:00:00 +0000 UTC.\nevent.OnTimer 2 fired at 2015-01-03 00:00:00 +0000 UTC.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeevik%2Ftimerqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeevik%2Ftimerqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeevik%2Ftimerqueue/lists"}