-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adopt TypeScript & Refocus Core APIs #158
Comments
Thank you so much for working on this. |
wonderful, thanks |
Maybe that support for interceptors could be added to the desired solution checklist #192 ? |
Hi @viglucci, thank you so much for your efforts on this - this would make our lives so much easier. If you'd like us to "beta test" any of your changes, let me know when you think it's ready to look at. I'm particularly excited about the removal of Flowable - we currently have a RxJS<->Flowable interop layer which pretty much completely disables the back-pressure features of Flowable. It would be awesome if we could just use regular RxJS operators on Flowables. This could be achieved by making a Flowable implement the For example, we currently define To implement As API inspiration, I found the Apple Combine |
Hi @lachenmayer, and others. Many thanks for your kind words and encouragement. In regards to beta testings the changes that have been made, we are hoping to have a In regards to RxJS interoperability, one of our goals is definitely improved interoperability with existing reactive libraries, and to support future implementations (such as a Reactive Streams compliant library in JavaScript). We believe this will likely take the form of an "extension" library which will wrap/compose with the core RSocket APIs, rather than as a core feature of RSocket-JS. I discussed this approach a bit more here. You'll see in the linked example of an RxJS extension that the API is pretty simple, though the batching approach you mention should likely be something we consider. The finer details of how the extensions will take shape, and which we'll implement immediately are all still very much in the works though, so I do appreciate the details and examples you've provided above, as they will likely serve well as inspiration. |
Providing a status update on this effort: We believe we are at a point with the Additionally, there have been some conversations around how to best support browser environments that require a |
We are excited to share that we've released the first alpha versioned artifacts from this effort. 🎉 😄 Please see the 1.0.0-alpha.1 release for an overview. |
Hi all,
|
Hi @viglucci, I'm finally getting around to integrating RSocket 1.0 in a greenfield project, so I'll be adding to this thread as and when I find anything worth sharing. So far loving the simple integration with RxJS, particularly on the client side this has reduced our RSocket setup code by at least 10x. Great work on that. I had one small hiccup that I've had to hack around on the server side. We're running an Express server with some "normal" HTTP endpoints, and we want RSocket to only listen on a We have an existing const websocketServer = new WebSocket.Server({
server: httpServer,
path: '/subscriptions',
})
const transport = new WebsocketServerTransport({
wsCreator: () => websocketServer,
})
const rsocketServer = new RSocketServer({
transport,
// ...
}) We were calling this as follows in our server setup code: await listen() // () => new Promise<void>((resolve) => httpServer.listen(env.port, resolve))
await rsocketServer.bind() This didn't work though, as I noticed that
Manually adding Instantiating the I can fix this for now by instantiating the RSocket server before listening on the HTTP server, eg.: const rsocketStarted = rsocketServer.bind()
await listen()
await rsocketStarted ...but it's a bit confusing that the order makes a difference. I can see why we'd want to await the Anyway not a blocker at all, just a papercut :) Will report on more as I come across it & once again thanks a lot for working on this! |
Thanks for the feedback @lachenmayer . I've documented this behavior in #237 . |
Tiny tiny API inconsistency in the RxJS adapter: on the rsocket-js/packages/rsocket-adapter-rxjs/src/Requesters.ts Lines 70 to 71 in c6d6c47
rsocket-js/packages/rsocket-adapter-rxjs/src/Responders.ts Lines 62 to 65 in c6d6c47
I would personally prefer the object approach, as I'm not a huge fan of having multiple unnamed parameters with the same type, but easy either way :) Also, I fully agree with your rationale of not providing any In fact we were able to easily implement our RSocket endpoints without using It took me a while to piece apart the RxJS example since it relies heavily on const server = new RSocketServer({
transport,
acceptor: {
async accept(setupPayload) {
return {
requestStream: RxRespondersFactory.requestStream((data) => {
return of(data) // arbitrary RxJS stream!
}, codecs),
}
},
},
}) Once again, amazing work on this API - this was previously a huge amount of work. (Sorry, I am currently under heavy deadline pressure for at least the rest of this month, otherwise I would definitely just contribute this myself!) |
Also another super tiny inconvenience in the RxJS requesters API: we're currently not using
|
@lachenmayer please see #241 which addresses #158 (comment). Additionally you can experiment with this change in |
Can confirm the fixed requesters API works great for us with |
I'm looking into this, but it might not be for a bit. In doing so, I found that we weren't leveraging I'll need to consider moving Thanks again for the valuable feedback! |
This is awesome, thank you very much for the effort. I'm about to migrate and I'm curious about:
|
@viglucci Is there an alternative in v1? |
Hi there, a few answers to the above questions (not exhaustive).
We aimed to aligned some of the terminology with other implementations, such as RSocket-Java.
I don't have a great answer for this, I haven't used
While not an exact replacement, const connector = new RSocketConnector({
transport: new WebsocketClientTransport({
url: "ws://localhost:8080",
wsCreator: (url) => new WebSocket(url) as any,
}),
});
const rsocket = await connector.connect();
rsocket.onClose((err) => {
// server has gone away
});
We have the documentation on roscket.io that I expect to be updated once |
Thank you very much @viglucci for the clarification :) |
It seems that stream of node is not supported. Pipe method and back pressure example of node |
@viglucci Is this project dead? |
the rxjs example 2, does not work, only work if you exit app if vou send more data crash |
This issue proposes that an effort should be made to re-write the core set of
rsocket-js
packages from Flow to TypeScript, with a focus on adopting a "small core" mentality when designing the projects public API.This issue is to serve as:
Motivation
TypeScript in Favor of Flow
TypeScript is a proven solution for authoring JavaScript libraries for use in NodeJs and browser environments, and will provide a number of benefits to the project:
@types
In addition to the above, in a recent post on the Flow Type blog, the Flow team described a refocusing of the projects priorities towards Facebook's internal needs. This is a signal that Flow may not be a suitable solution for projects outside of Facebook's internal infrastructure and ecosystem.
Small Core
New APIs and paradigms should be introduced to adopt a "small core" mentality, with core
rsocket-js
packages providing only the basic building blocks and implementations for the RSocket protocol. APIs should be easily extendable/composable to support additional packages that can later provide functionality outside of implementing the RSocket protocol, for example, anRxJS
interface.This "small core" approach is intended to assist with maintainability of the project, as well as ease of support for satisfying feature requests through extensions and "addon" packages.
Other RSocket implementations, such as RSocket-Swift, have benefited to a degree from this approach.
Serialization and Encoding
In conformance with the "small core" goal of this initiative, support for payload data encoding should be reduced down to transmitting instances of
Buffer
, rather than supporting a wide variety ofdata
andmetadata
payload serialization and encodings. This stance is in contrast to the current support provided by@rsocket
packages, where support for serializing objects to JSON and other formats is provided by interfaces such asJsonSerializer
, and encoding is provided by interfaces such asBufferEncoders
.Support for user friendly translation of objects and other structures to/from
JSON
and other serialization formats can be accomplished via extension packages, rather than as a core feature ofrsocket-js
.Reactive APIs
rsocket-js
has historically leveraged a Reactive Streams implementation (rsocket-flowable) both internally, and as its public API. This implementation has historically been published under@rsocekt/rsocket-flowable
. Moving forward,rsocket-js
will move away from@rsocket/rsocket-flowable
as a key feature of its public API, and instead focus on exposing a core set of Stream APIs that satisfy the core requirements of the RSocket protocol, while also promoting composition and extension with other Reactive Streams implementations, such as RxJS and reactive-streams-js.Interfaces example:
The intention of this change is two fold:
rsocket-js
librariesrsocket-js
with their Reactive Streams implementation of choiceDesired solution
Core RSocket protocol feature support, and APIs implementations needed:
RSocketConnector
APITODO: complete list of necessary core protocol features
Considered alternatives
N/A
Additional context
Major Version Change
Because of the breaking API changes that this effort will introduce, the version of all
@rsocket
scoped packages who's APIs are modified will be incremented to an initial major version release of1.0
.Issues & pull requests related to this work should be/are tagged with the
1.0
tag.Work in progress
Work for this effort is ongoing in the
dev
branch.API Example
The text was updated successfully, but these errors were encountered: