Skip to content

Commit

Permalink
Merge pull request #22 from wiktor-k/reintroduce-service-binding
Browse files Browse the repository at this point in the history
Add `Agent::bind` to accept `service_binding::Listener`s
  • Loading branch information
wiktor-k authored Mar 15, 2024
2 parents 2edc1fb + 79a5a28 commit e494afa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ futures = { version = "0.3.30", optional = true }
log = { version = "0.4.6", optional = true }
tokio = { version = "1", optional = true, features = ["rt", "net"] }
tokio-util = { version = "0.7.1", optional = true, features = ["codec"] }
service-binding = "1.1.0"

[features]
default = ["agent"]
Expand Down
10 changes: 10 additions & 0 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ pub trait Agent: 'static + Sync + Send + Sized {
}
}
}
async fn bind(mut self, listener: service_binding::Listener) -> Result<(), AgentError> {
match listener {
service_binding::Listener::Unix(listener) => {
self.listen(UnixListener::from_std(listener)?).await
}
service_binding::Listener::Tcp(listener) => {
self.listen(TcpListener::from_std(listener)?).await
}
}
}
}

impl<T> Agent for T
Expand Down

0 comments on commit e494afa

Please sign in to comment.