{"id":16874519,"url":"https://github.com/joway/pond","last_synced_at":"2025-04-11T11:25:26.653Z","repository":{"id":57562777,"uuid":"331519232","full_name":"joway/pond","owner":"joway","description":"Generic Object Pool for Golang.","archived":false,"fork":false,"pushed_at":"2021-08-12T08:36:31.000Z","size":30,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T07:51:09.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joway.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":"2021-01-21T04:58:54.000Z","updated_at":"2025-02-12T06:39:12.000Z","dependencies_parsed_at":"2022-09-17T14:10:58.828Z","dependency_job_id":null,"html_url":"https://github.com/joway/pond","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/joway%2Fpond","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fpond/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fpond/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joway%2Fpond/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joway","download_url":"https://codeload.github.com/joway/pond/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248382848,"owners_count":21094563,"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-13T15:33:07.242Z","updated_at":"2025-04-11T11:25:26.627Z","avatar_url":"https://github.com/joway.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pond\n\n![GitHub release](https://img.shields.io/github/tag/joway/pond.svg?label=release)\n[![Go Report Card](https://goreportcard.com/badge/github.com/joway/pond)](https://goreportcard.com/report/github.com/joway/pond)\n[![codecov](https://codecov.io/gh/joway/pond/branch/master/graph/badge.svg?token=Y1YO11FZKU)](https://codecov.io/gh/joway/pond)\n[![CircleCI](https://circleci.com/gh/joway/pond.svg?style=shield)](https://circleci.com/gh/joway/pond)\n\nGeneric Object Pool for Golang.\n\nIt has been used in production and serve millions of QPS.\n\n## Adopters\n\n- [Hive](https://github.com/joway/hive): A high-efficiency Goroutine Pool.\n\n## Get Started\n\n```go\ntype conn struct {\n    addr string\n}\n\nctx := context.Background()\ncfg := pond.NewDefaultConfig()\n//required\ncfg.ObjectCreateFactory = func (ctx context.Context) (interface{}, error) {\n    return \u0026conn{addr: \"127.0.0.1\"}, nil\n}\n//optional\ncfg.ObjectValidateFactory = func (ctx context.Context, object interface{}) bool {\n    c := object.(*conn)\n    return c.addr != \"\"\n}\n//optional\ncfg.ObjectDestroyFactory = func (ctx context.Context, object interface{}) error {\n    c := object.(*conn)\n    c.addr = \"\"\n    return nil\n}\n\np, err := pond.New(cfg)\nif err != nil {\n    log.Fatal(err)\n}\n\nobj, err := p.BorrowObject(ctx)\nif err != nil {\n    log.Fatal(err)\n}\ndefer p.ReturnObject(ctx, obj)\nfmt.Printf(\"get conn: %v\\n\", obj.(*conn).addr)\n```\n\n## Configuration\n\n| Option                        | Default        | Description  |\n| ------------------------------|:--------------:| :------------|\n| MaxSize                       | 10             |The capacity of the pool. If MaxSize \u003c= 0, no capacity limit.|\n| MinIdle                       | 0              |The minimum size of the idle objects.|\n| MaxIdle                       | 10             |The maximal size of the idle objects. Idle objects exceeding MaxIdle will be evicted.|\n| MinIdleTime                   | 5m             |The minimum time that idle object should be reserved.|\n| Nonblocking                   | false          |The blocking policy. If true, it will return ErrPoolExhausted when pool is exhausted.|\n| AutoEvict                     | true           |Enable auto evict idle objects. When true, pool will create a goroutine to start a evictor.|\n| EvictInterval                 | 30s            |The interval between evict.|\n| MaxValidateAttempts           | 1              |The maximal attempts to validate object.|\n| ObjectCreateFactory           | **required**   |The factory of creating object.|\n| ObjectValidateFactory         | none           |The factory of validating object.|\n| ObjectDestroyFactory          | none           |The factory of destroying object.|\n\n## Benchmark\n\nCompare with:\n\n- [go-commons-pool](https://github.com/jolestar/go-commons-pool):\n\n```text\nBenchmarkPool-8                          3116902               358 ns/op              71 B/op          2 allocs/op\nBenchmarkPoolWithConcurrent-8            3683365               326 ns/op               0 B/op          0 allocs/op\nBenchmarkCommonsPool-8                    1828080               669 ns/op             103 B/op          3 allocs/op\nBenchmarkCommonsPoolWithConcurrent-8      1715344               703 ns/op              32 B/op          1 allocs/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Fpond","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoway%2Fpond","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoway%2Fpond/lists"}