Skip to content

Commit

Permalink
Add getStatus and done methods to EventStore
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsharpe committed Jan 28, 2024
1 parent 21ae5e5 commit 8360ddf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/server/grimoire/src/lib/services/eventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ export interface IEventStore {
currentEvent: () => EventPayload | null
setEvent: (event: EventPayload) => void
init: (nodes: GraphNodes) => void
getStatus: () => StatusEnum
done: () => void
}

export enum StatusEnum {
INIT = 'INIT',
RUNNING = 'RUNNING',
DONE = 'DONE',
ERRORED = 'ERRORED',
}

export class EventStore implements IEventStore {
private _currentEvent: EventPayload | null
private status: StatusEnum

constructor() {
this._currentEvent = null
this.status = StatusEnum.INIT
}

public init() {
Expand All @@ -24,5 +35,17 @@ export class EventStore implements IEventStore {

public setEvent(event: EventPayload) {
this._currentEvent = event

if (this.status === StatusEnum.INIT) {
this.status = StatusEnum.RUNNING
}
}

public getStatus() {
return this.status
}

public done() {
this.status = StatusEnum.DONE
}
}

0 comments on commit 8360ddf

Please sign in to comment.