Description
The coderd processor part is the one connecting all the other components and defining, based on inputs, the state of the workspace.
This issue requires to :
- Create a migration in the database to store the state of workspaces. The migration is :
CREATE TYPE workspace_monitor_state AS ENUM ('OK', 'NOK');
CREATE TABLE workspace_monitors (
workspace_id uuid NOT NULL,
state workspace_monitor_state NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
debounced_until timestamp with time zone NOT NULL
);
The workspace_monitors describes - for each workspace - what is the current state. It is used to keep track of the current state and choose what action to take next based on the current state.
This monitor will be fetched and potentially updated at each tick.
- Implement the processor logic that determine if a workspace is in an healthy state or not.
- Definition of the different states for a workspace can be defined based on the above diagram :
- A workspace switch to OK when all the last points sent are OK.
- A workspace switch to NOK when :
- either 4 points in a row
- either 10 out of the last 20 points
are NOK.
- Push the state in the database based on the determined value
- Push a notification to notifier if the workspace goes from healthy to unhealthy - also using the
debounced_until
logic :
This extra layer works in a very simple way - whenever a notification is sent, the debounced_until
field is set to now() + x minutes.
Whenever we want to send a notification, if now() < debounced_until
- then we ignore it.
Metadata
Metadata
Assignees
Labels
No labels