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

cockatiel

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cockatiel

A resilience and transient-fault-handling library that allows developers to express policies such as Backoff, Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. Inspired by .NET Polly.

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
163K
increased by4.1%
Maintainers
1
Weekly downloads
 
Created

What is cockatiel?

Cockatiel is a resilience and transient-fault-handling library for JavaScript and TypeScript. It provides utilities for implementing retry policies, circuit breakers, timeouts, and bulkheads to make your applications more robust and fault-tolerant.

What are cockatiel's main functionalities?

Retry Policy

The retry policy allows you to automatically retry operations that might fail, with configurable backoff strategies. This example demonstrates how to set up a retry policy with exponential backoff.

const { retry } = require('cockatiel');

const policy = retry({
  maxAttempts: 5,
  backoff: new retry.ExponentialBackoff({ initialDelay: 100 })
});

policy.execute(async () => {
  // Your code that might fail
});

Circuit Breaker

The circuit breaker pattern helps to prevent cascading failures in distributed systems. This example shows how to set up a circuit breaker that opens after a failure and attempts to recover after a specified time.

const { circuitBreaker } = require('cockatiel');

const breaker = circuitBreaker({
  halfOpenAfter: 10 * 1000,
  breaker: (result) => result instanceof Error
});

breaker.execute(async () => {
  // Your code that might fail
});

Timeout Policy

The timeout policy allows you to set a maximum duration for an operation to complete. This example demonstrates how to set a timeout of 5 seconds for an operation.

const { timeout } = require('cockatiel');

const policy = timeout(5000); // 5 seconds

policy.execute(async () => {
  // Your code that might take too long
});

Bulkhead Policy

The bulkhead pattern helps to limit the number of concurrent operations to prevent resource exhaustion. This example shows how to set up a bulkhead policy that allows up to 5 concurrent executions.

const { bulkhead } = require('cockatiel');

const policy = bulkhead(5); // Allow up to 5 concurrent executions

policy.execute(async () => {
  // Your code that should be limited in concurrency
});

Other packages similar to cockatiel

Keywords

FAQs

Package last updated on 24 Feb 2020

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