These are the main public Queue class methods:
export class Queue {
static async create(
name: QueueName,
gitRepo: GitRepo,
commitOptions: CommitOptions
): Promise<Queue>
getNextJob(): NewJobCommittedMessage | NullCommittedMessage
async createJob(payload: string): Promise<CommitInfo>
async markJobAsStarted(payload: string): Promise<CommitInfo>
async markJobAsFinished(payload: string): Promise<CommitInfo>
}
Regarding the getNextJob() we only use the hash and payload in the main module.
nextJob.commitHash()
nextJob.payload()
Regarding the methods to change the job state (create, start, finish), we only need the result commit hash because it's one of the action outputs:
In the second case I think we can continue returning the CommitInfo but in the first case (getNextJob) I think it does not make sense to return a CommittedMessage. I think we could create a new class representing the Job. It can be simple as simple as this:
export class Job {
createdAt: CommitInfo // Commit were it was created
payload: string // Job payload
}
Job payload is not the same as the message payload. YOu can use a different payload for each action (create, start, finish). The job payload is the payload of the message when the job was created. This class does not have any direct state. The current state is the result of all actions/messages stored in the git lol (event sourcing). For example, if we add a method job.isFinished() in the future we can check if the JobFinishedMessage was added to the queue.
These are the main public
Queueclass methods:Regarding the
getNextJob()we only use the hash and payload in themainmodule.Regarding the methods to change the job state (
create,start,finish), we only need the result commit hash because it's one of the action outputs:In the second case I think we can continue returning the
CommitInfobut in the first case (getNextJob) I think it does not make sense to return aCommittedMessage. I think we could create a new class representing theJob. It can be simple as simple as this:Job payload is not the same as the message payload. YOu can use a different payload for each action (
create,start,finish). The job payload is the payload of the message when the job was created. This class does not have any direct state. The current state is the result of all actions/messages stored in the git lol (event sourcing). For example, if we add a methodjob.isFinished()in the future we can check if theJobFinishedMessagewas added to the queue.