Skip to content

Support for reconnectable, shared Mono<RSocket> - #759

Merged
OlegDokuka merged 10 commits into
developfrom
feature/reconnectable-rsocket
Mar 25, 2020
Merged

OlegDokuka merged 10 commits into
developfrom
feature/reconnectable-rsocket

Conversation

@OlegDokuka

@OlegDokuka OlegDokuka commented Mar 21, 2020 •

Copy link
Copy Markdown
Member

This PR enables a reconnectable RSocket Mono feature which allows to:

  1. Have shared Mono instance without extra effort (extra effort == mono.cache())
  2. Have allocation free blocking (ReconnectMono#block) as in the case of MonoProcessor
  3. Have a Mono which reestablishes connection once the previous has been expired
Mono<RSocket> sharedRSocketMono =          
  RSocketFactory                           
               .connect()                  
               .singleSubscriberRequester()
               .reconnect()                
               .transport(transport)       
               .start();                   
                                           
 RSocket r1 = sharedRSocketMono.block();   // subscribes first so the connection establishement is initiated 
 RSocket r2 = sharedRSocketMono.block();   // attached to the previous process
                                           
 assert r1 == r2;    // same reference                       
                                           
 r1.dispose(); // disposes instance so it is not valid anymore                              
                                           
 assert r2.isDisposed()                    
                                           
 RSocket r3 = sharedRSocketMono.block();   // reistablish a new connection
 RSocket r4 = sharedRSocketMono.block();   // attached to the previous process
                                           
                                           
 assert r1 != r3; // new instance is give (ref check is not valid)                         
 assert r4 == r3; // r3 and r4 are ref equal 
                 
 assert r2.isDisposed(); // previous is still disposed
 assert !r4.isDisposed(); // a new one is healthy 	
                        

Signed-off-by: Oleh Dokuka shadowgun@i.ua

@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from 9ff8f41 to ce7f507 Compare March 21, 2020 19:48
@OlegDokuka

OlegDokuka commented Mar 21, 2020 •

Copy link
Copy Markdown
Member Author

cc\ @rstoyanchev @simonbasle @linux-china @smaldini @yschimke for your review folks

@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from ce7f507 to c7642b3 Compare March 21, 2020 19:50
@OlegDokuka OlegDokuka self-assigned this Mar 21, 2020
@OlegDokuka OlegDokuka changed the title provides a reconnectable Mono<RSocket> feature Reconnectable Mono<RSocket> feature Mar 21, 2020
@OlegDokuka OlegDokuka changed the title Reconnectable Mono<RSocket> feature Reconnectable and Shared Mono<RSocket> feature Mar 21, 2020
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch 3 times, most recently from 323d885 to 9dd3db1 Compare March 21, 2020 21:30

@simonbasle simonbasle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some minor points on the API, otherwise looks good to me

@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from c35cb41 to 0643efb Compare March 24, 2020 10:35
@rstoyanchev

Copy link
Copy Markdown
Contributor

Looks great, exposed through ClientRSocketFactory as opposed to the other alternatives considered.

I'm wondering about using the new Retry from reactor-core which has some very nice built-in options.

For reconnect(), is it too simplistic maybe? Note that since the new Retry exposes a number of strategies it's much easier to configure. Perhaps we don't even need a no-arg reconnect() or do we think there is a good default reconnect strategy?

@OlegDokuka

Copy link
Copy Markdown
Member Author

@rstoyanchev no-args reconnect() is basically fail fast version which does nothing if upstream fails.
I prepared that one if a user does not want to retry at all but wants to have a reconnectable or shared rsocket.

Do you think such an extension (with no retry) is unnecessary?

Note that since the new Retry exposes a

Retry is now a convenient way to do retry, so I'm going to replace function with that one shortly

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from 0643efb to 72ab2d7 Compare March 24, 2020 12:34
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from 17ae73d to 6957a43 Compare March 24, 2020 12:43
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from 74a819c to 26a3548 Compare March 24, 2020 13:24
* assert r4 == r3;
*
* }</pre>
*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would also be worth mentioning or showing that downstream subscribers (i.e. individual requests) are expected to have retry logic, according to their own needs, in order to trigger a reconnect.

@OlegDokuka OlegDokuka Mar 24, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Co-Authored-By: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from ac7fcfe to d1fb0ec Compare March 24, 2020 16:49
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka
OlegDokuka force-pushed the feature/reconnectable-rsocket branch from d1fb0ec to 8523b1e Compare March 25, 2020 07:18
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka
OlegDokuka merged commit da18ea1 into develop Mar 25, 2020
@OlegDokuka
OlegDokuka deleted the feature/reconnectable-rsocket branch March 25, 2020 11:47
@rstoyanchev rstoyanchev modified the milestones: 1.0, 1.0.0-RC7 Apr 17, 2020
@rstoyanchev rstoyanchev changed the title Reconnectable and Shared Mono<RSocket> feature Support for reconnectable, shared Mono<RSocket> Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants