{"id":15074377,"url":"https://github.com/t34-dev/go-grpc-pool","last_synced_at":"2025-04-10T18:44:59.775Z","repository":{"id":253353964,"uuid":"843115408","full_name":"t34-dev/go-grpc-pool","owner":"t34-dev","description":"This package provides a connection pool for gRPC clients in Go, allowing efficient management and reuse of gRPC connections.","archived":false,"fork":false,"pushed_at":"2024-10-03T15:42:43.000Z","size":859,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T03:05:09.639Z","etag":null,"topics":["client","connector","fast","golang","grpc","pool","provider"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t34-dev.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}},"created_at":"2024-08-15T20:14:48.000Z","updated_at":"2024-12-24T01:47:06.000Z","dependencies_parsed_at":"2024-08-27T00:20:27.599Z","dependency_job_id":"7cd09933-3039-4e0e-8688-a21d9285bbd7","html_url":"https://github.com/t34-dev/go-grpc-pool","commit_stats":{"total_commits":26,"total_committers":4,"mean_commits":6.5,"dds":"0.34615384615384615","last_synced_commit":"8d1dc4407fdf88f3fbebe2c8aedb0ba80d825e97"},"previous_names":["t34-dev/go-grpc-pool"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t34-dev%2Fgo-grpc-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t34-dev%2Fgo-grpc-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t34-dev%2Fgo-grpc-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t34-dev%2Fgo-grpc-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t34-dev","download_url":"https://codeload.github.com/t34-dev/go-grpc-pool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271925,"owners_count":21075800,"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":["client","connector","fast","golang","grpc","pool","provider"],"created_at":"2024-09-25T03:32:43.138Z","updated_at":"2025-04-10T18:44:59.765Z","avatar_url":"https://github.com/t34-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)\n[![Coverage Status](https://coveralls.io/repos/github/t34-dev/go-grpc-pool/badge.svg?branch=main\u0026ver=1742903369)](https://coveralls.io/github/t34-dev/go-grpc-pool?branch=main\u0026ver=1742903369)\n![Go Version](https://img.shields.io/badge/Go-1.22-blue?logo=go\u0026ver=1742903369)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/t34-dev/go-grpc-pool?ver=1742903369)\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/t34-dev/go-grpc-pool?sort=semver\u0026style=flat\u0026logo=git\u0026logoColor=white\u0026label=Latest%20Version\u0026color=blue\u0026ver=1742903369)\n\n# gRPC Connection Pool\n\nThis package provides a connection pool for gRPC clients in Go, allowing efficient management and reuse of gRPC connections.\n\n![TypeScript WebSocket Client Logo](./example.gif)\n\n## Features\n\n- Configurable minimum and maximum number of connections\n- Automatic connection creation and cleanup\n- Idle timeout for unused connections\n- Concurrent-safe connection management\n- Simple API for getting and releasing connections\n\n## Installation\n\nTo install the gRPC connection pool package, use the following command:\n\n```bash\ngo get github.com/t34-dev/go-grpc-pool\n```\n\nEnsure that you have Go modules enabled in your project.\n\n## Usage\n\nHere's a basic example of how to use the gRPC connection pool in your project:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/t34-dev/go-grpc-pool\"\n\t\"google.golang.org/grpc\"\n\t\"google.golang.org/grpc/credentials/insecure\"\n)\n\nfunc main() {\n\t// Define a factory function to create gRPC connections\n\tfactory := func() (*grpc.ClientConn, error) {\n\t\treturn grpc.Dial(\"localhost:50053\",\n\t\t\tgrpc.WithTransportCredentials(insecure.NewCredentials()),\n\t\t\tgrpc.WithBlock(),\n\t\t\tgrpc.WithTimeout(5*time.Second))\n\t}\n\n\t// Create a new connection pool\n\tpool, err := grpcpool.NewPool(factory, grpcpool.PoolOptions{\n\t\tMinConn:     2,\n\t\tMaxConn:     10,\n\t\tIdleTimeout: 5 * time.Minute,\n\t\tWaitGetConn: 20 * time.Second,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create pool: %v\", err)\n\t}\n\tdefer pool.Close()\n\n\t// Get a connection from the pool\n\tconn, err := pool.Get()\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to get connection: %v\", err)\n\t}\n\tdefer conn.Free() // Return the connection to the pool when done\n\n\t// Use the connection to make gRPC calls\n\tclient := yourpackage.NewYourServiceClient(conn.GetConn())\n\tresp, err := client.YourMethod(context.Background(), \u0026yourpackage.YourRequest{})\n\tif err != nil {\n\t\tlog.Fatalf(\"Error calling YourMethod: %v\", err)\n\t}\n\n\tlog.Printf(\"Response: %v\", resp)\n}\n```\n\n## Configuration\n\nThe `PoolOptions` struct allows you to configure the connection pool:\n\n- `MinConn`: Minimum number of connections to maintain in the pool\n- `MaxConn`: Maximum number of connections allowed in the pool\n- `IdleTimeout`: Duration after which idle connections are closed\n- `WaitGetConn`: Maximum duration to wait for an available connection\n- `Logger`: Optional logger interface for debugging\n\n## Testing\n\nTo run the tests for this package, use the following command:\n\n```bash\nmake test\n```\n\n## Development\n\nTo generate protobuf files (if needed):\n\n```bash\nmake protoc\n```\n\nTo run the example server:\n\n```bash\nmake server\n```\n\nTo run the example client:\n\n```bash\nmake client\n```\n\n## License\n\nThis project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n\n---\n\nDeveloped with ❤️ by [T34](https://github.com/t34-dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft34-dev%2Fgo-grpc-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft34-dev%2Fgo-grpc-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft34-dev%2Fgo-grpc-pool/lists"}