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

reworks implementation using coroutines and multiplatform #76

merged 11 commits into from
Aug 16, 2020

Conversation

whyoleg
Copy link
Member

@whyoleg whyoleg commented Jul 26, 2020

Minimal multi-platform implementation based on coroutines and Ktor
Works on:

  • server
    • JVM: TCP/WS
  • client
    • JVM: TCP/WS
    • JS: WS

@OlegDokuka OlegDokuka added this to the 1.0.0-M1 milestone Jul 26, 2020
@OlegDokuka OlegDokuka linked an issue Jul 26, 2020 that may be closed by this pull request
@OlegDokuka
Copy link
Member

@sdeleuze will appreciate your review! 🙇‍♂️

@OlegDokuka OlegDokuka self-requested a review July 26, 2020 13:56
@yschimke
Copy link
Member

This is massive, love this.

@CommanderTvis
Copy link

That's a big step forward.

@sdeleuze
Copy link

sdeleuze commented Jul 29, 2020

OMG, is it real?

I will review it asap (possible delays due to my upcoming vacations).

Copy link
Member

@OlegDokuka OlegDokuka left a comment

Choose a reason for hiding this comment

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

@whyoleg can you please change all the packages to have the base io.rsocket?

Along, can we add the same license headers to all files as we have it at rsocket-java?

@whyoleg
Copy link
Member Author

whyoleg commented Jul 29, 2020

Yeah, will do on a weekend (on vacation now)


val Cancelable.isActive: Boolean get() = job.isActive

fun Cancelable.cancel(cause: CancellationException? = null) {
Copy link
Member

Choose a reason for hiding this comment

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

curious: Why so many extension methods, instead of defaults on the interface.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mainly code style. But also, default methods can be overridden, so it's even safer to keep them as extensions.
Also, it's more kotlinish

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't say it's kotlin idiomatic, which is why I asked. But not an issue, just curious.

val ignoredFrameConsumer: (Frame) -> Unit = {}
)

