Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nice-grpc-client-middleware-deadline

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nice-grpc-client-middleware-deadline

Deadline client middleware for nice-grpc

  • 1.0.5
  • npm
  • Socket score

Version published
Weekly downloads
65K
decreased by-17.71%
Maintainers
1
Weekly downloads
 
Created
Source

nice-grpc-client-middleware-deadline npm version

Client middleware for nice-grpc that adds support for setting deadline for a call, after which the call will get cancelled, and a ClientError with status code DEADLINE_EXCEEDED will be thrown.

Installation

npm install nice-grpc-client-middleware-deadline

Usage

import {
  createClientFactory,
  createChannel,
  ClientError,
  Status,
} from 'nice-grpc';
import {deadlineMiddleware} from 'nice-grpc-client-middleware-deadline';
import {addSeconds} from 'date-fns';

const clientFactory = createClientFactory().use(deadlineMiddleware);

const channel = createChannel(address);
const client = clientFactory.create(ExampleService, channel);

try {
  const response = await client.exampleMethod(request, {
    deadline: addSeconds(new Date(), 15),
  });
} catch (error: unknown) {
  if (error instanceof ClientError && error.code === Status.DEADLINE_EXCEEDED) {
    // timed out
  } else {
    throw error;
  }
}

FAQs

Package last updated on 16 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc