From 7ff05b0ede3fe1ed80489278a3754ffc78f9349d Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 24 Sep 2023 22:04:34 +0200 Subject: [PATCH] docs: update Signed-off-by: kjuulh --- README.md | 24 ++++++++++-------------- crates/crunch/src/lib.rs | 3 ++- examples/basic-setup/src/main.rs | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 669e2db..fa24754 100644 --- a/README.md +++ b/README.md @@ -9,22 +9,18 @@ The value of crunch is that you can separate your own business domain from other See [examples](crates/crunch/examples/) for a more holistic listing of features ```rust -impl Event for SomeEvent { - fn event_info(&self) -> EventInfo { - EventInfo { - domain: "some-domain", - entity_type: "some-entity", - } - } -} - #[tokio::main] async fn main() -> anyhow::Result<()> { - let in_memory = Persistence::in_memory(); - OutboxHandler::new(in_memory.clone()).spawn(); - let publisher = Publisher::new(in_memory); + let crunch = crunch::Builder::default().build()?; - publisher + crunch.subscribe(|event| async move { + println!("received event: {:?}", event); + + Ok(()) + }) + .await?; + + crunch .publish(SomeEvent { name: "some-name".into(), }) @@ -67,7 +63,7 @@ See [docs](docs/index.md) for more information (TBA) When crunch is used in services it needs some supportive tooling, it isn't a requirement, but it helps ease development when using them. - [x] [Cli](crates/crunch-cli) Used to generate code, add subscriptions, publish event schema, bump versions and more - - [x] Codegen done + - [x] Codegen done (at least for an alpha) - [ ] Rest - [x] [Codegen](crates/crunch-codegen) Can be used to automatically generate rust code depending on your crunch.toml file - [x] Main serialization and protobuf -> rust diff --git a/crates/crunch/src/lib.rs b/crates/crunch/src/lib.rs index e28fd30..154cd6d 100644 --- a/crates/crunch/src/lib.rs +++ b/crates/crunch/src/lib.rs @@ -56,7 +56,8 @@ impl std::ops::Deref for Crunch { } } -pub mod builder { +pub use builder::*; +mod builder { use crate::{errors, Crunch, OutboxHandler, Persistence, Publisher, Subscriber, Transport}; #[derive(Clone)] diff --git a/examples/basic-setup/src/main.rs b/examples/basic-setup/src/main.rs index 662b6f1..50dc9d1 100644 --- a/examples/basic-setup/src/main.rs +++ b/examples/basic-setup/src/main.rs @@ -4,7 +4,7 @@ use gencrunch::basic::{includes::my_include::MyInclude, my_event::MyEvent}; #[tokio::main] async fn main() -> anyhow::Result<()> { - let crunch = ::crunch::builder::Builder::default().build()?; + let crunch = crunch::Builder::default().build()?; crunch .subscribe(|item: MyEvent| async move {