Commit f2b571f8 authored by Katharina Fey's avatar Katharina Fey

rpc-layer: implementing basic socket initialisation

parent 38a8443b
......@@ -1675,6 +1675,7 @@ version = "0.1.0"
dependencies = [
"capnp",
"capnpc",
"ratman-identity",
]
[[package]]
......@@ -1889,8 +1890,11 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
name = "rpc-broker"
version = "0.1.0"
dependencies = [
"async-std",
"capnp",
"qrpc-sdk",
"ratman-identity",
"socket2",
]
[[package]]
......@@ -2064,6 +2068,18 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]]
name = "socket2"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"winapi 0.3.9",
]
[[package]]
name = "sodiumoxide"
version = "0.2.5"
......
......@@ -6,7 +6,9 @@ authors = ["Kaiden Fey <kookie@spacekookie.de>"]
edition = "2018"
[dependencies]
capnp = "*"
identity = { path = "../../ratman/identity", version = "0.4", package = "ratman-identity" }
capnp = "0.13"
[build-dependencies]
capnpc = "*"
\ No newline at end of file
capnpc = "0.13"
\ No newline at end of file
......@@ -13,9 +13,49 @@
//! service needs to register itself and it's capabilities. This
//! mechanism is handled by this sdk.
//!
//! If you want other third-party services to be able to depend on you
//! service you may want to split it into two parts: one part contains
//! the service logic, the other type and RPC interface information.
//! This way a third-party service can include your services' type
//! library (usually called `<service name>-rpc`), and gain access to
//! all public RPC functions.
//! If you want other third-party services to be able to depend on
//! your service you may want to split it into two parts: one part
//! contains the service logic, the other type and RPC interface
//! information. This way a third-party service can include your
//! services' type library (usually called `<service name>-rpc`), and
//! gain access to all public RPC functions.
//!
//! If this is not a requirement for you, don't worry about it.
use identity::Identity;
// FIXME: currently the protocols have to be in the root of the crate
// because of [this issue][i] in the capnproto codegen units:
// [i]: https://github.com/capnproto/capnproto-rust/issues/194
pub(crate) mod carrier_capnp {
#![allow(unused)] // don't bother me pls
include!(concat!(env!("OUT_DIR"), "/schema/carrier_capnp.rs"));
}
/// A service representation on the qrpc system
pub struct Service {
name: String,
version: u16,
description: String,
hash_id: Option<Identity>,
}
impl Service {
/// Create a new service without hash_id
///
/// The `hash_id` field will be filled in by the remote RPC server
/// after calling `register()`.
pub fn new<S: Into<String>>(name: S, version: u16, description: S) -> Self {
Self {
name: name.into(),
version,
description: description.into(),
hash_id: None,
}
}
/// Register this service with the RPC broker/ libqaul
pub async fn register(&mut self) -> Option<()> {
None
}
}
......@@ -6,5 +6,8 @@ authors = ["Kaiden Fey <kookie@spacekookie.de>"]
edition = "2018"
[dependencies]
identity = { path = "../../ratman/identity", version = "0.4", package = "ratman-identity" }
qrpc-sdk = { path = "../qrpc-sdk" }
capnp = "*"
\ No newline at end of file
capnp = "0.13"
socket2 = { version = "0.3", features = ["unix"] }
async-std = "=1.5"
\ No newline at end of file
......@@ -2,6 +2,7 @@
//!
//! An extensible rpc message broker for the libqaul ecosystem.
mod socket;
/// Hold the main broker state
pub struct Broker {
......
//! Wrapper module to read and write to and from an RPC socket
//!
use socket2::{Domain, SockAddr, Socket, Type};
use std::{io::Result, path::Path};
pub(crate) struct RpcSocket {
inner: Socket,
}
impl RpcSocket {
pub(crate) fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
let mut inner = Socket::new(
Domain::unix(),
Type::seqpacket(), // this _may_ not be supported on MacOS
None,
)?;
inner.connect(&SockAddr::unix(path)?)?;
Ok(Self { inner })
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment