Fix event subscription envelopes
This commit is contained in:
@ -10,7 +10,7 @@ struct Input {}
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
struct Output {
|
struct Output {
|
||||||
event: Option<Event>,
|
events: Vec<Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle(
|
pub async fn handle(
|
||||||
@ -45,16 +45,16 @@ async fn subscribe(
|
|||||||
.send(OutputEnvelope {
|
.send(OutputEnvelope {
|
||||||
error: None,
|
error: None,
|
||||||
request_nr: req_nr,
|
request_nr: req_nr,
|
||||||
data: to_value(event).unwrap(),
|
data: serde_json::json![{"events": [event]}],
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ok(Output { event: None })
|
Ok(Output { events: vec![] })
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if let Some(event) = rx.recv().await {
|
if let Some(event) = rx.recv().await {
|
||||||
Ok(Output { event: Some(event) })
|
Ok(Output { events: vec![event] })
|
||||||
} else {
|
} else {
|
||||||
Err(Error::new(
|
Err(Error::new(
|
||||||
ErrorKind::SubscriptionError,
|
ErrorKind::SubscriptionError,
|
||||||
|
Reference in New Issue
Block a user