[−][src]Crate hedwig
A Hedwig library for Rust. Hedwig is a message bus that works with arbitrary pubsub services such as AWS SNS/SQS or Google Cloud Pubsub. Messages are validated using a JSON schema. The publisher and consumer are de-coupled and fan-out is supported out of the box.
Example: publish a new message
use hedwig::{Hedwig, MajorVersion, MinorVersion, Version, Message}; fn main() -> Result<(), failure::Error> { 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" } } } }"#; fn router(t: MessageType, v: MajorVersion) -> Option<&'static str> { match (t, v) { (MessageType::UserCreated, MajorVersion(1)) => Some("dev-user-created-v1"), _ => None, } } // create a publisher instance let hedwig = Hedwig::new( schema, "myapp", publisher, router, )?; let message = hedwig.build_publish().message( Message::new(MessageType::UserCreated, Version(MajorVersion(1), MinorVersion(0)), UserCreatedData { user_id: "U_123".into() }) )?.publish()?;
Structs
GooglePublisher | A publisher that uses Google PubSub. To use this class, add feature |
Hedwig | Central instance to access all Hedwig related resources |
HedwigPublishBuilder | A builder for batch publish. |
MajorVersion | Major part component in semver |
Message | A message builder. |
Metadata | Additional metadata associated with a message |
MinorVersion | Minor part component in semver |
MockPublisher | A mock publisher that doesn't publish messages, but just stores them in-memory for later verification
This is useful primarily in tests. To use this class, add feature |
ValidatedMessage | A validated message. |
Version | A semver version without patch part |
Enums
HedwigError | All errors that may be returned when instantiating a new Hedwig instance. |
PublishError | All errors that may be returned while publishing a message. |
Traits
Publisher | Message publishers. |
Type Definitions
MessageRouter |
|