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

Provide JDK flow adapters #824 #904

Merged
merged 3 commits into from Jan 7, 2020
Merged

Conversation

muthupalaniappan
Copy link
Contributor

@muthupalaniappan muthupalaniappan commented Dec 28, 2019

Motivation:

For interoperability with JDK Flow today we dont have direct flow adapters, users have to use ReactiveStreams adapters and then use the Flow adapter provided by ReactiveStreams which is two step conversion and additional dependency on ReactiveStreams.

Modifications:

  • Added a new module servicetalk-concurrent-jdkflow and applied servicetalk-gradle-plugin-internal-library
  • Since flow apis are available only from jdk 9 it gets little tricky here and have to deviate from the standards as below
  • Build the module only if jdk 9 or above is available during build
  • Override the source and target compatibility of the module to jdk9
  • Added JdkFlowAdapters class in main similar to ReactiveStreamsAdapters
  • Added JdkFlowAdaptersTest test class in test similar to ReactiveStreamsAdaptersTest test class.

Result:
A new module servicetalk-concurrent-jdkflow is added which can be used with jdk9 and above for interoperability with JDK flow api.

Fixes #824

@servicetalk-bot
Copy link
Contributor

Can one of the admins verify this patch?

3 similar comments
@servicetalk-bot
Copy link
Contributor

Can one of the admins verify this patch?

@servicetalk-bot
Copy link
Contributor

Can one of the admins verify this patch?

@servicetalk-bot
Copy link
Contributor

Can one of the admins verify this patch?

@NiteshKant
Copy link
Collaborator

@servicetalk-bot test this please

NiteshKant pushed a commit to NiteshKant/servicetalk that referenced this pull request Jan 2, 2020
__Motivation__

As part of reviewing apple#904 following issues were observed in `ReactiveStreamsAdapters`:

- One method Javadoc had a typo linking to the wrong class.
- Name of internal classes were not consistently indicating the intent.
- Internal class `PublisherToRSPublisher` is redundant, we can instead use `PublisherSourceToRSPublisher`

__Modification__

- Fixed javadoc
- Renamed classes to follow [Rs, St]To[Rs, St][Publisher, Subscriber, Subscription] format
- Inlined a variable in the test.

__Result__

Better readability for `ReactiveStreamsAdapters`
Copy link
Collaborator

@NiteshKant NiteshKant left a comment

Choose a reason for hiding this comment

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

Thanks @muthupalaniappan for the contribution.

I noticed some minor cosmetic issues with the reactive-streams adapter implementation for which I have created a PR #906 for your reference and have also marked the changes in this PR.

}
}

private static final class FlowSubscriber<T> implements PublisherSource.Subscriber<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Rename to StToFlowSubscriber to match the other class names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should then be FlowToStSubscriber

NiteshKant pushed a commit that referenced this pull request Jan 2, 2020
__Motivation__

As part of reviewing #904 following issues were observed in `ReactiveStreamsAdapters`:

- One method Javadoc had a typo linking to the wrong class.
- Name of internal classes were not consistently indicating the intent.
- Internal class `PublisherToRSPublisher` is redundant, we can instead use `PublisherSourceToRSPublisher`

__Modification__

- Fixed javadoc
- Renamed classes to follow [Rs, St]To[Rs, St][Publisher, Subscriber, Subscription] format
- Inlined a variable in the test.

__Result__

Better readability for `ReactiveStreamsAdapters`
Motivation:

For interoperability with JDK Flow today we dont have direct flow adapters, users have to use ReactiveStreams adapters and then use the Flow adapter provided by ReactiveStreams which is two step conversion and additional dependency on ReactiveStreams.

Modifications:

* Added a new module `servicetalk-concurrent-jdkflow` and applied `servicetalk-gradle-plugin-internal-library`
* Since flow apis are available only from jdk 9 it gets little tricky here and have to deviate from the standards as below
* Build the module only if jdk 9 or above is available during build
* Override the source and target compatibility of the module to jdk9
* Added `JdkFlowAdapters` class in main similar to `ReactiveStreamsAdapters`
* Added `JdkFlowAdaptersTest` and `reactive-streams-tck-flow` tests in test similar to `ReactiveStreamsAdaptersTest` and `reactive-streams-tck` tests

Result:
A new module servicetalk-concurrent-jdkflow is added which can be used with jdk9 and above for interoperability with JDK flow api.

Fixes apple#824
Motivation:

For interoperability with JDK Flow today we dont have direct flow adapters, users have to use ReactiveStreams adapters and then use the Flow adapter provided by ReactiveStreams which is two step conversion and additional dependency on ReactiveStreams.

Modifications:

* Added a new module `servicetalk-concurrent-jdkflow` and applied `servicetalk-gradle-plugin-internal-library`
* Since flow apis are available only from jdk 9 it gets little tricky here and have to deviate from the standards as below
* Build the module only if jdk 9 or above is available during build
* Override the source and target compatibility of the module to jdk9
* Added `JdkFlowAdapters` class in main similar to `ReactiveStreamsAdapters`
* Added `JdkFlowAdaptersTest` test class in test similar to `ReactiveStreamsAdaptersTest` test class

Result:
A new module servicetalk-concurrent-jdkflow is added which can be used with jdk9 and above for interoperability with JDK flow api.

Fixes apple#824
@NiteshKant
Copy link
Collaborator

@servicetalk-bot test this please

Copy link
Collaborator

@NiteshKant NiteshKant left a comment

Choose a reason for hiding this comment

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

@NiteshKant
Copy link
Collaborator

@muthupalaniappan can you also update the docs to reflect this change now?

This is where you need to change:

https://github.com/apple/servicetalk/blob/master/servicetalk-concurrent-api/docs/modules/ROOT/pages/asynchronous-primitives.adoc

Under "Interoperability", modify the statement:

For interoperability we provide ReactiveStreams adapters and may provide similar Flow adapters in the future.

to

For interoperability we provide ReactiveStreams and JDK Flow adapters.

@muthupalaniappan
Copy link
Contributor Author

Thanks @NiteshKant , As you have already approved it should I make the doc change in a separate PR?

@NiteshKant
Copy link
Collaborator

@muthupalaniappan its ok to do the change in this PR, I can re-review

Motivation:

For interoperability with JDK Flow today we dont have direct flow adapters, users have to use ReactiveStreams adapters and then use the Flow adapter provided by ReactiveStreams which is two step conversion and additional dependency on ReactiveStreams.

Modifications:

* Added a new module `servicetalk-concurrent-jdkflow` and applied `servicetalk-gradle-plugin-internal-library`
* Since flow apis are available only from jdk 9 it gets little tricky here and have to deviate from the standards as below
* Build the module only if jdk 9 or above is available during build
* Override the source and target compatibility of the module to jdk9
* Added `JdkFlowAdapters` class in main similar to `ReactiveStreamsAdapters`
* Added `JdkFlowAdaptersTest` test class in test similar to `ReactiveStreamsAdaptersTest` test class

Result:
A new module servicetalk-concurrent-jdkflow is added which can be used with jdk9 and above for interoperability with JDK flow api.

Fixes apple#824
@NiteshKant
Copy link
Collaborator

@servicetalk-bot test this please

Copy link
Collaborator

@NiteshKant NiteshKant left a comment

Choose a reason for hiding this comment

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

@NiteshKant NiteshKant merged commit 5698947 into apple:master Jan 7, 2020
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.

Provide JDK flow adapters
3 participants