diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f51dcb3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +on: + push: + tags: + - v*.*.* + +name: CI + +jobs: + release: + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v1 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index ae31f45..e6d1d43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -698,7 +698,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] -name = "overwatch" +name = "overwatch-derive" +version = "0.1.0" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "tracing", +] + +[[package]] +name = "overwatch-rs" version = "0.1.0" dependencies = [ "async-trait", @@ -711,18 +723,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "overwatch-derive" -version = "0.1.0" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", - "tracing", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1296,8 +1296,8 @@ dependencies = [ "async-trait", "bincode", "clap 4.0.18", - "overwatch", "overwatch-derive", + "overwatch-rs", "rand", "serde", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 688fb92..5afe29a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ - "overwatch", + "overwatch-rs", "overwatch-derive", "examples/waku-chat" ] diff --git a/examples/waku-chat/Cargo.toml b/examples/waku-chat/Cargo.toml index 64801fe..86f2576 100644 --- a/examples/waku-chat/Cargo.toml +++ b/examples/waku-chat/Cargo.toml @@ -10,7 +10,7 @@ tokio = { version = "1", features = ["rt"] } waku = { git = "https://github.com/waku-org/waku-rust-bindings" } serde = "1" bincode = "1" -overwatch = { path = "../../overwatch" } +overwatch-rs = { path = "../../overwatch-rs" } overwatch-derive = { path = "../../overwatch-derive" } tracing = "*" async-trait = "0.1" diff --git a/examples/waku-chat/src/chat.rs b/examples/waku-chat/src/chat.rs index f389743..44871bb 100644 --- a/examples/waku-chat/src/chat.rs +++ b/examples/waku-chat/src/chat.rs @@ -1,9 +1,9 @@ use crate::network::*; use async_trait::async_trait; -use overwatch::services::handle::ServiceStateHandle; -use overwatch::services::relay::{NoMessage, OutboundRelay}; -use overwatch::services::state::{NoOperator, NoState}; -use overwatch::services::{ServiceCore, ServiceData, ServiceId}; +use overwatch_rs::services::handle::ServiceStateHandle; +use overwatch_rs::services::relay::{NoMessage, OutboundRelay}; +use overwatch_rs::services::state::{NoOperator, NoState}; +use overwatch_rs::services::{ServiceCore, ServiceData, ServiceId}; use serde::{Deserialize, Serialize}; use tokio::sync::mpsc::channel; diff --git a/examples/waku-chat/src/main.rs b/examples/waku-chat/src/main.rs index 7c9b95b..7d85e17 100644 --- a/examples/waku-chat/src/main.rs +++ b/examples/waku-chat/src/main.rs @@ -10,8 +10,8 @@ mod chat; use chat::*; use clap::Parser; use network::*; -use overwatch::{overwatch::*, services::handle::ServiceHandle}; use overwatch_derive::*; +use overwatch_rs::{overwatch::*, services::handle::ServiceHandle}; /// Simple program to greet a person #[derive(Parser, Debug)] diff --git a/examples/waku-chat/src/network/mod.rs b/examples/waku-chat/src/network/mod.rs index e3903aa..54f9e60 100644 --- a/examples/waku-chat/src/network/mod.rs +++ b/examples/waku-chat/src/network/mod.rs @@ -1,9 +1,9 @@ pub mod waku; use async_trait::async_trait; -use overwatch::services::handle::ServiceStateHandle; -use overwatch::services::relay::RelayMessage; -use overwatch::services::state::{NoOperator, NoState}; -use overwatch::services::{ServiceCore, ServiceData, ServiceId}; +use overwatch_rs::services::handle::ServiceStateHandle; +use overwatch_rs::services::relay::RelayMessage; +use overwatch_rs::services::state::{NoOperator, NoState}; +use overwatch_rs::services::{ServiceCore, ServiceData, ServiceId}; use std::fmt::Debug; use tokio::sync::mpsc::Sender; diff --git a/overwatch-derive/Cargo.toml b/overwatch-derive/Cargo.toml index 243f890..31564c2 100644 --- a/overwatch-derive/Cargo.toml +++ b/overwatch-derive/Cargo.toml @@ -5,6 +5,17 @@ edition = "2021" authors = [ "Daniel Sanchez Quiros " ] +license-file = "LICENSE" +homepage = "https://github.com/logos-co/Overwatch" +repository = "https://github.com/logos-co/Overwatch" +description = "Overwatch derive macros" +readme = "README.md" +keywords = ["async", "services"] +categories = ["Asynchronous"] +exclude = [ + "./tests", + ".github", +] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/overwatch-derive/README.md b/overwatch-derive/README.md new file mode 100644 index 0000000..0580201 --- /dev/null +++ b/overwatch-derive/README.md @@ -0,0 +1,15 @@ +# Overwatch + +[github](https://github.com/logos-co/Overwatch) +[crates.io](https://crates.io/crates/overwatch-derive) +[docs.rs](https://docs.rs/overwatch-derive) +[build status](https://github.com/logos-co/Overwatch/actions?query=branch%3Amaster) + + +Overwatch is a framework to easily construct applications that requires of several independent +parts that needs communication between them. +Everything is self-contained, and it matches somewhat the advantages of microservices. + +## Overwatch derive + +This crate contains the **derive** utilities for [Overwatch](https://crates.io/crates/overwatch-rs) diff --git a/overwatch-derive/src/lib.rs b/overwatch-derive/src/lib.rs index a5894a6..a5c19f4 100644 --- a/overwatch-derive/src/lib.rs +++ b/overwatch-derive/src/lib.rs @@ -65,7 +65,7 @@ fn generate_services_settings( let service_name = field.ident.as_ref().expect("A named struct attribute"); let _type = utils::extract_type_from(&field.ty); - quote!(pub #service_name: <#_type as ::overwatch::services::ServiceData>::Settings) + quote!(pub #service_name: <#_type as ::overwatch_rs::services::ServiceData>::Settings) }); let services_settings_identifier = service_settings_identifier_from(services_identifier); quote! { @@ -83,7 +83,7 @@ fn generate_assert_unique_identifiers( let services_ids = fields.iter().map(|field| { let _type = utils::extract_type_from(&field.ty); quote! { - <#_type as ::overwatch::services::ServiceData>::SERVICE_ID + <#_type as ::overwatch_rs::services::ServiceData>::SERVICE_ID } }); let services_ids_check = format_ident!( @@ -92,7 +92,7 @@ fn generate_assert_unique_identifiers( ); quote! { - const #services_ids_check: () = assert!(::overwatch::utils::const_checks::unique_ids(&[#( #services_ids ),*])); + const #services_ids_check: () = assert!(::overwatch_rs::utils::const_checks::unique_ids(&[#( #services_ids ),*])); } } @@ -109,7 +109,7 @@ fn generate_services_impl( let impl_update_settings = generate_update_settings_impl(fields); quote! { - impl ::overwatch::overwatch::Services for #services_identifier { + impl ::overwatch_rs::overwatch::Services for #services_identifier { type Settings = #services_settings_identifier; #impl_new @@ -143,7 +143,7 @@ fn generate_new_impl(fields: &Punctuated) -> proc_macro2::TokenStr quote! { #field_identifier: { let manager = - ::overwatch::services::handle::ServiceHandle::<#service_type>::new( + ::overwatch_rs::services::handle::ServiceHandle::<#service_type>::new( #settings_field_identifier, overwatch_handle.clone(), ); manager @@ -152,7 +152,7 @@ fn generate_new_impl(fields: &Punctuated) -> proc_macro2::TokenStr }); quote! { - fn new(settings: Self::Settings, overwatch_handle: ::overwatch::overwatch::handle::OverwatchHandle) -> Self { + fn new(settings: Self::Settings, overwatch_handle: ::overwatch_rs::overwatch::handle::OverwatchHandle) -> Self { let Self::Settings { #( #fields_settings ),* } = settings; @@ -176,7 +176,7 @@ fn generate_start_all_impl(fields: &Punctuated) -> proc_macro2::To quote! { #[::tracing::instrument(skip(self), err)] - fn start_all(&mut self) -> Result<(), ::overwatch::overwatch::Error> { + fn start_all(&mut self) -> Result<(), ::overwatch_rs::overwatch::Error> { #( #call_start )* Ok(()) } @@ -188,7 +188,7 @@ fn generate_start_impl(fields: &Punctuated) -> proc_macro2::TokenS let field_identifier = field.ident.as_ref().expect("A struct attribute identifier"); let type_id = utils::extract_type_from(&field.ty); quote! { - <#type_id as ::overwatch::services::ServiceData>::SERVICE_ID => { + <#type_id as ::overwatch_rs::services::ServiceData>::SERVICE_ID => { self.#field_identifier.service_runner().run(); Ok(()) } @@ -197,10 +197,10 @@ fn generate_start_impl(fields: &Punctuated) -> proc_macro2::TokenS quote! { #[::tracing::instrument(skip(self), err)] - fn start(&mut self, service_id: ::overwatch::services::ServiceId) -> Result<(), ::overwatch::overwatch::Error> { + fn start(&mut self, service_id: ::overwatch_rs::services::ServiceId) -> Result<(), ::overwatch_rs::overwatch::Error> { match service_id { #( #cases ),* - service_id => Err(::overwatch::overwatch::Error::Unavailable { service_id }) + service_id => Err(::overwatch_rs::overwatch::Error::Unavailable { service_id }) } } } @@ -212,16 +212,16 @@ fn generate_stop_impl(fields: &Punctuated) -> proc_macro2::TokenSt let type_id = utils::extract_type_from(&field.ty); // TODO: actually stop them here once service lifecycle is implemented quote! { - <#type_id as ::overwatch::services::ServiceData>::SERVICE_ID => { unimplemented!() } + <#type_id as ::overwatch_rs::services::ServiceData>::SERVICE_ID => { unimplemented!() } } }); quote! { #[::tracing::instrument(skip(self), err)] - fn stop(&mut self, service_id: ::overwatch::services::ServiceId) -> Result<(), ::overwatch::overwatch::Error> { + fn stop(&mut self, service_id: ::overwatch_rs::services::ServiceId) -> Result<(), ::overwatch_rs::overwatch::Error> { match service_id { #( #cases ),* - service_id => Err(::overwatch::overwatch::Error::Unavailable { service_id }) + service_id => Err(::overwatch_rs::overwatch::Error::Unavailable { service_id }) } } } @@ -232,23 +232,23 @@ fn generate_request_relay_impl(fields: &Punctuated) -> proc_macro2 let field_identifier = field.ident.as_ref().expect("A struct attribute identifier"); let type_id = utils::extract_type_from(&field.ty); quote! { - <#type_id as ::overwatch::services::ServiceData>::SERVICE_ID => { + <#type_id as ::overwatch_rs::services::ServiceData>::SERVICE_ID => { Ok(::std::boxed::Box::new( self.#field_identifier .relay_with() .expect("An open relay to service is established") - ) as ::overwatch::services::relay::AnyMessage) + ) as ::overwatch_rs::services::relay::AnyMessage) } } }); quote! { #[::tracing::instrument(skip(self), err)] - fn request_relay(&mut self, service_id: ::overwatch::services::ServiceId) -> ::overwatch::services::relay::RelayResult { + fn request_relay(&mut self, service_id: ::overwatch_rs::services::ServiceId) -> ::overwatch_rs::services::relay::RelayResult { { match service_id { #( #cases )* - service_id => Err(::overwatch::services::relay::RelayError::Unavailable { service_id }) + service_id => Err(::overwatch_rs::services::relay::RelayError::Unavailable { service_id }) } } } @@ -274,7 +274,7 @@ fn generate_update_settings_impl(fields: &Punctuated) -> proc_macr quote! { #[::tracing::instrument(skip(self, settings), err)] - fn update_settings(&mut self, settings: Self::Settings) -> Result<(), ::overwatch::overwatch::Error> { + fn update_settings(&mut self, settings: Self::Settings) -> Result<(), ::overwatch_rs::overwatch::Error> { let Self::Settings { #( #fields_settings ),* } = settings; diff --git a/overwatch/Cargo.toml b/overwatch-rs/Cargo.toml similarity index 54% rename from overwatch/Cargo.toml rename to overwatch-rs/Cargo.toml index aeb1da5..393d830 100644 --- a/overwatch/Cargo.toml +++ b/overwatch-rs/Cargo.toml @@ -1,10 +1,21 @@ [package] -name = "overwatch" +name = "overwatch-rs" version = "0.1.0" edition = "2021" authors = [ "Daniel Sanchez Quiros " ] +license-file = "LICENSE" +homepage = "https://github.com/logos-co/Overwatch" +repository = "https://github.com/logos-co/Overwatch" +description = "Overwatch is a framework to easily construct applications that requires of several independent parts that needs communication between them. Everything is self-contained, and it matches somewhat the advantages of microservices." +readme = "README.md" +keywords = ["async", "services"] +categories = ["Asynchronous"] +exclude = [ + "./tests", + ".github", +] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/overwatch/LICENSE b/overwatch-rs/LICENSE similarity index 100% rename from overwatch/LICENSE rename to overwatch-rs/LICENSE diff --git a/overwatch-rs/README.md b/overwatch-rs/README.md new file mode 100644 index 0000000..f7613c2 --- /dev/null +++ b/overwatch-rs/README.md @@ -0,0 +1,27 @@ +# Overwatch + +[github](https://github.com/logos-co/Overwatch) +[crates.io](https://crates.io/crates/overwatch-rs) +[docs.rs](https://docs.rs/overwatch-rs) +[build status](https://github.com/logos-co/Overwatch/actions?query=branch%3Amaster) + +Overwatch is a framework to easily construct applications that requires of several independent +parts that needs communication between them. +Everything is self-contained, and it matches somewhat the advantages of microservices. + +## Design Goals + +- Modularity: + - Components should be self-contained (as possible) + - Communication relations between components should be specifically defined + - Components should be mockable. This is rather important for measurements and testing. + +- Single responsibility: + - It is easier to isolate problems + - Minimal sharing when unavoidable + +- Debuggeability + - Easy to track workflow + - Easy to test + - Easy to measure + - Asynchronous Communication diff --git a/overwatch/src/lib.rs b/overwatch-rs/src/lib.rs similarity index 100% rename from overwatch/src/lib.rs rename to overwatch-rs/src/lib.rs diff --git a/overwatch/src/overwatch/commands.rs b/overwatch-rs/src/overwatch/commands.rs similarity index 100% rename from overwatch/src/overwatch/commands.rs rename to overwatch-rs/src/overwatch/commands.rs diff --git a/overwatch/src/overwatch/handle.rs b/overwatch-rs/src/overwatch/handle.rs similarity index 100% rename from overwatch/src/overwatch/handle.rs rename to overwatch-rs/src/overwatch/handle.rs diff --git a/overwatch/src/overwatch/mod.rs b/overwatch-rs/src/overwatch/mod.rs similarity index 100% rename from overwatch/src/overwatch/mod.rs rename to overwatch-rs/src/overwatch/mod.rs diff --git a/overwatch/src/services/handle.rs b/overwatch-rs/src/services/handle.rs similarity index 100% rename from overwatch/src/services/handle.rs rename to overwatch-rs/src/services/handle.rs diff --git a/overwatch/src/services/life_cycle.rs b/overwatch-rs/src/services/life_cycle.rs similarity index 100% rename from overwatch/src/services/life_cycle.rs rename to overwatch-rs/src/services/life_cycle.rs diff --git a/overwatch/src/services/mod.rs b/overwatch-rs/src/services/mod.rs similarity index 100% rename from overwatch/src/services/mod.rs rename to overwatch-rs/src/services/mod.rs diff --git a/overwatch/src/services/relay.rs b/overwatch-rs/src/services/relay.rs similarity index 100% rename from overwatch/src/services/relay.rs rename to overwatch-rs/src/services/relay.rs diff --git a/overwatch/src/services/settings.rs b/overwatch-rs/src/services/settings.rs similarity index 100% rename from overwatch/src/services/settings.rs rename to overwatch-rs/src/services/settings.rs diff --git a/overwatch/src/services/state.rs b/overwatch-rs/src/services/state.rs similarity index 100% rename from overwatch/src/services/state.rs rename to overwatch-rs/src/services/state.rs diff --git a/overwatch/src/utils/const_checks.rs b/overwatch-rs/src/utils/const_checks.rs similarity index 100% rename from overwatch/src/utils/const_checks.rs rename to overwatch-rs/src/utils/const_checks.rs diff --git a/overwatch/src/utils/mod.rs b/overwatch-rs/src/utils/mod.rs similarity index 100% rename from overwatch/src/utils/mod.rs rename to overwatch-rs/src/utils/mod.rs diff --git a/overwatch/src/utils/runtime.rs b/overwatch-rs/src/utils/runtime.rs similarity index 100% rename from overwatch/src/utils/runtime.rs rename to overwatch-rs/src/utils/runtime.rs diff --git a/overwatch/tests/print_service.rs b/overwatch-rs/tests/print_service.rs similarity index 91% rename from overwatch/tests/print_service.rs rename to overwatch-rs/tests/print_service.rs index 9153c0e..e21f1e2 100644 --- a/overwatch/tests/print_service.rs +++ b/overwatch-rs/tests/print_service.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; use futures::future::select; -use overwatch::overwatch::OverwatchRunner; -use overwatch::services::handle::{ServiceHandle, ServiceStateHandle}; -use overwatch::services::relay::RelayMessage; -use overwatch::services::state::{NoOperator, NoState}; -use overwatch::services::{ServiceCore, ServiceData, ServiceId}; use overwatch_derive::Services; +use overwatch_rs::overwatch::OverwatchRunner; +use overwatch_rs::services::handle::{ServiceHandle, ServiceStateHandle}; +use overwatch_rs::services::relay::RelayMessage; +use overwatch_rs::services::state::{NoOperator, NoState}; +use overwatch_rs::services::{ServiceCore, ServiceData, ServiceId}; use std::time::Duration; use tokio::time::sleep; diff --git a/overwatch/tests/settings_update.rs b/overwatch-rs/tests/settings_update.rs similarity index 88% rename from overwatch/tests/settings_update.rs rename to overwatch-rs/tests/settings_update.rs index f8d8e23..6c195dd 100644 --- a/overwatch/tests/settings_update.rs +++ b/overwatch-rs/tests/settings_update.rs @@ -1,10 +1,10 @@ use async_trait::async_trait; -use overwatch::overwatch::OverwatchRunner; -use overwatch::services::handle::{ServiceHandle, ServiceStateHandle}; -use overwatch::services::relay::RelayMessage; -use overwatch::services::state::{NoOperator, NoState}; -use overwatch::services::{ServiceCore, ServiceData, ServiceId}; use overwatch_derive::Services; +use overwatch_rs::overwatch::OverwatchRunner; +use overwatch_rs::services::handle::{ServiceHandle, ServiceStateHandle}; +use overwatch_rs::services::relay::RelayMessage; +use overwatch_rs::services::state::{NoOperator, NoState}; +use overwatch_rs::services::{ServiceCore, ServiceData, ServiceId}; use std::time::Duration; use tokio::time::sleep; diff --git a/overwatch/tests/state_handling.rs b/overwatch-rs/tests/state_handling.rs similarity index 88% rename from overwatch/tests/state_handling.rs rename to overwatch-rs/tests/state_handling.rs index 08289bc..26db4b1 100644 --- a/overwatch/tests/state_handling.rs +++ b/overwatch-rs/tests/state_handling.rs @@ -1,10 +1,10 @@ use async_trait::async_trait; -use overwatch::overwatch::OverwatchRunner; -use overwatch::services::handle::{ServiceHandle, ServiceStateHandle}; -use overwatch::services::relay::RelayMessage; -use overwatch::services::state::{ServiceState, StateOperator}; -use overwatch::services::{ServiceCore, ServiceData, ServiceId}; use overwatch_derive::Services; +use overwatch_rs::overwatch::OverwatchRunner; +use overwatch_rs::services::handle::{ServiceHandle, ServiceStateHandle}; +use overwatch_rs::services::relay::RelayMessage; +use overwatch_rs::services::state::{ServiceState, StateOperator}; +use overwatch_rs::services::{ServiceCore, ServiceData, ServiceId}; use std::time::Duration; use tokio::io::{self, AsyncWriteExt}; use tokio::time::sleep;