Skip to content

feat: add accept method (supersedes #292)#314

Open
KarstenB wants to merge 1 commit into
containerd:masterfrom
KarstenB:feat/add_accept_method
Open

feat: add accept method (supersedes #292)#314
KarstenB wants to merge 1 commit into
containerd:masterfrom
KarstenB:feat/add_accept_method

Conversation

@KarstenB
Copy link
Copy Markdown

Add accept method for better error handling and ergononics when only one connection is expected. Fixes #293

I didn't want to force push on a branch that is already used externally, but this branch removes the &mut self in favor of a &self.

Add accept method for better error handling and ergononics when only one connection is expected.
Fixes containerd#293

Signed-off-by: Karsten Becker <567973+KarstenB@users.noreply.github.com>
Co-authored-by: Jorge Prendes <jorge.prendes@gmail.com>
@KarstenB KarstenB mentioned this pull request May 12, 2026
pub async fn accept(&self, conn: Socket) -> std::io::Result<()> {
let delegate = ServerBuilder {
services: self.services.clone(),
streams: Arc::default(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: spawn_connection_handler initializes the streams as
streams: Arc::new(Mutex::new(HashMap::new())), so you could consider doing the same here.

Ok(())
}

pub async fn accept(&self, conn: Socket) -> std::io::Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crate defines it's own error type in here:
https://github.com/containerd/ttrpc-rust/blob/master/src/error.rs#L66

Every other public method on Server returns this crate-level Result<()> so can we use this instead?

From a consumer's perspective, if you're using this server and calling multiple methods, you'd expect a consistent error type.

Suggested change
pub async fn accept(&self, conn: Socket) -> std::io::Result<()> {
pub async fn accept(&self, conn: Socket) -> Result<()> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add single connection support to Server

2 participants