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

[rx adapter] Requester.requestChannel - No actual subscription until first requester emission #233

Open
MarcoScabbiolo opened this issue Jun 24, 2022 · 1 comment
Labels
needs triage Issue/PR needs triage by a project maintainer

Comments

@MarcoScabbiolo
Copy link

MarcoScabbiolo commented Jun 24, 2022

Expected Behavior

client -> .requestChannel
server -> receives .requestChannel
server -> sends message 1
client -> receives message 1
client -> sends message 2
server -> receives message 2

Actual Behavior

client -> .requestChannel
client -> sends message 1
server -> receives .requestChannel

Possible Solution

This looks intentional, there is some extra logic to do this in the code but I don't know why it is done this way. Receiving message before sending them sounds like a perfectly valid use case for me.

const [firstValueObservable, restValuestObservable] = partition(
datas.pipe(
share({
connector: () => new Subject(),
resetOnRefCountZero: true,
})
),
(_value, index) => index === 0
);
return (
rsocket: RSocket,
metadata: Map<string | number | WellKnownMimeType, Buffer>
) =>
firstValueObservable.pipe(
take(1),
concatMap(
(firstValue) =>
new Observer2BufferingSubscriberToPublisher2PrefetchingObservable(
(
s: OnTerminalSubscriber &
OnNextSubscriber &
OnExtensionSubscriber &
Requestable &
Cancellable
) =>
rsocket.requestChannel(

Why is this done? Wouldnt be better to subscribe right away, even if there is no initial payload?

  • RSocket version(s) used:
"rsocket-adapter-rxjs": "1.0.0-alpha.2",
"rsocket-core": "1.0.0-alpha.1",
@MarcoScabbiolo MarcoScabbiolo changed the title [rx adapter]: requestChannel - No actual subscription until first requester emission [rx adapter]: Requester.requestChannel - No actual subscription until first requester emission Jun 24, 2022
@MarcoScabbiolo MarcoScabbiolo changed the title [rx adapter]: Requester.requestChannel - No actual subscription until first requester emission [rx adapter] Requester.requestChannel - No actual subscription until first requester emission Jun 24, 2022
@viglucci viglucci added the needs triage Issue/PR needs triage by a project maintainer label Jun 30, 2022
@OlegDokuka
Copy link
Member

Hi @MarcoScabbiolo!

This is indeed intentional. As per spec, the Request_Channel frame carries the first payload with it (metadata from which we extract route as well as data, thus we await the first element before initiating the call.

Technically, you can overcome that problem by sending an empty data element.

Alternativelly, we can technically introduce an overloaded method with first element as a parameter, so it can be null. In that case, you may have REQUEST_CHANNEL frame sent upon subscription without the wait for the first element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue/PR needs triage by a project maintainer
Projects
None yet
Development

No branches or pull requests

3 participants