Skip to content

Service server: Extend API to be able to defer a response #1707

Closed

Description

@ivanpauno

Feature request

Feature description

Currently, when creating a service one must provide a callback that takes a request and returns a response.
In some cases, the response cannot be calculated immediately.
It would be useful to also be able to create a service server only providing a callback that takes a request (the request message and the request id), but defers to send a response.
In that case, user code is responsible of sending a response later.

Implementation considerations

I'm currently using a hack in the domain bridge to work around the issue.
The use case is bridging a service between two domains.

In a service callback we want to send the request to another server in a different domain.
A response cannot immediately be sent, because we cannot block in the service callback waiting for the other service to respond.
If we could defer to send a response, we would only need to capture the "request id" in an "async_send_request" callback to the original server, and use in that callback that "request id" and response to complete the bridge.
See here.

Activity

  1. added
    enhancement
    on Jul 1, 2021
  2. changed the title [-]Service server: Extend API to be able to respond to requests asynchronously[/-] [+]Service server: Extend API to be able to defer a response[/+] on Jul 1, 2021
  3. wjwwood commented on Jul 1, 2021

    @wjwwood
    Member

    Is this the same as #491?

  4. ivanpauno commented on Jul 2, 2021

    @ivanpauno
    MemberAuthor

    Is this the same as #491?

    Yes, it's the same.
    My idea was to extend Service constructor so that it also accepts a callback with signature

    void (
          const std::shared_ptr<rmw_request_id_t>,
          const std::shared_ptr<typename ServiceT::Request>);

    instead of adding an AsyncService class.

    @wjwwood what do you think?

  5. wjwwood commented on Jul 12, 2021

    @wjwwood
    Member

    Yes, it's the same.

    Let's close one or the other then.

  6. wjwwood commented on Jul 12, 2021

    @wjwwood
    Member

    instead of adding an AsyncService class.

    Yes, I think this is preferable.

  7. ivanpauno commented on Jul 12, 2021

    @ivanpauno
    MemberAuthor

    Closing in favor of #491.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions