Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions crates/shim/src/asynchronous/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

use std::os::unix::io::RawFd;

use async_trait::async_trait;
use containerd_shim_protos::{
api::Envelope,
api::{Empty, Envelope},
protobuf::MessageDyn,
shim::events,
shim_async::{Client, EventsClient},
shim_async::{Client, Events, EventsClient},
ttrpc,
ttrpc::context::Context,
ttrpc::{context::Context, r#async::TtrpcContext},
};
use log::{debug, error, warn};
use tokio::sync::mpsc;
Expand Down Expand Up @@ -169,6 +170,29 @@ impl RemotePublisher {
}
}

#[async_trait]
impl Events for RemotePublisher {
async fn forward(
&self,
_ctx: &TtrpcContext,
req: events::ForwardRequest,
) -> ttrpc::Result<Empty> {
let item = Item {
ev: req.envelope().clone(),
ctx: Context::default(),
count: 0,
};

//if channel is full and send fail ,release it after 3 seconds
self.sender
.send_timeout(item, tokio::time::Duration::from_secs(3))
.await
.map_err(|e| error::Error::Ttrpc(ttrpc::error::Error::Others(e.to_string())))?;

Ok(Empty::default())
}
}

#[cfg(test)]
mod tests {
use std::{
Expand Down
Loading