Skip to content
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

Support multiple listeners #12

Merged
merged 7 commits into from
Sep 29, 2024
Merged

Support multiple listeners #12

merged 7 commits into from
Sep 29, 2024

Conversation

avnik
Copy link
Contributor

@avnik avnik commented Sep 2, 2024

Description

Support of multiple listeners -- UNIX domain socket, and also add possibility to add vsock support in future.
Also update tonic library to current release

Checklist

  • Summary of the proposed changes in the PR description
  • More detailed description in the commit message(s)
  • Commits are squashed into relevant entities - avoid a lot of minimal dev time commits in the PR
  • Contribution guidelines followed
  • Test procedure added to nixos/tests
  • Author has run nix flake check --accept-flake-config and it passes
  • All automatic Github Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing

TBD

@avnik avnik marked this pull request as draft September 2, 2024 10:12
_request: tonic::Request<pb::systemd::UnitRequest>,
) -> std::result::Result<tonic::Response<pb::systemd::UnitStatusResponse>, tonic::Status> {
_request: Request<pb::systemd::UnitRequest>,
) -> Result<Response<pb::systemd::UnitStatusResponse>, Status> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is already much nicer; could also take it further by using tonic::Result to omit the Status, or even define our own type Result<T> = tonic::Result<Response<T>>.

@avnik avnik force-pushed the avnik/listeners branch 4 times, most recently from d27ef2c to 9fb6e65 Compare September 10, 2024 11:24
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
}

async fn connect_unix_socket(endpoint: Endpoint, path: &String) -> anyhow::Result<Channel> {
let mut path = Some(path.to_owned());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use the Arc based solution here that we discussed earlier.

Ok(ch)
}

async fn connect_vsock_socket(endpoint: Endpoint, vs: &VsockAddr) -> anyhow::Result<Channel> {
Copy link
Contributor

Choose a reason for hiding this comment

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

VsockAddr implements Copy, could just drop the reference and the let ....to_owned() (and use *vs in the caller)

}
}

async fn connect_unix_socket(endpoint: Endpoint, path: &String) -> anyhow::Result<Channel> {
Copy link
Contributor

Choose a reason for hiding this comment

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

&str instead of &String

#[derive(Clone, Debug, PartialEq)]
pub enum EndpointAddress {
Tcp {
// IP + port (FIXME: should be SocketAddres)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using String has the benefit of being able to use names instead of IP-addresses.

@mbssrc mbssrc marked this pull request as ready for review September 29, 2024 15:18
@mbssrc mbssrc merged commit 3344005 into tiiuae:main Sep 29, 2024
1 check passed
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.

3 participants