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

reworks implementation using coroutines and multiplatform #76

Merged
merged 11 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gitattributes

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run tests
on: push

jobs:
tests:
name: Build and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 11

- uses: eskatos/gradle-command-action@v1
name: Build project
with:
arguments: assemble

- uses: eskatos/gradle-command-action@v1
name: Run tests
with:
arguments: allTests --info
84 changes: 9 additions & 75 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,79 +1,13 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
syntax: glob

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db

# Editor Files #
################
*~
*.swp

# Gradle Files #
################
.gradle
.ivy2
.ivy2.cache
.m2
!gradle-wrapper.jar

# Build output directies
/target
*/target
/build
*/build

# IntelliJ specific files/directories
out
.idea
*.ipr
*.iws
/.idea/*
*.iml
atlassian-ide-plugin.xml

# Eclipse specific files/directories
.classpath
.project
.settings
.metadata

# NetBeans specific files/directories
.nbattrs
/bin

#.gitignore in subdirectory
#.gitignore
.gradle
classes
build/
*.log
/local.properties

### infer ###
# infer- http://fbinfer.com/
infer-out
*/infer-out
.inferConfig
*/.inferConfig
/buildSrc/src/main/kotlin/KampVersions.kt
/buildSrc/src/main/kotlin/KampModules.kt
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions AUTHORS

This file was deleted.

3 changes: 0 additions & 3 deletions CHANGES.md

This file was deleted.

31 changes: 0 additions & 31 deletions CONTRIBUTING.md

This file was deleted.

143 changes: 2 additions & 141 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,141 +1,2 @@
# RSOCKET-KOTLIN
<a href='https://travis-ci.org/rsocket/rsocket-kotlin/builds'><img src='https://travis-ci.org/rsocket/rsocket-kotlin.svg?branch=master'></a> [![Join the chat at https://gitter.im/RSocket/reactivesocket-java](https://badges.gitter.im/RSocket/reactivesocket-java.svg)](https://gitter.im/ReactiveSocket/reactivesocket-java)

R(eactive)Socket: [Reactive Streams](http://www.reactive-streams.org/) over network boundary (tcp, websockets, etc) using Kotlin/Rxjava

RSocket is binary application protocol which models all communication as multiplexed streams of messages over a single network connection, and never synchronously blocks while waiting for a response.

It enables following symmetric interaction models:

* fire-and-forget (no response)
* request/response (stream of 1)
* request/stream (finite/infinite stream of many)
* channel (bi-directional streams)
* per-stream and per-RSocket metadata

#### RPC style interactions support is provided by [RSOCKET RPC - KOTLIN](https://github.com/rsocket/rsocket-rpc-kotlin)

## Build and Binaries

Releases

```groovy
repositories {
maven { url 'https://oss.jfrog.org/libs-release' }
}
```

```groovy
dependencies {
compile 'io.rsocket.kotlin:rsocket-core:0.9.8'
}
```

Snapshots

```groovy
repositories {
maven { url 'https://oss.jfrog.org/libs-snapshot' }
}
```

```groovy
dependencies {
compile 'io.rsocket.kotlin:rsocket-core:0.9.9-SNAPSHOT'
}
```

### Transports

`OkHttp` based Websockets transport (`Client` only)
```groovy
dependencies {
compile 'io.rsocket.kotlin:rsocket-transport-okhttp:0.9.8'
}
```
### Usage
Each side of connection (Client and Server) has `Requester RSocket` for making requests to peer, and `Responder RSocket` to handle requests from peer.

Messages for all interactions are represented as `Payload` of binary (`NIO ByteBuffer`) data and metadata.

UTF-8 `text` payloads can be constructed as follows
```kotlin
val request = DefaultPayload.text("data", "metadata")
```
Stream Metadata is optional
```kotlin
val request = DefaultPayload.text("data")
```
#### Interactions
* Fire and Forget
`RSocket.fireAndForget(payload: Payload): Completable`

* Request-Response
`RSocket.requestResponse(payload: Payload): Single<Payload>`

* Request-Stream
`RSocket.requestStream(payload: Payload): Flowable<Payload>`

* Request-Channel
`RSocket.requestChannel(payload: Publisher<Payload>): Flowable<Payload>`

* Metadata-Push
`fun metadataPush(payload: Payload): Completable`

#### Client
Client is initiator of `Connections`
```kotlin
val rSocket: Single<RSocket> = RSocketFactory // Requester RSocket
.connect()
.acceptor { { requesterRSocket -> handler(requesterRSocket) } } // Optional handler RSocket
.transport(OkhttpWebsocketClientTransport.create(
HttpUrl.Builder()
.host(hostName)
.port(port)
.scheme(scheme)
.build()))
.start()

private fun handler(requester:RSocket): RSocket {
return object : AbstractRSocket() {
override fun requestStream(payload: Payload): Flowable<Payload> {
return Flowable.just(DefaultPayload.text("client handler response"))
}
}
}
```
#### Server
Server is acceptor of `Connections` from `Clients`
```kotlin
val closeable: Single<Closeable> = RSocketFactory
.receive()
.acceptor { { setup, rSocket -> handler(setup, rSocket) } } // server handler RSocket
.transport(WebsocketServerTransport.create(port)) // Netty websocket transport
.start()


private fun handler(setup: Setup, rSocket: RSocket): Single<RSocket> {
return Single.just(object : AbstractRSocket() {
override fun requestStream(payload: Payload): Flowable<Payload> {
return Flowable.just(DefaultPayload.text("server handler response"))
}
})
}

```

### LICENSE

Copyright 2015-2018 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# rsocket-kotlin
RSocket Kotlin multi-platform implementation
13 changes: 13 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TODO
- [ ] Spec test ([TODO] TCK)
- [ ] Frame with length support
- [ ] Fragmentation + Reassembly
- [ ] Lease
- [ ] Resume
- [ ] Composite metadata
- [ ] Tracing
- [ ] Security
- [ ] Routing
- [ ] Routing and Forwarding
- [ ] Load balancing
- [ ] ? Micrometer
23 changes: 23 additions & 0 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
ids(Plugins.benchmarks)
}

configureMultiplatform {
dependenciesMain {
implementation(Dependencies.kotlinx.benchmark)
}
kampCommonMain.dependencies {
implementation(KampModules.core)
implementation(KampModules.transportLocal)
}
}

allOpen {
annotation("org.openjdk.jmh.annotations.State")
}

benchmark {
targets {
register("jvm")
}
}
Loading