extract glee-core from glee
Problem
There is no way to run it on the browser.
Solution
Proposed solution with mockups, views...
Extract Glee's core logic into a separate project called "glee-core." As the name suggests, glee-core would be the foundation of Glee, capable of running on both servers and in browsers. It should expose a class called "Glee" with the following parameters:
- the parsed AsyncAPI spec file.
- a set of lifecycle functions and operation functions.
- some options to configure it further.
not exactly sure what the final interface would look like but it would be something like:
const glee = new Glee(asyncAPI: AsyncAPIDocument, handlers: {lifecycle, operations}, options: Options)
glee.start()
Rabbit holes
Since Glee was not designed for browser execution, there might be compatibility issues with its current dependencies.
Scope
Describe a list of tasks or issues that needs to be done ( you don't need to have an exhaustive list of all the tasks in the beginning)
- [ ] Create a working POC example with Websockets
- [ ] Implement HTTP adapters.
- [ ] Implement Kafka adapter.
- [ ] Implement MQTT adapter.
- [ ] Implement Socket.io adapter.
- [ ] Document how to add new adapters.
- [ ] Deployment how to the project works (tailored to contributors)
Out of bounds
- Integrating "glee-core" into the existing Glee project.
- Adding new features to glee is also not included. (unless added to the scope above)
Success criteria
- completed
glee-corethat can run in browser and node environment. glee-coresupports all of the features that glee currently supports (without dealing with files of-course)- it contains contribution guides, as well as a well documented API.
- it can run current glee example both on server and on the browser (excluding examples featuring a server for the browser).
Implement HTTP adapters. Implement Kafka adapter. Implement MQTT adapter. Implement Socket.io adapter.
I think adapters shouldn't go into glee-core. Actually, I think adapters should also be extracted as independent packages. Some adapters would work on the browser and some not.
Is there a justification for this? 🤔
for starters: https://github.com/asyncapi/glee/issues/794#issuecomment-2057373122
I think adapters shouldn't go into glee-core. Actually, I think adapters should also be extracted as independent packages. Some adapters would work on the browser and some not.
That is a great Idea.
I suggest we go even further, extracting the middleware and allowing the glee-core user to import and use it with the operations that they like.
something like:
import Glee, {string2json} from "@asyncapi/glee-core"
const glee = new Glee(AsyncAPIDocument)
//hello is the operation id.
glee.use('hello', (message: Message, context: Context) => {
const replyText = `you said: ${message.payload}`
message.reply(replyText)
}
})
glee.use('hi', string2json)
glee.use('hi', (message, context) => {
const replyText = `you sent the following json: ${message.payload}`// or maybe message.payload.json() 🤔
message.reply(replyText)
})
glee.start()
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart: