-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update introduction section. * remove dependency to the project itself. * update scala versions. * remove extra option for semanticdb. * Revert "update scala versions." This reverts commit 81213ad. * create root project with subprojects. * add scaladoc support. * fmt. * ignore publishing docs. * Revert "ignore publishing docs." This reverts commit 6124203.
- Loading branch information
Showing
13 changed files
with
239 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,96 @@ | ||
# This file was autogenerated using `zio-sbt` via `sbt generateGithubWorkflow` | ||
# task and should be included in the git repository. Please do not edit | ||
# it manually. | ||
# This file was autogenerated using `zio-sbt-website` via `sbt generateGithubWorkflow` | ||
# task and should be included in the git repository. Please do not edit it manually. | ||
|
||
name: website | ||
|
||
on: | ||
name: Website | ||
'on': | ||
workflow_dispatch: {} | ||
release: | ||
types: [ published ] | ||
|
||
types: | ||
- published | ||
push: | ||
branches: | ||
- master | ||
pull_request: {} | ||
jobs: | ||
build: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'pull_request' }} | ||
steps: | ||
- name: Git Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: '0' | ||
- name: Setup Scala | ||
uses: actions/[email protected] | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
check-latest: true | ||
- name: Check that site workflow is up to date | ||
run: sbt docs/checkGithubWorkflow | ||
- name: Check artifacts build process | ||
run: sbt +publishLocal | ||
- name: Check website build process | ||
run: sbt docs/buildWebsite | ||
publish-docs: | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 30 | ||
name: Publish Docs | ||
runs-on: ubuntu-latest | ||
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }} | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Scala and Java | ||
uses: olafurpg/setup-scala@v13 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Publishing Docs to NPM Registry | ||
run: sbt docs/publishToNpm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Git Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: '0' | ||
- name: Setup Scala | ||
uses: actions/[email protected] | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
check-latest: true | ||
- name: Setup NodeJs | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
registry-url: https://registry.npmjs.org | ||
- name: Publish Docs to NPM Registry | ||
run: sbt docs/publishToNpm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
generate-readme: | ||
name: Generate README | ||
runs-on: ubuntu-latest | ||
if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event_name == 'published')) }} | ||
steps: | ||
- name: Git Checkout | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ github.head_ref }} | ||
fetch-depth: '0' | ||
- name: Setup Scala | ||
uses: actions/[email protected] | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
check-latest: true | ||
- name: Generate Readme | ||
run: sbt docs/generateReadme | ||
- name: Commit Changes | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add README.md | ||
git commit -m "Update README.md" || echo "No changes to commit" | ||
- name: Create Pull Request | ||
uses: peter-evans/[email protected] | ||
with: | ||
body: |- | ||
Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin. | ||
I will automatically update the README.md file whenever there is new change for README.md, e.g. | ||
- After each release, I will update the version in the installation section. | ||
- After any changes to the "docs/index.md" file, I will update the README.md file accordingly. | ||
branch: zio-sbt-website/update-readme | ||
commit-message: Update README.md | ||
delete-branch: true | ||
title: Update README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,115 @@ | ||
# Interop reactive streams | ||
[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.) | ||
[//]: # (So please do not edit it manually. Instead, change "docs/index.md" file or sbt setting keys) | ||
[//]: # (e.g. "readmeDocumentation" and "readmeSupport".) | ||
|
||
[![Project stage][Stage]][Stage-Page] | ||
![CI][Badge-CI] | ||
[![Releases][Badge-SonatypeReleases]][Link-SonatypeReleases] | ||
[![Snapshots][Badge-SonatypeSnapshots]][Link-SonatypeSnapshots] | ||
# ZIO Interop Reactive Streams | ||
|
||
This library provides an interoperability layer between ZIO and reactive streams. | ||
|
||
[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/interop-reactive-streams/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-interop-reactivestreams_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-interop-reactivestreams_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-interop-reactivestreams-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-interop-reactivestreams-docs_2.13) [![ZIO Interop Reactive Streams](https://img.shields.io/github/stars/zio/interop-reactive-streams?style=social)](https://github.com/zio/interop-reactive-streams) | ||
|
||
## Introduction | ||
|
||
**ZIO** integrates with [Reactive Streams](http://reactive-streams.org) by providing conversions from `zio.stream.Stream` to `org.reactivestreams.Publisher` and from `zio.stream.Sink` to `org.reactivestreams.Subscriber` and vice versa. Simply import `import zio.interop.reactivestreams._` to make the conversions available. | ||
|
||
## Installation | ||
|
||
In order to use this library, we need to add the following line in our `build.sbt` file: | ||
|
||
```scala | ||
libraryDependencies += "dev.zio" %% "zio-interop-reactive-streams" % "2.0.0" | ||
``` | ||
|
||
## Examples | ||
|
||
First, let's get a few imports out of the way. | ||
|
||
```scala | ||
import org.reactivestreams.example.unicast._ | ||
import zio._ | ||
import zio.interop.reactivestreams._ | ||
import zio.stream._ | ||
``` | ||
|
||
We use the following `Publisher` and `Subscriber` for the examples: | ||
|
||
```scala | ||
val publisher = new RangePublisher(3, 10) | ||
val subscriber = new SyncSubscriber[Int] { | ||
override protected def whenNext(v: Int): Boolean = { | ||
print(s"$v, ") | ||
true | ||
} | ||
} | ||
``` | ||
|
||
### Publisher to Stream | ||
|
||
A `Publisher` used as a `Stream` buffers up to `qSize` elements. If possible, `qSize` should be | ||
a power of two for best performance. The default is 16. | ||
|
||
```scala | ||
val streamFromPublisher = publisher.toZIOStream(qSize = 16) | ||
streamFromPublisher.run(Sink.collectAll[Integer]) | ||
``` | ||
|
||
### Subscriber to Sink | ||
|
||
When running a `Stream` to a `Subscriber`, a side channel is needed for signalling failures. | ||
For this reason `toZIOSink` returns a tuple of a callback and a `Sink`. The callback must be used to signal `Stream` failure. The type parameter on `toZIOSink` is the error type of *the Stream*. | ||
|
||
```scala | ||
val asSink = subscriber.toZIOSink[Throwable] | ||
val failingStream = ZStream.range(3, 13) ++ ZStream.fail(new RuntimeException("boom!")) | ||
ZIO.scoped { | ||
asSink.flatMap { case (signalError, sink) => // FIXME | ||
failingStream.run(sink).catchAll(signalError) | ||
} | ||
} | ||
``` | ||
|
||
### Stream to Publisher | ||
|
||
```scala | ||
val stream = Stream.range(3, 13) | ||
stream.toPublisher.flatMap { publisher => | ||
UIO(publisher.subscribe(subscriber)) | ||
} | ||
``` | ||
|
||
### Sink to Subscriber | ||
|
||
`toSubscriber` returns a `Subscriber` and an `IO` which completes with the result of running the `Sink` or the error if the `Publisher` fails. | ||
A `Sink` used as a `Subscriber` buffers up to `qSize` elements. If possible, `qSize` should be a power of two for best performance. The default is 16. | ||
|
||
```scala | ||
val sink = Sink.collectAll[Integer] | ||
ZIO.scoped { | ||
sink.toSubscriber(qSize = 16).flatMap { case (subscriber, result) => | ||
UIO(publisher.subscribe(subscriber)) *> result | ||
} | ||
} | ||
``` | ||
|
||
## Documentation | ||
|
||
[Homepage](https://zio.dev/zio-interop-reactivestreams) | ||
Learn more on the [ZIO Interop Reactive Streams homepage](https://zio.dev/zio-interop-reactivestreams)! | ||
|
||
## Contributing | ||
|
||
For the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing). | ||
|
||
## Code of Conduct | ||
|
||
See the [Code of Conduct](https://zio.dev/about/code-of-conduct) | ||
|
||
## Support | ||
|
||
Come chat with us on [![Badge-Discord]][Link-Discord]. | ||
|
||
[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord "chat on discord" | ||
[Link-Discord]: https://discord.gg/2ccFBr4 "Discord" | ||
|
||
## License | ||
|
||
[Badge-CI]: https://github.com/zio/interop-reactive-streams/workflows/CI/badge.svg | ||
[Badge-SonatypeReleases]: https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.12.svg "Sonatype Releases" | ||
[Badge-SonatypeSnapshots]: https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.12.svg "Sonatype Snapshots" | ||
[Link-Circle]: https://circleci.com/gh/zio/interop-reactive-streams/tree/master | ||
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-interop-reactivestreams_2.12/ "Sonatype Releases" | ||
[Link-SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-interop-reactivestreams_2.12/ "Sonatype Snapshots" | ||
[Stage]: https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg | ||
[Stage-Page]: https://github.com/zio/zio/wiki/Project-Stages | ||
[License](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.