-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature: maintenance mode websocket #469
base: develop
Are you sure you want to change the base?
Conversation
…to feature/maintenance-mode-websocket
Nice to see you are working on the backend! :D Small issue / food for thought about this new feature though, in production we run 4 processes for the main endpoints and one for cron jobs. The API calls are distributed evenly over these 4 processes, which is nice for high load situtions. The issue, as you might guess, is that the process that receives the server-setting update might not be the same as the one storing the clients (in the end, you are only connected to a single process with the websocket). Possible solutions include stuff like redis or storing jobs in the db, but I think this solution works best: Also, second remark. I think it would be a bit nicer if we create some pub-sub type structure? (and possible a authentication layer or handshake) In the end it would be nice to use this to get live transaction history on the POS without having to pol continuously. To this end I suggest a structure where you can connect to specific topic (transactions, topups, etc). However it should not be so complex that we are reworking our CRUD endpoints into pubsub topics, but I think a set of predefined topics could get is quite a distance. Maybe just a topic per entity? And also the ability to specify an Id if the entity has one, e.g. Last dump edit: we could create an WSAppDataSource which includes all the subscribers, and based on functions within those subscribers we could effectively send out messages, al whilst keeping the ws in its own process. |
@@ -45,6 +46,7 @@ export default class ServerSettingsController extends BaseController { | |||
public constructor(options: BaseControllerOptions) { | |||
super(options); | |||
this.logger.level = process.env.LOG_LEVEL; | |||
WebSocketService.initiateWebSocket(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this to the index?
* @module websocket | ||
*/ | ||
|
||
export default class WebSocketService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest a singleton class like the ServerSettings
Description
This PR creates a websocket server that we will send a message over once the
PUT /server-settings/maintenance-mode
endpoint is called. This message can be used by the POS to show the maintenance screen as soon as maintenance mode is enabled without having to be refreshed.Related issues/external references
Types of changes