{"id":23721214,"url":"https://github.com/byndyusoft/grpc-timeouts","last_synced_at":"2026-05-05T22:40:52.443Z","repository":{"id":54105454,"uuid":"325283233","full_name":"Byndyusoft/grpc-timeouts","owner":"Byndyusoft","description":"A library for customizable gRPC timeouts","archived":false,"fork":false,"pushed_at":"2021-03-09T10:07:05.000Z","size":180,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-31T08:46:59.404Z","etag":null,"topics":["circuit-breaker","fail-fast","grpc","nodejs","timeouts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Byndyusoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-29T12:38:43.000Z","updated_at":"2021-03-04T07:37:07.000Z","dependencies_parsed_at":"2022-08-13T06:50:31.199Z","dependency_job_id":null,"html_url":"https://github.com/Byndyusoft/grpc-timeouts","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byndyusoft%2Fgrpc-timeouts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byndyusoft%2Fgrpc-timeouts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byndyusoft%2Fgrpc-timeouts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byndyusoft%2Fgrpc-timeouts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Byndyusoft","download_url":"https://codeload.github.com/Byndyusoft/grpc-timeouts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239816363,"owners_count":19701752,"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":["circuit-breaker","fail-fast","grpc","nodejs","timeouts","typescript"],"created_at":"2024-12-30T22:18:11.845Z","updated_at":"2026-02-13T01:30:15.780Z","avatar_url":"https://github.com/Byndyusoft.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpc-timeouts\n\n[![npm version](https://img.shields.io/npm/v/@byndyusoft/grpc-timeouts)](https://www.npmjs.com/package/@byndyusoft/grpc-timeouts)\n[![npm downloads](https://img.shields.io/npm/dt/@byndyusoft/grpc-timeouts)](https://www.npmjs.com/package/@byndyusoft/grpc-timeouts)\n[![dependencies](https://img.shields.io/david/Byndyusoft/grpc-timeouts)](https://www.npmjs.com/package/@byndyusoft/grpc-timeouts)\n[![dev dependencies](https://img.shields.io/david/dev/Byndyusoft/grpc-timeouts)](https://www.npmjs.com/package/@byndyusoft/grpc-timeouts)\n[![Build Status](https://img.shields.io/github/workflow/status/Byndyusoft/grpc-timeouts/test%20workflow/master)](https://github.com/Byndyusoft/grpc-timeouts/actions?query=workflow%3A%22test+workflow%22)\n\n## Table of contents\n- [About](#about)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [CircuitBreaker](#circuitbreaker)\n    - [serverInterceptor](#serverinterceptor)\n    - [clientInterceptor](#clientinterceptor)\n- [Type Definitions](#typedefinitions)\n  - [ICircuitBreakerOptions](#icircuitbreakeroptions)\n  - [ITimeouts](#itimeouts)\n  - [IServerInterceptor](#iserverinterceptor)\n  - [IClientInterceptor](#iclientinterceptor)\n- [Related](#related)\n- [Maintainers](#maintainers)\n\n## About\n`grpc-timeouts` is a small library that makes it easy to add customizable timeouts to your services. The library implements a circuit breaker pattern, which means that if the request exceeds the deadline, no further requests will be sent. If the deadline for a received request has expired, the request will not be processed and service instantly answers with code 4 (Deadline exceeded).\n\n## Release New version\n\nFor new version use https://github.com/semantic-release/semantic-release description.\nWe must set commit message fix(pencil): New feature in release\n\n## Installation\n\n`npm i @byndyusoft/grpc-timeouts`\n\n## Usage\n**:warning: Make sure that CircuitBreaker interceptors is the last added interceptor, because it will interrupt further processing of the request!**\n```js\nconst grpc = require(\"grpc\")\nconst { CircuitBreaker } = require(\"@byndyusoft/grpc-timeouts\");\nconst circuitBreaker = new CircuitBreaker();\n\n/*...*/\n\n// Client interceptor:\nconst client = new grpc.Client(address, credentials, {\n  interceptors: [circuitBreaker.clientInterceptor]\n});\n\n// Server interceptor: (with grpc-host-builder)\nconst server = new GrpcHostBuilder()\n  .addInterceptor(circuitBreaker.serverInterceptor)\n  .addService(myService)\n  .bind(grpcBind)\n  .build()\n```\n\n## API\n### CircuitBreaker\n`constructor([options: ICircuitBreakerOptions])`\n\nOptions is an optional object with timeouts for methods (default timeout is 10 seconds).\n\n#### serverInterceptor\n`IServerInterceptor`\n\nServer interceptor function.\n\n#### clientInterceptor\n`IClientInterceptor`\n\nClient interceptor function.\n\n## Type Definitions\n### ICircuitBreakerOptions\nAn object with following keys:\n- `[timeouts: ITimeouts]` - The longest time for the methods to respond\n- `[minResponseTimeouts: ITimeouts]` - The shortest time to wait for a response from the services\n```js\n{\n  timeouts: {\n    createOrder: 3000,\n    updateOrder: 500,\n    deleteOrder: 500,\n    getOrder: 300,\n    default: 5000 //default was 10000\n  },\n  minResponseTimeouts: {\n    createOrder: 280,\n    default: 50 //default was 0\n  }\n}\n```\n### ITimeouts\nAn object which keys is camelCased method names and values is milliseconds. \\\nThis object also have `default` field that can be reassigned.\n\n### IServerInterceptor\n`(call: Object, methodDefinition: Object, next: Function) =\u003e Promise\u003cObject\u003e` \\\nA function that can be used as server interceptor.\n\n### IClientInterceptor\n`(options: Object, next: Function) =\u003e grpc.InterceptingCall` \\\nA function that can be used as client interceptor.\n\n## Related\n[grpc-host-builder](https://www.npmjs.com/package/grpc-host-builder)\n\n## Maintainers\n@Byndyusoft/owners: https://github.com/orgs/Byndyusoft/teams/owners, github.maintain@byndyusoft.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyndyusoft%2Fgrpc-timeouts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyndyusoft%2Fgrpc-timeouts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyndyusoft%2Fgrpc-timeouts/lists"}