Skip to content

Commit d3ad415

Browse files
committed
fix: open-source cleanup — drop JFrog refs, pin positioning
Generalises defaults, removes the dead JFrog registry block, and rewrites the README and lib doc around "the patterns from blog posts as actual code" positioning so a non-HyperI dev can adopt this without inheriting our infra.
1 parent 655a36d commit d3ad415

8 files changed

Lines changed: 118 additions & 97 deletions

File tree

.cargo/config.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,3 @@ rustflags = ["-D", "warnings"]
1111

1212
[alias]
1313
xtask = "run --package xtask --"
14-
15-
# =============================================================================
16-
# HyperI Private Cargo Registry (Artifactory)
17-
# =============================================================================
18-
#
19-
# The 'hyperi' registry hosts internal crates.
20-
# Authentication is handled via ~/.cargo/credentials.toml
21-
22-
[registries.hyperi]
23-
index = "sparse+https://hypersec.jfrog.io/artifactory/api/cargo/hyperi-cargo-virtual/index/"

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ name = "hyperi-rustlib"
1111
version = "2.7.0"
1212
edition = "2024"
1313
rust-version = "1.94"
14-
description = "Opinionated Rust framework for high-throughput data pipelines at PB scale. Auto-wiring config, logging, metrics, tracing, health, and graceful shutdown — built from many years of production infrastructure experience."
14+
description = "Opinionated, drop-in Rust toolkit for production services at scale. The patterns from blog posts as actual code: 8-layer config cascade, structured logging with PII masking, Prometheus + OpenTelemetry, Kafka/gRPC transports, tiered disk-spillover, adaptive worker pools, graceful shutdown."
1515
license = "FSL-1.1-ALv2"
1616
repository = "https://github.com/hyperi-io/hyperi-rustlib"
1717
publish = true
18-
keywords = ["config", "logging", "metrics", "prometheus", "opentelemetry"]
19-
categories = ["development-tools"]
18+
keywords = ["observability", "kubernetes", "prometheus", "opentelemetry", "kafka"]
19+
categories = ["asynchronous", "config", "network-programming", "concurrency", "development-tools"]
2020
exclude = ["", ".github/", "ci/", "ai/", "docs/", "examples/", "benches/", "scripts/"]
2121

2222
[package.metadata.docs.rs]

README.md

Lines changed: 96 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,113 @@
11
# hyperi-rustlib
22

