# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

[package]
name = "seatbelt"
description = "Resilience and recovery mechanisms for fallible operations."
version = "0.4.3"
readme = "README.md"
keywords = ["oxidizer", "resilience", "layered", "recovery", "retry"]
categories = ["data-structures"]

edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository = "https://github.com/microsoft/oxidizer/tree/main/crates/seatbelt"

[package.metadata.cargo_check_external_types]
allowed_external_types = [
    "layered::layer::stack::Stack",
    "layered::service::Service",
    "opentelemetry::metrics::meter::MeterProvider",
    "recoverable::Recovery",
    "recoverable::RecoveryInfo",
    "recoverable::RecoveryKind",
    "serde_core::de::*",
    "serde_core::ser::*",
    "tick::clock::Clock",
    "tower_layer::Layer",
    "tower_service::Service",
    "thread_aware::core::ThreadAware",
    "thread_aware::affinity::MemoryAffinity",
    "thread_aware::affinity::PinnedAffinity",
]

[package.metadata.docs.rs]
all-features = true

[features]
default = []
timeout = []
retry = ["dep:fastrand"]
breaker = ["dep:fastrand"]
fallback = []
hedging = ["dep:futures-util"]
chaos-injection = ["dep:fastrand"]
serde = ["dep:serde", "dep:jiff"]
metrics = ["dep:opentelemetry", "opentelemetry/metrics"]
logs = ["dep:tracing"]
tower-service = ["dep:tower-service"]

[dependencies]
fastrand = { workspace = true, optional = true }
futures-util = { workspace = true, optional = true, features = ["alloc"] }
jiff = { workspace = true, features = ["std", "serde"], optional = true }
layered = { workspace = true }
opentelemetry = { workspace = true, optional = true }
recoverable = { workspace = true }
serde = { workspace = true, features = ["std", "derive"], optional = true }
thread_aware = { workspace = true }
tick = { workspace = true }
tower-service = { workspace = true, optional = true }
tracing = { workspace = true, optional = true }

[dev-dependencies]
alloc_tracker.workspace = true
criterion.workspace = true
fastrand.workspace = true
futures = { workspace = true, features = ["executor"] }
futures-util = { workspace = true, features = ["alloc"] }
http.workspace = true
insta = { workspace = true, features = ["json"] }
jiff = { workspace = true, default-features = true, features = ["serde"] }
layered = { workspace = true, features = ["tower-service", "dynamic-service"] }
mutants.workspace = true
ohno = { workspace = true, features = ["app-err"] }
opentelemetry = { workspace = true, default-features = false, features = ["metrics"] }
opentelemetry-stdout = { workspace = true, default-features = false, features = ["metrics", "logs"] }
opentelemetry_sdk = { workspace = true, default-features = false, features = ["metrics", "testing", "experimental_metrics_custom_reader"] }
rstest.workspace = true
serde = { workspace = true, features = ["std", "derive"] }
serde_json = { workspace = true }
static_assertions.workspace = true
tick = { workspace = true, features = ["test-util", "tokio"] }
tokio = { workspace = true, features = ["rt", "macros"] }
tower = { workspace = true, features = ["util"] }
tower-service.workspace = true
tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["fmt", "std"] }

[[example]]
name = "timeout"
required-features = ["timeout", "metrics"]

[[example]]
name = "timeout_advanced"
required-features = ["timeout", "metrics"]

[[example]]
name = "retry"
required-features = ["retry"]

[[example]]
name = "retry_advanced"
required-features = ["retry", "metrics"]

[[example]]
name = "retry_outage"
required-features = ["retry", "metrics"]

[[example]]
name = "resilience_pipeline"
required-features = ["retry", "timeout", "metrics"]

[[example]]
name = "tower"
required-features = ["retry", "timeout", "tower-service"]

[[example]]
name = "hedging"
required-features = ["hedging"]

[[example]]
name = "breaker"
required-features = ["breaker", "metrics", "chaos-injection"]

[[example]]
name = "config"
required-features = ["retry", "breaker", "timeout", "serde"]

[[example]]
name = "fallback"
required-features = ["fallback"]

[[example]]
name = "chaos_injection"
required-features = ["chaos-injection"]

[[example]]
name = "chaos_injection_advanced"
required-features = ["chaos-injection"]

[[bench]]
name = "observability"
harness = false
required-features = ["retry", "logs", "metrics"]

[[bench]]
name = "timeout"
harness = false
required-features = ["timeout"]

[[bench]]
name = "retry"
harness = false
required-features = ["retry"]

[[bench]]
name = "breaker"
harness = false
required-features = ["breaker"]

[[bench]]
name = "hedging"
harness = false
required-features = ["hedging"]

[lints]
workspace = true
