Skip to content

Commit

Permalink
Rust I Love u and Hate u
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano Santos committed Feb 13, 2023
1 parent 6f3bbdc commit 61e65b7
Show file tree
Hide file tree
Showing 19 changed files with 1,043 additions and 569 deletions.
123 changes: 122 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spawn-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name = "spawn-examples"
version = "0.1.0"

[dependencies]
env_logger = "0.10.0"
prost-types = "0.11"
spawn-rs = {path = "../spawn-rs"}
tokio = {version = "1.25.0", features = ["full"]}
14 changes: 13 additions & 1 deletion spawn-examples/src/joe.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
use prost_types::Any;

use spawn_rs::{
action::{Action, Message},
action::Action,
actor::{Actor, ActorSettings, Kind},
context::Context,
serializer::Serializer,
value::Value,
Message,
};

pub struct Joe;

impl Serializer for Joe {
fn decode(&mut self, _msg: prost_types::Any) -> Box<dyn std::any::Any> {
todo!()
}

fn encode(&mut self, _msg: Box<dyn std::any::Any>) -> prost_types::Any {
todo!()
}
}

impl Actor for Joe {
fn settings(&mut self) -> ActorSettings {
ActorSettings::new()
Expand Down
3 changes: 3 additions & 0 deletions spawn-examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extern crate env_logger;
extern crate prost_types;
extern crate tokio;

Expand All @@ -7,6 +8,8 @@ use spawn_rs::spawn::Spawn;

#[tokio::main]
async fn main() {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug"));

Spawn::new()
.system("spawn-system".to_string())
.port(8091)
Expand Down
2 changes: 2 additions & 0 deletions spawn-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ name = "spawn-rs"
version = "0.1.0"

[dependencies]
actix-protobuf = "0.9.0"
actix-server = "2.2.0"
actix-web = "4"
env_logger = "0.10.0"
prost = "0.11"
prost-types = "0.11"

Expand Down
2 changes: 1 addition & 1 deletion spawn-rs/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(false)
.out_dir("src/eigr/spawn")
.out_dir("src/eigr")
.compile(
&[
"proto/google/protobuf/any.proto",
Expand Down
2 changes: 1 addition & 1 deletion spawn-rs/proto/actor.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package eigr.functions.protocol.actors;
package eigr.spawn;

import "google/protobuf/any.proto";

Expand Down
24 changes: 12 additions & 12 deletions spawn-rs/proto/protocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
//
syntax = "proto3";

package eigr.functions.protocol;
package eigr.spawn;

import "actor.proto";
import "google/protobuf/any.proto";
Expand All @@ -180,10 +180,10 @@ message Context {
map<string, string> tags = 5;

// Who is calling target actor
eigr.functions.protocol.actors.ActorId caller = 2;
eigr.spawn.ActorId caller = 2;

// The target actor itself
eigr.functions.protocol.actors.ActorId self = 3;
eigr.spawn.ActorId self = 3;
}

// Noop is used when the input or output value of a function or method
Expand All @@ -196,7 +196,7 @@ message RegistrationRequest {

ServiceInfo service_info = 1;

eigr.functions.protocol.actors.ActorSystem actor_system = 2;
eigr.spawn.ActorSystem actor_system = 2;
}

message RegistrationResponse {
Expand Down Expand Up @@ -233,7 +233,7 @@ message ServiceInfo {
}

message SpawnRequest {
repeated eigr.functions.protocol.actors.ActorId actors = 1;
repeated eigr.spawn.ActorId actors = 1;
}

message SpawnResponse {
Expand Down Expand Up @@ -330,9 +330,9 @@ message Workflow {
// * metadata: Meta information or headers
message InvocationRequest {

eigr.functions.protocol.actors.ActorSystem system = 1;
eigr.spawn.ActorSystem system = 1;

eigr.functions.protocol.actors.Actor actor = 2;
eigr.spawn.Actor actor = 2;

string command_name = 3;

Expand All @@ -343,7 +343,7 @@ message InvocationRequest {

bool async = 5;

eigr.functions.protocol.actors.ActorId caller = 6;
eigr.spawn.ActorId caller = 6;

map<string, string> metadata = 8;

Expand All @@ -365,7 +365,7 @@ message InvocationRequest {
// * payload: The value to be passed to the function or method corresponding to command_name.
message ActorInvocation {

eigr.functions.protocol.actors.ActorId actor = 1;
eigr.spawn.ActorId actor = 1;

string command_name = 2;

Expand All @@ -376,7 +376,7 @@ message ActorInvocation {
Noop noop = 5;
}

eigr.functions.protocol.actors.ActorId caller = 6;
eigr.spawn.ActorId caller = 6;
}

// The user function's response after executing the action originated by the local proxy request via ActorInvocation.
Expand Down Expand Up @@ -415,9 +415,9 @@ message InvocationResponse {

RequestStatus status = 1;

eigr.functions.protocol.actors.ActorSystem system = 2;
eigr.spawn.ActorSystem system = 2;

eigr.functions.protocol.actors.Actor actor = 3;
eigr.spawn.Actor actor = 3;

oneof payload {
google.protobuf.Any value = 4;
Expand Down
Loading

0 comments on commit 61e65b7

Please sign in to comment.