mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-10 17:43:23 +01:00
Makes rumqttc futures run on the tokio runtime as required.
This commit is contained in:
parent
e9b1ba1f50
commit
ea863e71af
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -79,6 +79,19 @@ dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-compat"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b48b4ff0c2026db683dea961cd8ea874737f56cffca86fa84415eaddc51c00d"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-executor"
|
||||
version = "1.4.1"
|
||||
@ -515,6 +528,7 @@ name = "diflouroborane"
|
||||
version = "0.3.2"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-compat",
|
||||
"async-rustls",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
|
@ -51,6 +51,7 @@ rsasl = "1.4.0"
|
||||
#rsasl = { path = "../../rsasl" }
|
||||
|
||||
rumqttc = { version = "0.10", features = ["url"] }
|
||||
async-compat = "0.2.1"
|
||||
url = "2.2.2"
|
||||
|
||||
#mlua = { version = "0.4", features = ["async", "luajit"] }
|
||||
|
@ -9,6 +9,7 @@ use futures::{future::BoxFuture, Stream};
|
||||
use futures::channel::mpsc;
|
||||
use futures_signals::signal::Signal;
|
||||
use rumqttc::{AsyncClient, ConnectionError, Event, Incoming, MqttOptions};
|
||||
use async_compat::CompatExt;
|
||||
|
||||
use crate::db::machine::MachineState;
|
||||
use crate::config::Config;
|
||||
@ -175,12 +176,12 @@ pub fn load(log: &Logger, config: &Config) -> Result<(ActorMap, Vec<Actor>)> {
|
||||
}
|
||||
|
||||
Ok(eventloop)
|
||||
})?;
|
||||
}.compat())?;
|
||||
let dlog = log.clone();
|
||||
smol::spawn(async move {
|
||||
let mut fault = false;
|
||||
loop {
|
||||
match eventloop.poll().await {
|
||||
match eventloop.poll().compat().await {
|
||||
Ok(_) => {
|
||||
fault = false;
|
||||
// TODO: Handle incoming MQTT messages
|
||||
@ -213,7 +214,7 @@ pub fn load(log: &Logger, config: &Config) -> Result<(ActorMap, Vec<Actor>)> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).detach();
|
||||
}.compat()).detach();
|
||||
|
||||
let actuators = config.actors.iter()
|
||||
.map(|(k,v)| (k, load_single(log, k, &v.module, &v.params, mqtt.clone())))
|
||||
|
Loading…
Reference in New Issue
Block a user