Web server workflow-related state refactoring - #1387
Merged
Conversation
zuozhiw
approved these changes
Feb 8, 2022
zuozhiw
left a comment
Contributor
There was a problem hiding this comment.
Looks good, left a few minor minor comments.
zuozhiw
reviewed
Feb 8, 2022
Yicong-Huang
reviewed
Feb 8, 2022
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
**Workflow State Store** According to our discussion, we want to separate data and logic for each component class in our webserver. So I used protobuf for the data class and added a `SyncableState` (any better names?) to wrap the modification. I created a centralized store for all data classes. This centralized store is called `WorkflowStateStore` and is passed into every service component. The service component can subscribe to any state change and push events to the frontend as a reaction. It can also actively modify any state based on request and this modification will also be observed by other components. **Reason to use protobuf** Although protobuf increases the transmission efficiency but the biggest reason I want to use it is not about that. Protobuf gives us a unified way to define data classes. Since we have the typescript-based frontend, a java/scala/python-based backend, we don't want to write the same data class in different languages. Another reason is that protobuf objects are immutable so we can easily write the `onChanged` API and enforce developers to follow this API to modify the state. Right now protobuf data classes only stay inside the backend. When we send those data to the frontend, a conversion to `TexeraWebsocketEvent` needs to be done so that we can hook up with the existing json serialization/deserialization. In the future, we may replace json with protobuf serialization. **Websocket Input** This module provides an `observable` of frontend requests to workflow internal components inside the web server. So every component has a chance to subscribe to specific events they want to handle. **Lifecycle Manager** This module controls the lifecycle of a workflow state. As I stated before, there is a counter inside each workflow to maintain the current number of active users. Once all users disconnect **AND** the workflow is not in a running state, the cleanup logic will trigger. 
This was referenced Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workflow State Store
According to our discussion, we want to separate data and logic for each component class in our webserver. So I used protobuf for the data class and added a
SyncableState(any better names?) to wrap the modification. I created a centralized store for all data classes. This centralized store is calledWorkflowStateStoreand is passed into every service component. The service component can subscribe to any state change and push events to the frontend as a reaction. It can also actively modify any state based on request and this modification will also be observed by other components.Reason to use protobuf
Although protobuf increases the transmission efficiency but the biggest reason I want to use it is not about that. Protobuf gives us a unified way to define data classes. Since we have the typescript-based frontend, a java/scala/python-based backend, we don't want to write the same data class in different languages. Another reason is that protobuf objects are immutable so we can easily write the
onChangedAPI and enforce developers to follow this API to modify the state. Right now protobuf data classes only stay inside the backend. When we send those data to the frontend, a conversion toTexeraWebsocketEventneeds to be done so that we can hook up with the existing json serialization/deserialization. In the future, we may replace json with protobuf serialization.Websocket Input
This module provides an
observableof frontend requests to workflow internal components inside the web server. So every component has a chance to subscribe to specific events they want to handle.Lifecycle Manager
This module controls the lifecycle of a workflow state. As I stated before, there is a counter inside each workflow to maintain the current number of active users. Once all users disconnect AND the workflow is not in a running state, the cleanup logic will trigger.