-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adriano Santos
committed
Sep 18, 2023
1 parent
25f0c9d
commit 2999a78
Showing
14 changed files
with
213 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub(crate) fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
tonic_build::configure() | ||
.build_server(false) | ||
.out_dir("src/domain") | ||
.compile(&["proto/domain.proto"], &["proto"])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
|
||
package domain; | ||
|
||
message State { | ||
repeated string languages = 1; | ||
} | ||
|
||
message Request { | ||
string language = 1; | ||
} | ||
|
||
message Reply { | ||
string response = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[allow(clippy::derive_partial_eq_without_eq)] | ||
#[derive(Clone, PartialEq, ::prost::Message)] | ||
pub struct State { | ||
#[prost(string, repeated, tag = "1")] | ||
pub languages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, | ||
} | ||
#[allow(clippy::derive_partial_eq_without_eq)] | ||
#[derive(Clone, PartialEq, ::prost::Message)] | ||
pub struct Request { | ||
#[prost(string, tag = "1")] | ||
pub language: ::prost::alloc::string::String, | ||
} | ||
#[allow(clippy::derive_partial_eq_without_eq)] | ||
#[derive(Clone, PartialEq, ::prost::Message)] | ||
pub struct Reply { | ||
#[prost(string, tag = "1")] | ||
pub response: ::prost::alloc::string::String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
use prost_types::Any; | ||
|
||
use spawn_examples::domain::domain::{Reply, Request}; | ||
use spawn_rs::{context::Context, value::Value, Message}; | ||
|
||
pub fn sum(_msg: Message, ctx: Context) -> Value { | ||
return Value::new() | ||
.state(ctx.state().clone()) | ||
.response(Any::default()) | ||
.to_owned(); | ||
use log::info; | ||
|
||
pub fn set_language(msg: Message, ctx: Context) -> Value { | ||
info!("Actor msg: {:?}", msg); | ||
let value: Value = match msg.body::<Request>() { | ||
Ok(request) => { | ||
let lang = request.language; | ||
info!("Setlanguage To: {:?}", lang); | ||
let reply = Reply::default(); | ||
|
||
Value::new() | ||
.state(ctx.state().clone()) | ||
.response(&Reply::default()) | ||
.to_owned() | ||
} | ||
Err(e) => Value::new() | ||
.state(ctx.state().clone()) | ||
//.response(Any::default()) | ||
.to_owned(), | ||
}; | ||
|
||
return value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[macro_use] | ||
extern crate log; | ||
extern crate prost_types; | ||
|
||
pub mod domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.