{"id":18643410,"url":"https://github.com/avencera/moleculer-rs","last_synced_at":"2025-04-11T11:31:57.831Z","repository":{"id":53549572,"uuid":"343594946","full_name":"avencera/moleculer-rs","owner":"avencera","description":"🚀 Progressive microservices framework for Rust, based on and compatible with moleculerjs/moleculer","archived":false,"fork":false,"pushed_at":"2024-10-06T01:17:48.000Z","size":239,"stargazers_count":22,"open_issues_count":7,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T13:39:17.102Z","etag":null,"topics":["microservice-framework","microservices","moleculer"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avencera.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}},"created_at":"2021-03-02T00:17:27.000Z","updated_at":"2025-02-24T21:19:03.000Z","dependencies_parsed_at":"2022-09-07T16:03:26.488Z","dependency_job_id":null,"html_url":"https://github.com/avencera/moleculer-rs","commit_stats":null,"previous_names":["primcloud/moleculer-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avencera%2Fmoleculer-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avencera%2Fmoleculer-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avencera%2Fmoleculer-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avencera%2Fmoleculer-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avencera","download_url":"https://codeload.github.com/avencera/moleculer-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248384012,"owners_count":21094657,"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":["microservice-framework","microservices","moleculer"],"created_at":"2024-11-07T06:06:58.036Z","updated_at":"2025-04-11T11:31:56.816Z","avatar_url":"https://github.com/avencera.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# moleculer-rs\n\n![Build Status](https://github.com/primcloud/moleculer-rs/workflows/Rust/badge.svg)\n[![Crates.io](https://img.shields.io/crates/v/moleculer.svg)](https://crates.io/crates/moleculer)\n[![Documentation](https://docs.rs/moleculer/badge.svg)](https://docs.rs/moleculer)\n[![Rust 1.52+](https://img.shields.io/badge/rust-1.52+-orange.svg)](https://www.rust-lang.org)\n\nInspired and compatible with [Moleculer JS](https://github.com/moleculerjs/moleculer)\n\nYou can currently do all the basics of `emit`, `broadcast` and `call`.\n\nHowever it only works with the `NATS` transporter and `JSON` serializer/deserializer.\n\n## Getting Started\n\nAvailable on crates: [crates.io/moleculer](https://crates.io/crates/moleculer)\n\nDocumentation available at: [docs.rs/moleculer](https://docs.rs/moleculer/)\n\n```toml\nmoleculer = \"0.3.3\"\n```\n\nSimple example showing how to receive an event, and responding to a request, for more check the [examples folder](https://github.com/primcloud/moleculer-rs/tree/master/examples)\n\n```rust\nuse std::error::Error;\nuse moleculer::{\n    config::{ConfigBuilder, Transporter},\n    service::{Context, Event, EventBuilder, Service},\n    ServiceBroker,\n};\nuse serde::Deserialize;\n\n#[tokio::main]\nasync fn main() -\u003e eyre::Result\u003c()\u003e {\n    env_logger::init();\n    color_eyre::install()?;\n\n    // build config\n    let config = ConfigBuilder::default().transporter(Transporter::nats(\"nats://localhost:4222\"))\n    .build();\n\n    // create the first event\n    let print_hi = EventBuilder::new(\"printHi\").add_callback(print_hi).build();\n\n    // create the second event\n    let print_name = EventBuilder::new(\"printName\")\n        .add_callback(print_name)\n        .build();\n\n    // create math action\n    let math_action = ActionBuilder::new(\"mathAdd\").add_callback(math_add).build();\n\n    // create a service with events and actions\n    let greeter_service = Service::new(\"rustGreeter\")\n        .add_event(print_hi)\n        .add_event(print_name)\n        .add_action(math_action);\n\n    // create service broker with service\n    let service_broker = ServiceBroker::new(config).add_service(greeter_service);\n\n    // start the service broker\n    service_broker.start().await;\n\n    Ok(())\n}\n\n\n// callback for first event, will be called whenever \"printHi\" event is received\nfn print_hi(_ctx: Context\u003cEvent\u003e) -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    println!(\"Hello from Rust\");\n    Ok(())\n}\n\n// callback for second event, will be called whenever \"printName\" event is received\nfn print_name(ctx: Context\u003cEvent\u003e) -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let msg: PrintNameMessage = serde_json::from_value(ctx.params)?;\n\n    println!(\"Hello to: {} from Rust\", msg.name);\n\n    Ok(())\n}\n\n// callback for math action\nfn math_add(ctx: Context\u003cAction\u003e) -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    // get message decode using serde\n    let msg: ActionMessage = serde_json::from_value(ctx.params.clone())?;\n    let answer = msg.a + msg.b;\n\n    // serialize reply using serde and send reply\n    let _ = ctx.reply(answer.into());\n\n    Ok(())\n}\n\n#[derive(Deserialize)]\nstruct PrintNameMessage {\n    name: String,\n}\n\n#[derive(Deserialize)]\nstruct ActionMessage {\n    a: i32,\n    b: i32,\n}\n```\n\n## Current Status\n\nUsable but missing some options\n\n### What it does\n\n- Is discoverable by other moleculer clients\n- Only NATS transporter\n- Only JSON serialization/deserialization\n- Can `emit` and `broadcast` events\n- Can `call` to send request and wait for response ([#20](https://github.com/primcloud/moleculer-rs/pull/20))\n- Can respond to events from other molecular clients using callbacks (see: [simple event example](https://github.com/primcloud/moleculer-rs/blob/master/examples/simple_event.rs))\n- Can create actions, and respond to requests ([#19](https://github.com/primcloud/moleculer-rs/pull/19))\n\n### What its missing:\n\n- Tests [#17](https://github.com/primcloud/moleculer-rs/issues/17)\n- Better error handling on actions [#24](https://github.com/primcloud/moleculer-rs/issues/24)\n- Support for different serializer/deserializer [#23](https://github.com/primcloud/moleculer-rs/issues/23)\n- Support for `Bulkhead`, `CircuitBreaker` and `RetryPolicy`\n- Support for tracing\n- Support for different transporters other than NATS\n- Support for different loggers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favencera%2Fmoleculer-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favencera%2Fmoleculer-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favencera%2Fmoleculer-rs/lists"}