-
Notifications
You must be signed in to change notification settings - Fork 1
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
Define API shape to interact with back-end over WebSockets #119
Comments
What if we want to use multiple |
What if we want to manage services at proxy level? I mean, we should jump into every wss envelope, read the headers of it and forward to the right service which sound impossible to me with websocket connection. |
Hmmm... seems this could work... |
Now i need to think, how to incorporate Protobufs for payload definitions. |
Something feels wrong with current naming. What if const ListModulesResponse {
name: "ListModulesResponse",
body: {
parent: action.payload.id,
page_size: action.payload.pageSize,
page_token: action.payload.pageToken,
}
} So from API we could receive such simple object: {
service: "ModulesService",
rpc: "ListModules",
message: {
name: "ListModulesResponse",
body: {
parent: action.payload.id,
page_size: action.payload.pageSize,
page_token: action.payload.pageToken,
},
},
} Then |
This for now seems good, but carries kinda lot of metadata. All that JSON structure wastes prety much bytes. But it is still much less that plain POST/GET etc request. Also i need to think about some message buffering. If client is trying to send more messages as server can handle. For example large images or other binary data. Connection will be blocked. protoc -I=$SRC_DIR --js_out=$DST_DIR $SRC_DIR/addressbook.proto Motivation:
|
|
Some updates from Go Protobufs |
But I still should think about the bandwidth. If this service will be hosted in some of the clouds, then every extra byte can be costly for event-intensive communication. Same applies for mobile users on 2G and 3G. |
How to import type declarations from external
|
At this point i created simple My questions ATM:
|
Today i got an thought that... probably my current approach of sending entire object of export interface Modules {
readonly entities: { [id: string]: Module }
readonly ids: string[]
} is wasteful. If we are using websocket we should not send large messages. Downsides is that every time new entity arrives, store get updated and thus components get repainted. This could change the communication message shape as we are leaning away from Request/Response thinking more towards Events. New navigation/Component Connected callback Basically UI should not ask for the data. UI just broadcasts an events. Depending on the events, relative data gets streamed back. This is some mental shift in the thinking. |
Every UI component can be an independent subscriber. There is something... I feel i like it. We basically do not care what data we need to request. As components get connected (rendered), they subscribes to their data streams. |
At |
{
service: "ModulesService",
rpc: "SubscribeModulesChannel",
message: {
name: "SubscribeModulesChannelRequest",
body: {
parent: action.payload.id,
page_size: action.payload.pageSize,
page_token: action.payload.pageToken,
},
},
} {
service: "ModulesService",
rpc: "SubscribeModulesChannel",
message: {
name: "SubscribeModulesChannelResponse",
body: {
module: {},
total_entities: 47,
entity_no: 9,
},
},
} |
All channels could be grouped into Services. ModulesService {
Modules
ModulesCreate
ModulesUpdates
} |
When new form get's opened we create draft entity. On form field update we emit update event. On form submit we change entity status from
Idea is to utilize native HTML5 events as much as we can thus stay closer to the native platform API. Event-target gives us an information about the object we are interacting with. Most likely every form will match some kind of domain, like User, Order, OrderLine etc. This would be a hard core to stream every UI level event, but general idea for now is like that. Forms typically already represents some kind of entity and fields are just a entity properties. Also keep in mind UPDATE: I think there i wend down into rabbit hole. 😃 |
Found this project to document WebSocket API - https://www.asyncapi.com/docs/getting-started/coming-from-openapi/ |
Status update |
Other conclusion from the talks i saw is that it is better to implement Bazel workflow as early as possible because migrating monolitic'ish codebase into small bazel modules is not an easy task. |
UPDATE: 2021 |
Still shaving the yak, but i see it worth it in the long term. |
At this point i got really bored to work with Terraform and Ansible in |
ATM mostly working with automation. |
Currently I am using just simple
type
andpayload
structure which will work for a small amount of services, but as amount of services will grow we will encounter bunch of naming collisions. And overall to name the methods will be harder.Right now i have an idea to mimic the RPC style where
wss
message should define the service and the method it is calling.Also i am thinking how to version the methods. Most likely, i don't need to version services as those will be pretty stable, but methods and messages(payload)definitely will be modified over the time.
So, let's define pseudo message shape for now:
The text was updated successfully, but these errors were encountered: