Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonHartley committed Mar 1, 2024
1 parent a2d3f19 commit 9b0c04d
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ members = [
"examples/coerce-cluster-example",
"examples/coerce-sharded-chat-example",
"coerce/tools/coerce-proto-build",
"providers/persistence/coerce-redis",
"providers/discovery/coerce-k8s"
]
"modules/persistence/coerce-redis",
"modules/discovery/coerce-k8s"
, "modules/replication/coerce-replication"]

resolver = "2"
resolver = "2"
4 changes: 3 additions & 1 deletion coerce/src/remote/cluster/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::remote::net::message::{datetime_to_timestamp, timestamp_to_datetime};
use crate::remote::net::proto::network;
use crate::remote::stream::system::ClusterEvent::NodeAdded;
use chrono::{DateTime, Utc};
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::fmt::Display;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
Expand Down Expand Up @@ -62,6 +62,7 @@ pub struct RemoteNode {
pub enum NodeSelector {
All,
Attribute(NodeAttribute),
Ids(HashSet<NodeId>)
}

impl NodeSelector {
Expand All @@ -73,6 +74,7 @@ impl NodeSelector {
match &self {
NodeSelector::All => true,
NodeSelector::Attribute((key, value)) => node.attributes.get(key) == Some(value),
NodeSelector::Ids(ids) => ids.contains(&node.id),
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion coerce/src/singleton/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::actor::message::{
FromBytes, Handler, Message, MessageUnwrapErr, MessageWrapErr, ToBytes,
};
use crate::actor::{Actor, ActorFactory, ActorId, ActorRef, IntoActor, LocalActorRef, ToActorId};
use crate::remote::cluster::node::NodeSelector;
use crate::remote::cluster::node::{NodeSelector, RemoteNodeRef};
use crate::remote::stream::pubsub::{PubSub, Receive, Subscription};
use crate::remote::stream::system::{ClusterEvent, ClusterMemberUp, SystemEvent, SystemTopic};
use crate::remote::system::{NodeId, RemoteActorSystem};
Expand Down Expand Up @@ -37,6 +37,12 @@ pub struct Manager<F: SingletonFactory> {
cluster_up: bool,
}

struct NodeGroup {
node_id: NodeId,
manager_actor: ActorRef<Self>,

Check failure on line 42 in coerce/src/singleton/manager/mod.rs

View workflow job for this annotation

GitHub Actions / Coerce Runtime Test

the trait bound `NodeGroup: persistent::actor::PersistentActor` is not satisfied
node: RemoteNodeRef,
}

impl<F: SingletonFactory> Manager<F> {
pub fn new(
sys: RemoteActorSystem,
Expand Down
2 changes: 1 addition & 1 deletion examples/coerce-sharded-chat-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
coerce = { path = "../../coerce", features = ["full"] }
coerce-macros = { version = "0.2.0" }
coerce-redis = { path = "../../providers/persistence/coerce-redis" }
coerce-redis = { path = "../../modules/persistence/coerce-redis" }
coerce-k8s = { version = "0.1.7" }

tokio = { version = "1.28.1", features = ["full"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cargo run --bin sharded-chat-server -- --node_id 0 --remote_seed_addr 127.0.0.1:31101 --remote_listen_addr 0.0.0.0:31101 --websocket_listen_addr localhost:31102 --cluster_api_listen_addr 127.0.0.1:31103 --log_level DEBUG
cargo run --bin sharded-chat-server -- --node_id 0 --remote_seed_addr 127.0.0.1:31101 --remote_listen_addr 0.0.0.0:31101 --websocket_listen_addr localhost:31102 --cluster_api_listen_addr 127.0.0.1:31103 --log_level DEBUG --redis_addr redis://localhost:6379
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cargo run --bin sharded-chat-server -- --node_id 2 --remote_listen_addr 0.0.0.0:32101 --websocket_listen_addr localhost:32102 --cluster_api_listen_addr 127.0.0.1:32103 --remote_seed_addr 127.0.0.1:33101 --log_level DEBUG
cargo run --bin sharded-chat-server -- --node_id 2 --remote_listen_addr 0.0.0.0:32101 --websocket_listen_addr localhost:32102 --cluster_api_listen_addr 127.0.0.1:32103 --remote_seed_addr 127.0.0.1:31101 --log_level DEBUG --redis_addr redis://localhost:6379
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions modules/replication/coerce-replication/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "coerce-replication"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
16 changes: 16 additions & 0 deletions modules/replication/coerce-replication/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mod simple;

pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
10 changes: 10 additions & 0 deletions modules/replication/coerce-replication/src/simple/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Simple Replicator is a basic system that allows state to be safely replicated
//! across a collection of Coerce nodes.
//!
//!
pub struct SimpleReplicator {

}


0 comments on commit 9b0c04d

Please sign in to comment.