{"id":19975471,"url":"https://github.com/innoave/eventmill","last_synced_at":"2025-05-04T02:33:54.803Z","repository":{"id":57626435,"uuid":"260602514","full_name":"innoave/eventmill","owner":"innoave","description":"Event sourcing and CQRS for Rust applications","archived":false,"fork":false,"pushed_at":"2024-01-02T06:51:29.000Z","size":2195,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T01:10:30.689Z","etag":null,"topics":["aggregate","cqrs","ddd","event-sourcing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/innoave.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-02T02:57:29.000Z","updated_at":"2023-05-21T20:24:20.000Z","dependencies_parsed_at":"2024-01-02T08:10:07.414Z","dependency_job_id":null,"html_url":"https://github.com/innoave/eventmill","commit_stats":{"total_commits":129,"total_committers":1,"mean_commits":129.0,"dds":0.0,"last_synced_commit":"bf8943779f9fd66b9922b086c9cda846eb05e9d3"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Feventmill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Feventmill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Feventmill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Feventmill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/innoave","download_url":"https://codeload.github.com/innoave/eventmill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224380294,"owners_count":17301608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aggregate","cqrs","ddd","event-sourcing"],"created_at":"2024-11-13T03:18:34.371Z","updated_at":"2024-11-13T03:18:35.087Z","avatar_url":"https://github.com/innoave.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eventmill \u0026emsp;\n\n[![Latest Release]][crates.io]\n[![Documentation]][docs.rs]\n[![License]](LICENSE)\n[![Rustc Support 1.39+]][Rust 1.39]\n[![Build Status]][actions]\n\n[Latest Release]: https://img.shields.io/crates/v/eventmill.svg\n[crates.io]: https://crates.io/crates/eventmill\n[Documentation]: https://docs.rs/eventmill/badge.svg \n[docs.rs]: https://docs.rs/eventmill\n[License]: https://img.shields.io/badge/license-MIT%2FApache_2.0-blue.svg\n[MIT]: https://opensource.org/licenses/MIT\n[Apache-2.0]: https://www.apache.org/licenses/LICENSE-2.0\n[Build Status]: https://img.shields.io/github/workflow/status/innoave/eventmill/CI/master\n[actions]: https://github.com/innoave/eventmill/actions?query=branch%3Amaster\n[Rustc Support 1.39+]: https://img.shields.io/badge/rustc-1.39+-lightgray.svg\n[Rust 1.39]: https://blog.rust-lang.org/2019/11/07/Rust-1.39.0.html\n\n**Event sourcing and CQRS for Rust applications**\n\n\u003e very much work in progress!\n\n```toml\n[dependencies]\neventmill = \"0.4\"\n```\n\nto use the `derive` macros from the `eventmill-derive` crate activate the `derive` feature:\n\n```toml\n[dependencies]\neventmill = { version = \"0.4\", features = [\"derive\"] }    \n```\n\n## Usage example\n\nDefine your domain events:\n\n```rust\nconst EVENT_NAMESPACE: \u0026str = \"https://github.com/innoave/eventmill/examples/counter\";\n\n#[derive(EventType, Debug, Clone, PartialEq)]\n#[event_source(EVENT_NAMESPACE)]\n#[event_type_version(\"V1\")]\n#[event_type(\"Incremented\")]\nstruct Incremented;\n```\n\nDefine your aggregate:\n\n```rust\n#[derive(AggregateType, Debug)]\n#[id_field(id)]\n#[initialize_with_defaults]\nstruct Counter {\n    id: i32,\n    hits: u64,\n}\n```\n\nImplement the business logic for applying events to the aggregate:\n\n```rust\nimpl Aggregate\u003cIncremented\u003e for Counter {\n    fn apply_event(\u0026mut self, _event: \u0026DomainEvent\u003cIncremented, Self\u003e) {\n        self.hits += 1;\n    }\n}\n```\n\nDefine a command:\n\n```rust\n#[derive(Debug, PartialEq)]\nstruct Increment;\n```\n\nImplement the business logic so that the aggregate is able to handle the command:\n\n```rust\nimpl HandleCommand\u003cIncrement, Self\u003e for Counter {\n    type Event = Incremented;\n    type Error = Infallible;\n    type Context = ();\n\n    fn handle_command(\n        \u0026self,\n        _command: Increment,\n        _context: \u0026Self::Context,\n    ) -\u003e Result\u003cVec\u003cNewEvent\u003cSelf::Event, Counter\u003e\u003e, Self::Error\u003e {\n        Ok(vec![NewEvent {\n            aggregate_id: self.id,\n            data: Incremented,\n        }])\n    }\n}\n```\n\nBringing it all together using the `Core` dispatcher:\n\n```rust\nfn main() {\n    let event_store = InMemoryStore::new();\n    let core = Core::new(event_store);\n\n    let aggregate_id = 4711;\n\n    let increment_command = DomainCommand {\n        aggregate_id,\n        aggregate_generation: Generation::default(),\n        data: Increment,\n    };\n\n    let versioned_counter: VersionedAggregate\u003cCounter\u003e = core\n        .dispatch_command(increment_command, \u0026())\n        .expect(\"counter incremented\");\n\n    assert_eq!(versioned_counter.state().hits, 1);\n}\n```\n\nThese code samples are taken from the `counter` example. Take a look at [`eventmill-examples`] for\nmore insights.\n\n## TODO\n\n* [X] define basic abstractions and API\n* [X] provide a first example on how it looks like to use the API\n* [ ] make more examples to polish the API\n* [ ] write rust-doc for the API\n* [ ] support async/await or switch to async as the only option\n* [ ] consider providing default implementations for eventstores and other building blocks\n* [ ] ...\n\n[`eventmill-examples`]: https://github.com/innoave/eventmill/tree/master/eventmill-examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoave%2Feventmill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnoave%2Feventmill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoave%2Feventmill/lists"}