-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[eventually-postgres] subscribers drop connection and then hang #144
Comments
So, the way I understand it right now, the following happens:
A way I see forward:
|
Hey @to266, thanks for reporting the bug. The fix in #145 works, but I'm not sure the design is correct... My initial idea was to make the However, we might still be able to use pub struct EventSubscriber<Id, Event> {
type_name: &'static str,
config: tokio_postgres::config::Config,
id: std::marker::PhantomData<Id>,
event: std::marker::PhantomData<Event>,
}
impl<Id, Event> EventSubscriber<Id, Event> {
#[inline]
pub fn new(type_name: &'static str, config: tokio_postgres::config::Config) -> Self {
// yadda yadda yadda
}
}
impl<Id, Event> eventually_core::subscription::EventSubscriber for EventSubscriber<Id, Event>
where
// all the necessary type bounds
{
// NOTE: we don't really need a future here, only an EventStream
fn subscribe_all(&self) -> BoxFuture<Result<EventStream<Self>>> {
let fut = async move {
// Maybe TLS should be passed to the constructor?
let (client, connection) = self.config.connect(tls).await?;
let client = Arc::new(client);
let client_captured = client.clone();
let mut stream = futures::stream::poll_fn(move |cx| connection.poll_message(cx));
let stream = try_stream! {
while let Some(event) = stream.next().await {
// An error that stops the whole stream.
let event = event.map_err(EventSubscriber::Stream)?;
if let AsyncMessage::Notification(not) = event {
yield serde_json::from_str::<NotificationPayload<Event>>(not.payload())
.map_err(|e| DeserializeError {
message: e.to_string(),
})?
.and_then(TryInto::try_into);
}
}
drop(client_captured);
};
// Still need to figure out how to call LISTEN using the Client...
// Maybe join the two futures? Use a barrier?
Ok(stream)
};
Box::pin(fut)
}
} |
Let's continue the discussion here: https://github.com/eventually-rs/eventually-rs/discussions/147 |
Describe the bug
Occasionally subscribers fail here
https://github.com/eventually-rs/eventually-rs/blob/718d9acc473cf731276aec67e6148b163073a7dc/eventually-postgres/src/subscriber.rs#L82
with simply a logged statement
This would be OK if the process driving an inmemory projection somehow also failed, as that is part of the public API visible to the users of the library. Then the whole thing can be handled in some way or another. However right now if a
projector
is created as follows, then no error or panic is seen, simply the error is getting logged from thesubscriber
, and projection stops working.To Reproduce
Steps to reproduce the behavior:
projector.run().await
never failsThe text was updated successfully, but these errors were encountered: