Skip to content

Commit bc97890

Browse files
committed
Add NoopEventPublisher, which will be used as default impl.
Introduces a NoopEventPublisher that implements the EventPublisher trait, but performs no actions when publishing events. It will serve as a convenient default implementation for scenarios where no real event publishing mechanism is required, reducing the burden on developers to provide an explicit publisher in all cases.
1 parent 9741cba commit bc97890

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ldk-server/src/io/events/event_publisher.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,16 @@ pub trait EventPublisher {
4040
/// [`LdkServerErrorCode::InternalServerError`]: crate::api::error::LdkServerErrorCode
4141
async fn publish(&self, event: EventEnvelope) -> Result<(), LdkServerError>;
4242
}
43+
44+
pub(crate) struct NoopEventPublisher;
45+
46+
#[async_trait]
47+
impl EventPublisher for NoopEventPublisher {
48+
/// Publishes an event to a no-op sink, effectively discarding it.
49+
///
50+
/// This implementation does nothing and always returns `Ok(())`, serving as a
51+
/// default when no messaging system is configured.
52+
async fn publish(&self, _event: EventEnvelope) -> Result<(), LdkServerError> {
53+
Ok(())
54+
}
55+
}

0 commit comments

Comments
 (0)