{"id":13413068,"url":"https://github.com/vardius/gollback","last_synced_at":"2025-06-30T09:33:06.363Z","repository":{"id":35137498,"uuid":"186094005","full_name":"vardius/gollback","owner":"vardius","description":"Go asynchronous simple function utilities, for managing execution of closures and callbacks","archived":false,"fork":false,"pushed_at":"2023-02-16T21:51:46.000Z","size":35,"stargazers_count":125,"open_issues_count":1,"forks_count":13,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T02:45:17.630Z","etag":null,"topics":["callback","cancel","closure","future","golang","goroutine","promise","race","retry","timeout"],"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/vardius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["vardius"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-05-11T05:56:37.000Z","updated_at":"2025-03-26T14:16:56.000Z","dependencies_parsed_at":"2024-01-08T15:34:34.296Z","dependency_job_id":null,"html_url":"https://github.com/vardius/gollback","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/vardius/gollback","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Fgollback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Fgollback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Fgollback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Fgollback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vardius","download_url":"https://codeload.github.com/vardius/gollback/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Fgollback/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262747763,"owners_count":23358036,"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":["callback","cancel","closure","future","golang","goroutine","promise","race","retry","timeout"],"created_at":"2024-07-30T20:01:33.060Z","updated_at":"2025-06-30T09:33:05.687Z","avatar_url":"https://github.com/vardius.png","language":"Go","readme":"⚙️ gollback\n================\n[![Build Status](https://travis-ci.org/vardius/gollback.svg?branch=master)](https://travis-ci.org/vardius/gollback)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vardius/gollback)](https://goreportcard.com/report/github.com/vardius/gollback)\n[![codecov](https://codecov.io/gh/vardius/gollback/branch/master/graph/badge.svg)](https://codecov.io/gh/vardius/gollback)\n[![](https://godoc.org/github.com/vardius/gollback?status.svg)](https://pkg.go.dev/github.com/vardius/gollback)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/vardius/gollback/blob/master/LICENSE.md)\n\n\u003cimg align=\"right\" height=\"180px\" src=\"https://github.com/vardius/gorouter/blob/master/website/src/static/img/logo.png?raw=true\" alt=\"logo\" /\u003e\n\ngollback - Go asynchronous simple function utilities, for managing execution of closures and callbacks\n\n📖 ABOUT\n==================================================\nContributors:\n\n* [Rafał Lorenz](http://rafallorenz.com)\n\nWant to contribute ? Feel free to send pull requests!\n\nHave problems, bugs, feature ideas?\nWe are using the github [issue tracker](https://github.com/vardius/gollback/issues) to manage them.\n\n## 📚 Documentation\n\nFor __examples__ **visit [godoc#pkg-examples](http://godoc.org/github.com/vardius/gollback#pkg-examples)**\n\nFor **GoDoc** reference, **visit [pkg.go.dev](https://pkg.go.dev/github.com/vardius/gollback)**\n\n🚏 HOW TO USE\n==================================================\n\n## 🚅 Benchmark\n**CPU: 3,3 GHz Intel Core i7**\n\n**RAM: 16 GB 2133 MHz LPDDR3**\n\n```bash\n➜  gollback git:(master) ✗ go test -bench=. -cpu=4 -benchmem\ngoos: darwin\ngoarch: amd64\npkg: github.com/vardius/gollback\nBenchmarkRace-4    \t  566022\t      2608 ns/op\t     663 B/op\t       5 allocs/op\nBenchmarkAll-4     \t 5052489\t       241 ns/op\t      42 B/op\t       1 allocs/op\nBenchmarkRetry-4   \t206430384\t         5.93 ns/op\t       0 B/op\t       0 allocs/op\nPASS\nok  \tgithub.com/vardius/gollback\t31.741s\n```\n\n## Race\n\u003e Race method returns a response as soon as one of the callbacks in an iterable resolves with the value that is not an error, otherwise last error is returne\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/vardius/gollback\"\n)\n\nfunc main() {\n\tr, err := gollback.Race(\n\t\tcontext.Background(),\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\ttime.Sleep(3 * time.Second)\n\t\t\treturn 1, nil\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn nil, errors.New(\"failed\")\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn 3, nil\n\t\t},\n\t)\n}\n```\n\n## All\n\u003e All method returns when all of the callbacks passed as an iterable have finished, returned responses and errors are ordered according to callback order\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/vardius/gollback\"\n)\n\nfunc main() {\n\trs, errs := gollback.All(\n\t\tcontext.Background(),\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\ttime.Sleep(3 * time.Second)\n\t\t\treturn 1, nil\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn nil, errors.New(\"failed\")\n\t\t},\n\t\tfunc(ctx context.Context) (interface{}, error) {\n\t\t\treturn 3, nil\n\t\t},\n\t)\n}\n```\n\n## Retry\n\u003e Retry method retries callback given amount of times until it executes without an error, when retries = 0 it will retry infinitely\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/vardius/gollback\"\n)\n\nfunc main() {\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\t// Will retry infinitely until timeouts by context (after 5 seconds)\n\tres, err := gollback.Retry(ctx, 0, func(ctx context.Context) (interface{}, error) {\n\t\treturn nil, errors.New(\"failed\")\n\t})\n\n\t// Will retry 5 times or will timeout by context (after 5 seconds)\n\tres, err := gollback.Retry(ctx, 5, func(ctx context.Context) (interface{}, error) {\n\t\treturn nil, errors.New(\"failed\")\n\t})\n}\n```\n\n📜 [License](LICENSE.md)\n-------\n\nThis package is released under the MIT license. See the complete license in the package\n","funding_links":["https://github.com/sponsors/vardius"],"categories":["Goroutines","Relational Databases","Go","Goroutines `goroutines的管理和使用`"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","SQL 查询语句构建库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Fgollback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvardius%2Fgollback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Fgollback/lists"}