{"id":21929937,"url":"https://github.com/reneweb/crius","last_synced_at":"2025-06-28T16:33:25.529Z","repository":{"id":57612791,"uuid":"93281412","full_name":"reneweb/crius","owner":"reneweb","description":"Crius is a simple hystrix-like circuit breaker for rust.","archived":false,"fork":false,"pushed_at":"2018-11-17T16:58:06.000Z","size":47,"stargazers_count":14,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T06:27:29.368Z","etag":null,"topics":["circuit-breaker","command","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/crius","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reneweb.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}},"created_at":"2017-06-04T00:33:59.000Z","updated_at":"2024-11-28T16:33:23.000Z","dependencies_parsed_at":"2022-09-14T15:21:56.524Z","dependency_job_id":null,"html_url":"https://github.com/reneweb/crius","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/reneweb/crius","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reneweb%2Fcrius","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reneweb%2Fcrius/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reneweb%2Fcrius/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reneweb%2Fcrius/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reneweb","download_url":"https://codeload.github.com/reneweb/crius/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reneweb%2Fcrius/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261430894,"owners_count":23157173,"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","command","rust"],"created_at":"2024-11-28T23:06:33.667Z","updated_at":"2025-06-28T16:33:25.503Z","avatar_url":"https://github.com/reneweb.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crius [![Build Status](https://travis-ci.org/reneweb/crius.svg?branch=master)](https://travis-ci.org/reneweb/crius) [![Cargo Version](https://img.shields.io/crates/v/crius.svg)](https://crates.io/crates/crius)\n\nCrius is a simple hystrix-like circuit breaker for rust.\n\n_\"In the midst of chaos, there is also opportunity\"_\n\n## Usage\n\n### Simple command\n```rust\nuse crius::{command, Config, CriusError};\n\n#[derive(PartialEq, Debug)]\nstruct ExampleError;\nimpl From\u003cCriusError\u003e for ExampleError {\n  fn from(_: CriusError) -\u003e Self { ExampleError }\n}\n\n// Define a simple circuit breaker command:\nlet mut cmd = command(Config::default(), |n| {\n  if n \u003e 10 {\n    Err(ExampleError)\n  } else {\n    Ok(n * 2)\n  }}).unwrap();\n\n// and run it with an example input:\nlet result = cmd.run(10);\nassert_eq!(Ok(20), result);\n```\n\n### Command with fallback\n```rust\nuse crius::{command_with_fallback, Config, CriusError};\n\n#[derive(PartialEq, Debug)]\nstruct ExampleError;\nimpl From\u003cCriusError\u003e for ExampleError {\n  fn from(_: CriusError) -\u003e Self { ExampleError }\n}\n\nlet double_if_lt_ten = |n| if n \u003e 10 {\n  Err(ExampleError)\n} else {\n  Ok(n * 2)\n};\n\n// Define a simple circuit breaker command:\nlet mut cmd = command_with_fallback(\n    Config::default(),\n    double_if_lt_ten,\n\n    // Define a fallback:\n    |_err| 4, // It's always four.\n).unwrap();\n\n// and run it with an example input:\nlet result = cmd.run(11);\nassert_eq!(Ok(4), result);\n```\n\n### Command with custom configuration\n```rust\nuse crius::{command, Config, CriusError};\n\nlet config = *Config::default()\n    .circuit_open_ms(5000)\n    .error_threshold(10)\n    .error_threshold_percentage(50)\n    .buckets_in_window(100)\n    .bucket_size_in_ms(1000);\n\nlet mut cmd = command(config, |n| {\n  if n \u003e 10 {\n    Err(ExampleError)\n  } else {\n    Ok(n * 2)\n  }}).unwrap();\n\n// and run it with an example input:\nlet result = cmd.run(10);\nassert_eq!(Ok(20), result);\n```\n\n## Configuration\n\n`circuit_open_ms` - Time in ms commands are rejected after the circuit opened - Default 5000\n\n`error_threshold` - Minimum amount of errors for the circuit to break - Default 10\n\n`error_threshold_percentage` - Minimum error percentage for the circuit to break - Default 50\n\n`buckets_in_window` - Rolling window to track success/error calls, this property defines the amount of buckets in a window (buckets_in_window * bucket_size_in_ms is the overall length in ms of the window) - Default 10\n\n`bucket_size_in_ms` - This property defines the ms a bucket is long, i.e. each x ms a new bucket will be created (buckets_in_window * bucket_size_in_ms is the overall length in ms of the window) - Default 1000\n\n`circuit_breaker_enabled` - Defines if the circuit breaker is enabled or not - Default true","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freneweb%2Fcrius","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freneweb%2Fcrius","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freneweb%2Fcrius/lists"}