{"id":19312136,"url":"https://github.com/bigcommerce/gruf-balancer","last_synced_at":"2025-04-22T15:32:00.590Z","repository":{"id":42366185,"uuid":"344629664","full_name":"bigcommerce/gruf-balancer","owner":"bigcommerce","description":"Percentage-based balancing of gruf-client requests for testing","archived":false,"fork":false,"pushed_at":"2024-02-05T22:16:12.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-08-10T19:23:20.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/bigcommerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-04T22:45:54.000Z","updated_at":"2024-08-10T19:23:20.573Z","dependencies_parsed_at":"2024-02-05T23:27:20.173Z","dependency_job_id":"befc4d4d-03e3-4cbb-9929-0c6f429a462d","html_url":"https://github.com/bigcommerce/gruf-balancer","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"723e08bd04fc60b32896db3a5593264ce833d800"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigcommerce","download_url":"https://codeload.github.com/bigcommerce/gruf-balancer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223900362,"owners_count":17222028,"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-11-10T00:33:03.149Z","updated_at":"2024-11-10T00:33:03.674Z","avatar_url":"https://github.com/bigcommerce.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gruf-balancer - Testing framework for Gruf Clients\n\n[![CircleCI](https://circleci.com/gh/bigcommerce/gruf-balancer/tree/main.svg?style=svg)](https://circleci.com/gh/bigcommerce/gruf-balancer/tree/main) [![Gem Version](https://badge.fury.io/rb/gruf-balancer.svg)](https://badge.fury.io/rb/gruf-balancer)\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/5644b038f277f345d0b3/maintainability)](https://codeclimate.com/github/bigcommerce/gruf-balancer/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/5644b038f277f345d0b3/test_coverage)](https://codeclimate.com/github/bigcommerce/gruf-balancer/test_coverage) \n\nProvides an integration for [gruf](https://github.com/bigcommerce/gruf) Ruby gRPC framework, allowing testing \nvarious outbound `Gruf::Client` calls on a percentage-basis, letting you balance requests between multiple clients \nfor testing new services, code paths, or networking operations.\n\n## Installation\n\n```ruby\ngem 'gruf-balancer'\n```\n\n## Usage\n\nInstead of creating a normal `Gruf::Client`, simply add clients to a `Gruf::Balancer::Client`, via passing in\na percentage of requests and client options (similarly to how you'd create `Gruf::Client` objects).\n\n```ruby\nclient = Gruf::Balancer::Client.new(service: MyService)\nclient.add_client(percentage: 60, options: { hostname: '127.0.0.1:8000' })\nclient.add_client(percentage: 40, options: { hostname: '127.0.0.1:8001' })\n# @type [Gruf::Response] resp\nresp = client.call(:GetThing, id: 123)\n```\n\nThis uses a weighted random sampling algorithm under the hood to balance the requests to the method on the defined\npercentage weights. In the example above, 60% of requests would go to our service on port 8000, and 40% on port 8001.\n\n`Gruf::Balancer::Client` acts similarly to a `Gruf::Client`, in terms of its `call` method signature. It maintains\na thread-safe pool of clients. Note, similarly to gRPC core, that clients are not fork-safe; please instantiate\nany balanced client pools _after_ forking.\n\n### Use Cases\n\nSome use cases for gruf-balancer can be:\n\n* Testing a new application service that serves the same gRPC Service, but on a different hostname\n* Testing different hostnames, routing rules, network infrastructure, or service meshes via different hostnames \n* Testing new client options, such as timeouts, credentials, channels, or channel arguments\n* Testing new client interceptors, since they are configured per-client\n\n## License\n\nCopyright (c) 2021-present, BigCommerce Pty. Ltd. All rights reserved\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fgruf-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigcommerce%2Fgruf-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fgruf-balancer/lists"}