Skip to content

how to use userheader in the untyped request/response #1336

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

Open
qclzdh opened this issue Apr 19, 2022 · 8 comments
Open

how to use userheader in the untyped request/response #1336

qclzdh opened this issue Apr 19, 2022 · 8 comments
Labels
feature request Feature request under evaluation

Comments

@qclzdh
Copy link

qclzdh commented Apr 19, 2022

If i have a common IPC send function as following code, parameter msgPayload is untyped, it may changed according some other conditions, and paramter cnt is the number of msgPayload, so the total size i want to send is header + sizeof(msgPayload) * count

bool sendBroadcast(
    const msgHeader& header,
    const msgPayload* payload,
    const uint32_t& cnt)

it is very easy to wrap by using iox untyped_publisher funtions, since loan functions of untyped_publisher has "head" paramter.

loan(const uint32_t userPayloadSize,
         const uint32_t userPayloadAlignment = iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT,
         const uint32_t userHeaderSize = iox::CHUNK_NO_USER_HEADER_SIZE,
         const uint32_t userHeaderAlignment = iox::CHUNK_NO_USER_HEADER_ALIGNMENT)

and i can easily wrap like this,

loan(sizeof(msgPayload) * cnt, alignof(msgPayload), sizeof(msgHeader), alignof(msgHeader));

but how do i use customer header and untyped payload in request/response, it looks like request/response header size is fixed

cxx::expected<void*, AllocationError> UntypedClientImpl<BaseClientT>::loan(const uint32_t payloadSize,
                                                                           const uint32_t payloadAlignment) noexcept

cxx::expected<void*, AllocationError> UntypedServerImpl<BaseServerT>::loan(const RequestHeader* const requestHeader,
                                                                           const uint32_t payloadSize,
                                                                           const uint32_t payloadAlignment) noexcept
@elBoberido
Copy link
Member

@qclzdh request-response does not support a user-header since it already uses that portion of the chunk for it's own header. This means the segmentation must be done by the user on the user-payload portion of the chunk

@qclzdh
Copy link
Author

qclzdh commented Apr 19, 2022

@elBoberido Thanks, if there is no smart way, i will pack them together. It looks a little ugly, but should work well.

@qclzdh
Copy link
Author

qclzdh commented Apr 19, 2022

@elBoberido is there any limitation about payloadAlignment, for example payloadSize % payloadAlignment must equal to 0 ?

@elBoberido
Copy link
Member

elBoberido commented Apr 19, 2022

@qclzdh it's not the most convenient solution but should work. If there is a big demand for a user-header with request-response we can think of extending the API but it might become quite complex on the implementation side

@elBoberido
Copy link
Member

@elBoberido is there any limitation about payloadAlignment, for example payloadSize % payloadAlignment must equal to 0 ?

@qclzdh yes, the assumption was that the payload will contain a struct and therefore the same restrictions apply

@qclzdh
Copy link
Author

qclzdh commented Apr 20, 2022

@qclzdh it's not the most convenient solution but should work. If there is a big demand for a user-header with request-response we can think of extending the API but it might become quite complex on the implementation side

Yes, userHeader is mandatory, please consider to extend the API.

@mossmaurice mossmaurice added the feature request Feature request under evaluation label Apr 27, 2022
@mossmaurice
Copy link
Contributor

@qclzdh @elBoberido I've not come to a final conclusion, but my feeling is the custom user header could also be helpful for rmw_iceoryx, see here: ros2/rmw_iceoryx#84

@qclzdh
Copy link
Author

qclzdh commented Jan 31, 2023

From a user point view, a custom user header would be much more helpful, it's better to support this kind of feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request under evaluation
Projects
None yet
Development

No branches or pull requests

3 participants