fun RSocketClientConfiguration.setupFrame(): SetupFrame = SetupFrame(
Copy link
Member

Choose a reason for hiding this comment

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

curious: again, why an extension method?

Copy link
Member Author

Choose a reason for hiding this comment

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

similar to upper comment, but here, it's even can be just inlined in implementation.

@yschimke
Copy link
Member

yschimke commented Aug 1, 2020

This is a tough big review with a lot of formatting, copyright changes. I won't be doing a deep dive, but once we have snapshots for this I'd love to start testing it against various servers (rsocket-demo, cli) and platforms (JS, Java).

@OlegDokuka
Copy link
Member

OlegDokuka commented Aug 1, 2020

@yschimke @sdeleuze @rstoyanchev I have done the first round of review with @whyoleg - so far so good. I can propose to schedule a call with everyone interested in the review to make grasping of the ideas easier. Let me know your thoughts on that

@yschimke
Copy link
Member

yschimke commented Aug 1, 2020

I'll probably wait until it lands and kick the tires then. This is really great to see!

@OlegDokuka
Copy link
Member

OlegDokuka commented Aug 1, 2020

Also, I'm not a Kotlin expert, so my review is more structure/features/ideas related rather than the idiomatic and best practice of the Kotlin usage oriented

Thus, it is only you @yschimke and @sdeleuze who may bring better Kotlin usage into the place

merge client/server to core package
minor cleanup
payload builder
@yschimke
Copy link
Member

yschimke commented Aug 4, 2020

I'd vote for landing and iterating. I'm keen to test this with my rsocket-cli and flush out issues against rsocket-java server etc.

frames tests
fixing dependencies
add using of experimental annotations in tests
@yschimke
Copy link
Member

yschimke commented Aug 6, 2020

What is the background with the build system, is this standard for kotlin MP projects?

edit: found https://github.com/whyoleg/kamp

@yschimke
Copy link
Member

yschimke commented Aug 6, 2020

Nice, just works against the demo site

@OptIn(KtorExperimentalAPI::class)
val engine: HttpClientEngineFactory<*> = CIO

suspend fun main() {
  val client = HttpClient(engine) {
    install(WebSockets)
    install(RSocketClientSupport)
  }

  val rSocket = client.rSocket("wss://rsocket-demo.herokuapp.com/rsocket")
  val response = rSocket.requestStream(Payload.Empty)

  val flow = response.onEach {
    println(it.data.readText())
  }

  flow.collect()
}
1596695278886
1596695278925
1596695278974
1596695279024
1596695279074

@yschimke
Copy link
Member

yschimke commented Aug 6, 2020

Since Kotlin 1.4 is imminent, and presumably ktor bumps. What are thoughts there? Should I wait before trying to use in my code?

@whyoleg
Copy link
Member Author

whyoleg commented Aug 6, 2020

Since Kotlin 1.4 is imminent, and presumably ktor bumps. What are thoughts there? Should I wait before trying to use in my code?

Should be okay, I don't expect any breaking changes in ktor in what used here.
BTW, I will try to publish some test version today.

@whyoleg
Copy link
Member Author

whyoleg commented Aug 7, 2020

@yschimke First published version for testing can be found on bintray.
Feel free to experiment.

@yschimke
Copy link
Member

yschimke commented Aug 7, 2020

Trying it now, thanks.

Don't take this personally, but a custom DSL for builds inside of gradle kotlin is disorienting. If it's to manage the MP builds and ktor jars, understood.

@whyoleg
Copy link
Member Author

whyoleg commented Aug 7, 2020

custom DSL - yeah, I know, it can be not so intuitive. It's mostly needed for managing MPP dependencies:

  1. Declaring it in one line, instead of line per platform (seems will be not needed after 1.4)
  2. To easy find dependencies, what I need. In MPP project, the default stack is coroutines, serialization, ktor. So plugin contains shortcuts for all of them.
    • simple version management from one place.

* limitations under the License.
*/

package io.rsocket
Copy link
Member

Choose a reason for hiding this comment

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

You are going to need a different package, this one's taken :)

Copy link
Member Author

@whyoleg whyoleg Aug 8, 2020

Choose a reason for hiding this comment

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

We can use or just rsocket (why not?) or as in current repository io.rsocket.kotlin
Not sure about that...

Copy link
Member

Choose a reason for hiding this comment

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

@yschimke do you have any issues with io.rsocket? Are you mixing rsocket-java / kotlin? We discussed that with @whyoleg and I proposed initially to go with io.rsocket unless someone complains. And here this happened. Thus, the question is how much it is critical. If it is critical I would go for kotlin.rsocket or io.rsocket.kotlin

Copy link
Member

Choose a reason for hiding this comment

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

It's a bad idea. Noone does this. How about io.rsocket.kt?

I can't suggest this strongly enough. Don't reuse the package.

Copy link
Member

Choose a reason for hiding this comment

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

do you think kotlin.rsocket will confuse someone?

Copy link
Member

Choose a reason for hiding this comment

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

anyways. I'm good with io.rsocket.kt just wanna have less . in the base pkg name

Copy link
Member

Choose a reason for hiding this comment

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

I'll defer to you both, but just dont overlap.

Copy link
Member

Choose a reason for hiding this comment

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

sure

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's then use io.rsocket.kotlin, I don't really like kt ending. If it's ok, I will change it soon

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me

@yschimke
Copy link
Member

yschimke commented Aug 7, 2020

This is a lovely implementation. Really nice natural API with kotlin flow.

@yschimke
Copy link
Member

yschimke commented Aug 7, 2020

Playing around with a branch here https://github.com/rsocket/rsocket-cli/tree/kotlin

@whyoleg
Copy link
Member Author

whyoleg commented Aug 12, 2020

New version with changed root package name and group: bintray

@OlegDokuka OlegDokuka marked this pull request as ready for review August 16, 2020 07:05
@OlegDokuka OlegDokuka changed the title Fully reworked using coroutines and multiplatform reworks implementation using coroutines and multiplatform Aug 16, 2020
@OlegDokuka OlegDokuka merged commit 66a027d into rsocket:develop Aug 16, 2020
OlegDokuka pushed a commit that referenced this pull request Aug 20, 2020
Minimal multi-platform implementation based on coroutines and Ktor
Works on:

server
JVM: TCP/WS
client
JVM: TCP/WS
JS: WS
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.

Reboot rsocket-kotlin as a multiplatform + Coroutines based project
5 participants