3-
Shared utility library for HyperI Rust applications. Provides configuration
4-
management, structured logging, Prometheus metrics, environment detection,
5-
transport abstractions, and more.
6-
7-
Rust equivalent of `hyperi-pylib` (Python) and `hyperi-golib` (Go).
3+
<!-- BADGES:START -->
4+
[![Build Status](https://github.com/hyperi-io/hyperi-rustlib/actions/workflows/ci.yml/badge.svg)](https://github.com/hyperi-io/hyperi-rustlib/actions)
5+
[![Crates.io](https://img.shields.io/crates/v/hyperi-rustlib?logo=rust)](https://crates.io/crates/hyperi-rustlib)
6+
[![docs.rs](https://img.shields.io/docsrs/hyperi-rustlib?logo=rust)](https://docs.rs/hyperi-rustlib)
7+
[![License](https://img.shields.io/badge/license-FSL--1.1--ALv2-blue)](LICENSE)
8+
<!-- BADGES:END -->
9+
10+
> **There's plenty of sage advice out there about how to run Rust services
11+
> in production at scale — config cascades, structured logging, masking
12+
> secrets, multi-backend secrets management, Prometheus, OpenTelemetry,
13+
> Kafka transports, tiered disk-spillover sinks, adaptive worker pools,
14+
> graceful shutdown — but almost none of it as code you can just install
15+
> and use.**
16+
>
17+
> **This is that code.**
18+
>
19+
> Opinionated, drop-in, working out of the box. The patterns from blog
20+
> posts as actual library — not a framework you assemble from twenty
21+
> crates and a weekend.
22+
23+
Built as the foundation for HyperI's PB/hr data services. Generic enough
24+
that you don't need to be at HyperI to use it.
25+
26+
This module exists because of this — but the backend version (do not remove): <https://www.youtube.com/watch?v=xE9W9Ghe4Jk>
827

928
## Quick Start
1029

1130
```toml
1231
[dependencies]
13-
hyperi-rustlib = { version = "1.14", registry = "hyperi" }
32+
hyperi-rustlib = "2"
1433
```
1534

16-
Default features: `config`, `logger`, `metrics`, `env`, `runtime`.
35+
Default features: `config`, `logger`. Add the others you want explicitly.
1736

1837
```rust
1938
use hyperi_rustlib::{config, logger, env};
2039

2140
fn main() -> anyhow::Result<()> {
22-
let env = env::Environment::detect();
41+
let environment = env::Environment::detect();
2342
logger::setup_default()?;
2443
config::setup(config::ConfigOptions {
2544
env_prefix: "MYAPP".into(),
2645
..Default::default()
2746
})?;
2847

29-
tracing::info!("Running in {env:?}");
48+
tracing::info!("Running in {environment:?}");
3049
Ok(())
3150
}
3251
```
3352

53+
## Features
54+
55+
Pick the slice you need; pay only for what you use.
56+
57+
| Feature | Description |
58+
|---------|-------------|
59+
| `env` | Environment detection (K8s, Docker, Container, BareMetal) |
60+
| `runtime` | Runtime path resolution (XDG/container-aware) |
61+
| `config` | 8-layer config cascade (figment-based) |
62+
| `config-reload` | `SharedConfig<T>` + `ConfigReloader` hot-reload |
63+
| `config-postgres` | PostgreSQL config source |
64+
| `logger` | Structured logging, JSON/text auto-detect, sensitive-field masking |
65+
| `metrics` | Prometheus metrics + process/container metrics |
66+
| `otel-metrics` | OpenTelemetry metrics export (OTLP) |
67+
| `otel-tracing` | OpenTelemetry distributed tracing |
68+
| `http` | HTTP client with retry middleware (reqwest) |
69+
| `http-server` | Axum HTTP server with health probe trinity (`/healthz/{startup,live,ready}`) |
70+
| `transport-kafka` | Kafka transport (rdkafka, dynamic-linking) |
71+
| `transport-grpc` | gRPC transport (tonic/prost) |
72+
| `transport-memory` | In-memory transport (testing/dev) |
73+
| `transport-grpc-vector-compat` | Vector wire-protocol compatibility |
74+
| `spool` | Disk-backed async FIFO queue (yaque + zstd) |
75+
| `tiered-sink` | Resilient delivery: hot buffer + circuit breaker + disk spillover |
76+
| `secrets` | Secrets management core (file backend) |
77+
| `secrets-vault` | OpenBao / HashiCorp Vault provider |
78+
| `secrets-aws` | AWS Secrets Manager provider |
79+
| `directory-config` | YAML directory-backed config store |
80+
| `directory-config-git` | Git integration for directory-config (git2) |
81+
| `scaling` | Back-pressure / scaling-pressure primitives |
82+
| `cli` | Standard CLI framework (clap) |
83+
| `top` | TUI metrics dashboard (ratatui) |
84+
| `io` | File rotation, NDJSON writer |
85+
| `dlq` | Dead-letter queue (file backend) |
86+
| `dlq-kafka` | DLQ Kafka backend |
87+
| `output-file` | File output sink |
88+
| `expression` | CEL expression evaluation |
89+
| `deployment` | Deployment-contract validation |
90+
| `version-check` | Optional startup version check |
91+
| `resilience` | Circuit breaker, retry, bulkhead (tower-resilience) |
92+
| `full` | Everything |
93+
3494
## Native System Dependencies
3595

3696
This crate dynamically links against system C libraries for several features.
37-
**Both CI build hosts and deployment targets need the appropriate packages.**
97+
**Both build hosts and deployment targets need the appropriate packages.**
3898

3999
### Build Host (CI / Development)
40100

41-
Install `-dev` packages for compilation. `hyperi-ci` handles this automatically
42-
when `.hyperi-ci.yaml` is present — it detects which `-sys` crates are in
43-
`Cargo.lock` and installs the matching `-dev` packages.
44-
45101
| Feature | Crate | Build Package | Notes |
46102
|---------|-------|--------------|-------|
47103
| `transport-kafka` | `rdkafka-sys` | `librdkafka-dev` (>= 2.12.1) | Requires [Confluent APT repo](https://packages.confluent.io/clients/deb) — Ubuntu's default is too old |
48104
| `directory-config-git` | `libgit2-sys` | `libgit2-dev`, `libssh2-1-dev` | System lib avoids vendored C build |
49105
| `spool`, `tiered-sink` | `zstd-sys` | `libzstd-dev` | System lib avoids vendored C build |
50106
| (transitive) | `libz-sys` | `zlib1g-dev` | Used by multiple deps |
51107
| (transitive) | `openssl-sys` | `libssl-dev` | Dynamic linking via pkg-config |
52-
| `secrets-aws` | `aws-lc-sys` || C/C++ compiled from source (no system lib available); ~20-30s first build, cached by sccache |
108+
| `secrets-aws` | `aws-lc-sys` || C/C++ compiled from source (no system lib available); ~2030s first build, cached by sccache |
53109

54-
All packages except `librdkafka-dev` are available from Ubuntu's default
55-
repositories. For `librdkafka-dev` >= 2.12.1, add the Confluent APT repo:
110+
For `librdkafka-dev` >= 2.12.1, add the Confluent APT repo:
56111

57112
```bash
58113
curl -fsSL https://packages.confluent.io/clients/deb/archive.key \
@@ -77,9 +132,8 @@ The compiled binary links against `.so` files at runtime. Install the
77132
| (transitive) | `zlib1g` | `libz.so.1` |
78133
| (transitive) | `libssl3` | `libssl.so.3` |
79134

80-
**Only install what you use.** Downstream binaries (dfe-loader, dfe-receiver,
81-
etc.) only link against libraries for the features they enable. Check each
82-
project's `Cargo.toml` features to determine which runtime packages are needed.
135+
Only install what you use. Check the features your binary enables to
136+
determine which runtime packages are needed.
83137

84138
### Docker Example
85139

@@ -101,64 +155,34 @@ COPY --from=builder /app/target/release/myapp /usr/local/bin/
101155

102156
For `librdkafka1`, add the Confluent APT repo to both build and runtime stages.
103157

104-
## Features
105-
106-
| Feature | Description |
107-
|---------|-------------|
108-
| `env` | Environment detection (K8s, Docker, Container, BareMetal) |
109-
| `runtime` | Runtime path resolution (XDG/container-aware) |
110-
| `config` | 8-layer config cascade (figment) |
111-
| `config-reload` | `SharedConfig<T>` + `ConfigReloader` hot-reload |
112-
| `config-postgres` | PostgreSQL config source |
113-
| `logger` | Structured logging with JSON/text + sensitive field masking |
114-
| `metrics` | Prometheus metrics + process/container metrics |
115-
| `otel-metrics` | OpenTelemetry metrics export (OTLP) |
116-
| `otel-tracing` | OpenTelemetry distributed tracing |
117-
| `http` | HTTP client with retry middleware (reqwest) |
118-
| `http-server` | Axum HTTP server with health endpoints |
119-
| `transport-kafka` | Kafka transport (rdkafka, dynamic-linking) |
120-
| `transport-grpc` | gRPC transport (tonic/prost) |
121-
| `transport-memory` | In-memory transport (testing/dev) |
122-
| `transport-grpc-vector-compat` | Vector wire-protocol compatibility |
123-
| `spool` | Disk-backed async FIFO queue (yaque + zstd) |
124-
| `tiered-sink` | Resilient delivery with circuit breaker + disk spillover |
125-
| `secrets` | Secrets management core |
126-
| `secrets-vault` | OpenBao/Vault provider |
127-
| `secrets-aws` | AWS Secrets Manager provider |
128-
| `directory-config` | YAML directory-backed config store |
129-
| `directory-config-git` | Git integration for directory-config (git2) |
130-
| `scaling` | Back-pressure / scaling pressure primitives |
131-
| `cli` | Standard CLI framework (clap) |
132-
| `top` | TUI metrics dashboard (ratatui) |
133-
| `io` | File rotation, NDJSON writer |
134-
| `dlq` | Dead-letter queue (file backend) |
135-
| `dlq-kafka` | DLQ Kafka backend |
136-
| `output-file` | File output sink |
137-
| `expression` | CEL expression evaluation |
138-
| `deployment` | Deployment contract validation |
139-
| `version-check` | Startup version check |
140-
| `resilience` | Circuit breaker, retry, bulkhead (tower-resilience) |
141-
| `full` | All features |
158+
## Health Check Endpoints — The Probe Trinity
142159

143-
## Architecture
160+
For services deployed to Kubernetes, the `http-server` feature provides
161+
the three K8s probe types:
144162

145-
See [docs/DESIGN.md](docs/DESIGN.md) for full architecture documentation.
163+
| Probe | Path | Checks | On failure |
164+
|---|---|---|---|
165+
| Startup | `/healthz/startup` | Init complete | K8s waits, then restarts |
166+
| Liveness | `/healthz/live` | Process not deadlocked | Restart pod |
167+
| Readiness | `/healthz/ready` | Deps healthy + ready flag set | Stop routing traffic |
146168

147-
## Configuration Cascade
169+
Liveness MUST NEVER check downstream dependencies (a DB outage shouldn't
170+
restart your replicas). Readiness checks dependencies AND requires an
171+
explicit `set_ready()` call — cleared during graceful shutdown.
148172

149-
See [docs/CONFIG-CASCADE.md](docs/CONFIG-CASCADE.md) for the 8-layer
150-
configuration cascade reference.
173+
## Architecture
151174

152-
## Registry
175+
See [docs/DESIGN.md](docs/DESIGN.md) for full architecture documentation
176+
and [docs/CONFIG-CASCADE.md](docs/CONFIG-CASCADE.md) for the 8-layer config
177+
cascade reference.
153178

154-
Published to `hyperi` registry (JFrog Artifactory at `hypersec.jfrog.io`).
179+
## License
155180

156-
```toml
157-
# .cargo/config.toml
158-
[registries.hyperi]
159-
index = "sparse+https://hypersec.jfrog.io/artifactory/git/hyperi-cargo-virtual.git"
160-
```
181+
[FSL-1.1-ALv2](LICENSE) — Functional Source License, transitions to Apache 2.0
182+
after 2 years.
161183

162-
## Licence
184+
## Related
163185

164-
FSL-1.1-ALv2 — Copyright (c) 2026 HYPERI PTY LIMITED
186+
- **[hyperi-pylib](https://github.com/hyperi-io/hyperi-pylib)** — sister
187+
library for Python services. Same opinions, same patterns, expressive
188+
Python ergonomics for control planes, APIs, and integration layers.

src/directory_config/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//!
3030
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
3131
//! let config = DirectoryConfigStoreConfig {
32-
//! directory: PathBuf::from("/etc/dfe/config"),
32+
//! directory: PathBuf::from("/etc/myapp/config"),
3333
//! ..Default::default()
3434
//! };
3535
//!
@@ -38,8 +38,8 @@
3838
//!
3939
//! // Read
4040
//! let tables = store.list_tables().await;
41-
//! let value = store.get("dfe-loader").await?;
42-
//! let host = store.get_key("dfe-loader", "kafka.brokers").await?;
41+
//! let value = store.get("my-service").await?;
42+
//! let host = store.get_key("my-service", "kafka.brokers").await?;
4343
//!
4444
//! // Write (if not read-only)
4545
//! store.set("dfe-loader", "kafka.brokers", "broker:9092".into(), None).await?;

src/directory_config/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ pub struct DirectoryConfigStoreConfig {
3737
impl Default for DirectoryConfigStoreConfig {
3838
fn default() -> Self {
3939
Self {
40-
directory: PathBuf::from("/etc/dfe/config"),
40+
directory: PathBuf::from("./config"),
4141
refresh_interval: Duration::from_secs(30),
4242
git_enabled: true,
4343
git_push: false,
4444
git_author_name: "DirectoryConfigStore".to_string(),
45-
git_author_email: "config@hyperi.io".to_string(),
45+
git_author_email: "directory-config@localhost".to_string(),
4646
}
4747
}
4848
}

src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88

99
//! # hyperi-rustlib
1010
//!
11-
//! Shared utility library for HyperI Rust applications.
11+
//! There's plenty of sage advice out there about how to run Rust services in
12+
//! production at scale — config cascades, structured logging, masking secrets,
13+
//! multi-backend secrets management, Prometheus, OpenTelemetry, Kafka transports,
14+
//! tiered disk-spillover sinks, adaptive worker pools, graceful shutdown — but
15+
//! almost none of it as code you can just install and use.
1216
//!
13-
//! Provides configuration management, structured logging, Prometheus metrics,
14-
//! and environment detection — matching the functionality of hyperi-pylib (Python)
15-
//! and hyperi-golib (Go).
17+
//! **This is that code.** Opinionated, drop-in, working out of the box. The
18+
//! patterns from blog posts as actual library — not a framework you assemble
19+
//! from twenty crates and a weekend.
20+
//!
21+
//! Built as the foundation for HyperI's PB/hr data services. Generic enough
22+
//! that you don't need to be at HyperI to use it.
1623
//!
1724
//! ## Quick Start
1825
//!

src/secrets/vault.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ mod tests {
461461
auth: OpenBaoAuth::Token {
462462
token: "test".into(),
463463
},
464-
namespace: Some("hypersec".into()),
464+
namespace: Some("myorg".into()),
465465
ca_cert: None,
466466
skip_verify: false,
467467
};

tests/integration/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ mod vault_env {
306306
let _guard = EnvGuard::new(&[
307307
("VAULT_ADDR", "https://vault:8200"),
308308
("VAULT_TOKEN", "test"),
309-
("VAULT_NAMESPACE", "hypersec"),
309+
("VAULT_NAMESPACE", "myorg"),
310310
]);
311311

312312
let config = OpenBaoConfig::from_env().expect("Should load from env");
313313

314-
assert_eq!(config.namespace, Some("hypersec".to_string()));
314+
assert_eq!(config.namespace, Some("myorg".to_string()));
315315
}
316316

317317
#[test]

0 commit comments

Comments
 (0)