Split out syndicate-server crate

This commit is contained in:
Tony Garnock-Jones 2021-08-12 21:40:48 -04:00
parent 37fd904210
commit 4f30faa1ba
15 changed files with 100 additions and 67 deletions

17
Cargo.lock generated
View File

@ -1283,7 +1283,7 @@ dependencies = [
]
[[package]]
name = "syndicate-rs"
name = "syndicate"
version = "0.2.0"
dependencies = [
"bytes",
@ -1294,10 +1294,21 @@ dependencies = [
"openssl",
"preserves",
"preserves-schema",
"serde",
"serde_bytes",
"sha2",
"tokio",
"tokio-util",
"tracing",
"tracing-futures",
"tracing-subscriber",
]
[[package]]
name = "syndicate-server"
version = "0.2.0"
dependencies = [
"futures",
"structopt",
"syndicate",
"tokio",
"tokio-tungstenite",
"tokio-util",

View File

@ -1,6 +1,7 @@
[workspace]
members = [
"syndicate",
"syndicate-server",
]
[patch.crates-io]

View File

@ -10,14 +10,14 @@ A Rust implementation of:
- the Syndicate network protocol, including
- a high-speed Dataspace indexing structure
([`src/skeleton.rs`](src/skeleton.rs); see also
([`skeleton.rs`](syndicate/src/skeleton.rs); see also
[HOWITWORKS.md](https://git.syndicate-lang.org/syndicate-lang/syndicate-rkt/src/commit/90c4c60699069b496491b81ee63b5a45ffd638cb/syndicate/HOWITWORKS.md)
from `syndicate-rkt`) and
- a standalone Syndicate protocol "broker" service (roughly
comparable in scope and intent to D-Bus); and
- a handful of [example programs](examples/).
- a handful of [example programs](syndicate-server/examples/).
![The Syndicate/rs server running.](syndicate-rs-server.png)
*The Syndicate/rs server running.*

View File

@ -0,0 +1,22 @@
[package]
name = "syndicate-server"
version = "0.2.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
[dependencies]
syndicate = { path = "../syndicate", version = "^0.2.0" }
futures = "0.3.5"
structopt = "0.3.14"
tungstenite = "0.13.0"
tokio-tungstenite = "0.14.0"
tokio = { version = "1.10.0", features = ["io-util", "macros", "sync", "net", "rt", "rt-multi-thread", "time"] }
tokio-util = "0.6.7"
tracing = "0.1.14"
tracing-subscriber = "0.2.5"
tracing-futures = "0.2.4"

50
syndicate-server/Makefile Normal file
View File

@ -0,0 +1,50 @@
all: binary-debug
# cargo install cargo-watch
watch:
cargo watch -c -x check -x 'test -- --nocapture'
run-watch:
RUST_BACKTRACE=1 cargo watch -c -x 'build --all-targets' -x 'run'
inotifytest:
inotifytest sh -c 'reset; cargo build && RUST_BACKTRACE=1 cargo test -- --nocapture'
binary: binary-release
binary-release:
cargo build --release --all-targets
binary-debug:
cargo build --all-targets
# OK, rather than doing it myself (per
# https://eighty-twenty.org/2019/10/15/cross-compiling-rust), it turns
# out past a certain level of complexity we need more than just a
# linker but also a C compiler, compatible headers, and so forth. This
# proved nontrivial. The Rust team maintains a docker-based
# cross-compilation environment that's very easy to use, so instead,
# I'll just use that!
#
# cargo install cross
#
# The `vendored-openssl` thing is necessary because otherwise I'd have
# to mess about with getting a musl build of openssl, plus its headers
# etc, ready on my system despite being otherwise able to rely on
# cross. I think. It's a bit confusing.
arm-binary: arm-binary-release
arm-binary-release:
cross build --target=armv7-unknown-linux-musleabihf --release --all-targets --features vendored-openssl
arm-binary-debug:
cross build --target=armv7-unknown-linux-musleabihf --all-targets --features vendored-openssl
aarch64-binary: aarch64-binary-release
aarch64-binary-release:
cross build --target=aarch64-unknown-linux-musl --release --all-targets --features vendored-openssl
aarch64-binary-debug:
cross build --target=aarch64-unknown-linux-musl --all-targets --features vendored-openssl

View File

@ -32,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let presence: AnyValue = Value::simple_record1(
"Present",
Value::from(std::process::id()).wrap()).wrap();
let handle = syndicate::next_handle();
let handle = syndicate::actor::next_handle();
let assert_e = || {
let ds = Arc::clone(&ds);
let presence = presence.clone();

View File

@ -1,10 +1,6 @@
use futures::SinkExt;
use futures::StreamExt;
use preserves::value::Map;
use preserves::value::NestedValue;
use preserves::value::Value;
use std::future::ready;
use std::io;
use std::iter::FromIterator;
@ -23,6 +19,10 @@ use syndicate::schemas::internal_protocol::_Any;
use syndicate::schemas::gatekeeper;
use syndicate::sturdy;
use syndicate::value::Map;
use syndicate::value::NestedValue;
use syndicate::value::Value;
use tokio::net::TcpListener;
use tokio::net::TcpStream;
use tokio::net::UnixListener;

View File

@ -1,5 +1,5 @@
[package]
name = "syndicate-rs"
name = "syndicate"
version = "0.2.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
@ -7,9 +7,6 @@ edition = "2018"
[features]
vendored-openssl = ["openssl/vendored"]
[lib]
name = "syndicate"
[build-dependencies]
preserves-schema = "0.5.0"
@ -17,10 +14,7 @@ preserves-schema = "0.5.0"
preserves = "0.17.1"
preserves-schema = "0.5.0"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_bytes = "0.11"
tokio = { version = "1.7.1", features = ["macros", "sync", "net", "rt", "rt-multi-thread", "time"] }
tokio = { version = "1.10.0", features = ["io-util", "macros", "sync", "net", "rt", "rt-multi-thread", "time"] }
tokio-util = "0.6.7"
bytes = "1.0.1"
@ -30,11 +24,6 @@ getrandom = "0.2.3"
hmac = "0.11.0"
sha2 = "0.9.5"
structopt = "0.3.14"
tungstenite = "0.13.0"
tokio-tungstenite = "0.14.0"
tracing = "0.1.14"
tracing-subscriber = "0.2.5"
tracing-futures = "0.2.4"

View File

@ -1,55 +1,15 @@
all: binary-debug
# cargo install cargo-watch
watch:
cargo watch -c -x check -x 'test -- --nocapture'
run-watch:
RUST_BACKTRACE=1 cargo watch -c -x 'build --all-targets' -x 'run'
clippy-watch:
cargo watch -c -x clippy
inotifytest:
inotifytest sh -c 'reset; cargo build && RUST_BACKTRACE=1 cargo test -- --nocapture'
binary: binary-release
binary-release:
cargo build --release --all-targets
binary-debug:
cargo build --all-targets
# OK, rather than doing it myself (per
# https://eighty-twenty.org/2019/10/15/cross-compiling-rust), it turns
# out past a certain level of complexity we need more than just a
# linker but also a C compiler, compatible headers, and so forth. This
# proved nontrivial. The Rust team maintains a docker-based
# cross-compilation environment that's very easy to use, so instead,
# I'll just use that!
#
# cargo install cross
#
# The `vendored-openssl` thing is necessary because otherwise I'd have
# to mess about with getting a musl build of openssl, plus its headers
# etc, ready on my system despite being otherwise able to rely on
# cross. I think. It's a bit confusing.
arm-binary: arm-binary-release
arm-binary-release:
cross build --target=armv7-unknown-linux-musleabihf --release --all-targets --features vendored-openssl
arm-binary-debug:
cross build --target=armv7-unknown-linux-musleabihf --all-targets --features vendored-openssl
aarch64-binary: aarch64-binary-release
aarch64-binary-release:
cross build --target=aarch64-unknown-linux-musl --release --all-targets --features vendored-openssl
aarch64-binary-debug:
cross build --target=aarch64-unknown-linux-musl --all-targets --features vendored-openssl
pull-protocols:
git subtree pull -P protocols \
-m 'Merge latest changes from the syndicate-protocols repository' \

View File

@ -163,12 +163,12 @@ where
const BUMP_AMOUNT: u8 = 10;
static NEXT_ACTOR_ID: AtomicU64 = AtomicU64::new(1);
fn next_actor_id() -> ActorId {
pub fn next_actor_id() -> ActorId {
NEXT_ACTOR_ID.fetch_add(BUMP_AMOUNT.into(), Ordering::Relaxed)
}
static NEXT_HANDLE: AtomicU64 = AtomicU64::new(3);
fn next_handle() -> Handle {
pub fn next_handle() -> Handle {
NEXT_HANDLE.fetch_add(BUMP_AMOUNT.into(), Ordering::Relaxed)
}