Hedwig library for Rust
What is it?
Hedwig is a inter-service communication bus that works on AWS and GCP, while keeping things pretty simple and straight forward. It uses json schema draft v4 for schema validation so all incoming and outgoing messages are validated against pre-defined schema.
Hedwig allows separation of concerns between consumers and publishers so your services are loosely coupled, and the contract is enforced by the schema validation. Hedwig may also be used to build asynchronous APIs.
Support exists for Python and Golang.
For intra-service messaging, see Taskhawk.
Quick Start
Installation
Add to Cargo.toml:
[dependencies]
hedwig = "*"
To use Google Publisher, use feature google
. There's also a mock publisher provided for testing
that can be accessed using feature mock
.
Usage
let schema = r#"
{
"$id": "https://hedwig.standard.ai/schema",
"$schema": "https://json-schema.org/draft-04/schema#",
"description": "Example Schema",
"schemas": {
"user-created": {
"1.*": {
"description": "A new user was created",
"type": "object",
"x-versions": [
"1.0"
],
"required": [
"user_id"
],
"properties": {
"user_id": {
"$ref": "https://hedwig.standard.ai/schema#/definitions/UserId/1.0"
}
}
}
}
},
"definitions": {
"UserId": {
"1.0": {
"type": "string"
}
}
}
}"#;
// create a publisher instance appropriately
// let publisher = GooglePublisher::new(String::from("/home/.google-key.json"), "myproject".into())?;
let hedwig = new?;
let message = hedwig.message?;
let message_id = message.id;
let publish_id = hedwig.publish?;
println!;
There's also a full running example in the repo.
Getting Help
We use GitHub issues for tracking bugs and feature requests.
- If it turns out that you may have found a bug, please open an issue