Update code to handle the JobUpdate to SocketIOJobUpdate rename

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2022-05-19 15:18:06 +02:00
parent b928896066
commit cc62cab1d6
9 changed files with 15 additions and 15 deletions

View File

@ -81,7 +81,7 @@ var _ TaskStateMachine = (*task_state_machine.StateMachine)(nil)
type ChangeBroadcaster interface { type ChangeBroadcaster interface {
// BroadcastNewJob sends a 'new job' notification to all SocketIO clients. // BroadcastNewJob sends a 'new job' notification to all SocketIO clients.
BroadcastNewJob(jobUpdate api.JobUpdate) BroadcastNewJob(jobUpdate api.SocketIOJobUpdate)
// Note that there is no BroadcastNewTask. The 'new job' broadcast is sent // Note that there is no BroadcastNewTask. The 'new job' broadcast is sent
// after the job's tasks have been created, and thus there is no need for a // after the job's tasks have been created, and thus there is no need for a

View File

@ -61,7 +61,7 @@ func TestSubmitJob(t *testing.T) {
mf.persistence.EXPECT().FetchJob(gomock.Any(), queuedJob.JobID).Return(&dbJob, nil) mf.persistence.EXPECT().FetchJob(gomock.Any(), queuedJob.JobID).Return(&dbJob, nil)
// Expect the new job to be broadcast. // Expect the new job to be broadcast.
jobUpdate := api.JobUpdate{ jobUpdate := api.SocketIOJobUpdate{
Id: dbJob.UUID, Id: dbJob.UUID,
Name: &dbJob.Name, Name: &dbJob.Name,
Priority: dbJob.Priority, Priority: dbJob.Priority,

View File

@ -253,7 +253,7 @@ func (m *MockChangeBroadcaster) EXPECT() *MockChangeBroadcasterMockRecorder {
} }
// BroadcastNewJob mocks base method. // BroadcastNewJob mocks base method.
func (m *MockChangeBroadcaster) BroadcastNewJob(arg0 api.JobUpdate) { func (m *MockChangeBroadcaster) BroadcastNewJob(arg0 api.SocketIOJobUpdate) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
m.ctrl.Call(m, "BroadcastNewJob", arg0) m.ctrl.Call(m, "BroadcastNewJob", arg0)
} }

View File

@ -51,7 +51,7 @@ var _ PersistenceService = (*persistence.DB)(nil)
type ChangeBroadcaster interface { type ChangeBroadcaster interface {
// BroadcastJobUpdate sends the job update to SocketIO clients. // BroadcastJobUpdate sends the job update to SocketIO clients.
BroadcastJobUpdate(jobUpdate api.JobUpdate) BroadcastJobUpdate(jobUpdate api.SocketIOJobUpdate)
// BroadcastTaskUpdate sends the task update to SocketIO clients. // BroadcastTaskUpdate sends the task update to SocketIO clients.
BroadcastTaskUpdate(jobUpdate api.SocketIOTaskUpdate) BroadcastTaskUpdate(jobUpdate api.SocketIOTaskUpdate)

View File

@ -396,7 +396,7 @@ func (m *StateMachineMocks) expectBroadcastJobChange(
job *persistence.Job, job *persistence.Job,
fromStatus, toStatus api.JobStatus, fromStatus, toStatus api.JobStatus,
) *gomock.Call { ) *gomock.Call {
expectUpdate := api.JobUpdate{ expectUpdate := api.SocketIOJobUpdate{
Id: job.UUID, Id: job.UUID,
Name: &job.Name, Name: &job.Name,
PreviousStatus: &fromStatus, PreviousStatus: &fromStatus,
@ -411,7 +411,7 @@ func (m *StateMachineMocks) expectBroadcastJobChangeWithTaskRefresh(
job *persistence.Job, job *persistence.Job,
fromStatus, toStatus api.JobStatus, fromStatus, toStatus api.JobStatus,
) *gomock.Call { ) *gomock.Call {
expectUpdate := api.JobUpdate{ expectUpdate := api.SocketIOJobUpdate{
Id: job.UUID, Id: job.UUID,
Name: &job.Name, Name: &job.Name,
PreviousStatus: &fromStatus, PreviousStatus: &fromStatus,

View File

@ -8,12 +8,12 @@ import (
"git.blender.org/flamenco/pkg/api" "git.blender.org/flamenco/pkg/api"
) )
// NewJobUpdate returns a partial JobUpdate struct for the given job. // NewJobUpdate returns a partial SocketIOJobUpdate struct for the given job.
// It only fills in the fields that represent the current state of the job. For // It only fills in the fields that represent the current state of the job. For
// example, it omits `PreviousStatus`. The ommitted fields can be filled in by // example, it omits `PreviousStatus`. The ommitted fields can be filled in by
// the caller. // the caller.
func NewJobUpdate(job *persistence.Job) api.JobUpdate { func NewJobUpdate(job *persistence.Job) api.SocketIOJobUpdate {
jobUpdate := api.JobUpdate{ jobUpdate := api.SocketIOJobUpdate{
Id: job.UUID, Id: job.UUID,
Name: &job.Name, Name: &job.Name,
Updated: job.UpdatedAt, Updated: job.UpdatedAt,
@ -43,7 +43,7 @@ func NewTaskUpdate(task *persistence.Task) api.SocketIOTaskUpdate {
} }
// BroadcastJobUpdate sends the job update to clients. // BroadcastJobUpdate sends the job update to clients.
func (b *BiDirComms) BroadcastJobUpdate(jobUpdate api.JobUpdate) { func (b *BiDirComms) BroadcastJobUpdate(jobUpdate api.SocketIOJobUpdate) {
log.Debug().Interface("jobUpdate", jobUpdate).Msg("socketIO: broadcasting job update") log.Debug().Interface("jobUpdate", jobUpdate).Msg("socketIO: broadcasting job update")
b.BroadcastTo(SocketIORoomJobs, SIOEventJobUpdate, jobUpdate) b.BroadcastTo(SocketIORoomJobs, SIOEventJobUpdate, jobUpdate)
} }
@ -51,7 +51,7 @@ func (b *BiDirComms) BroadcastJobUpdate(jobUpdate api.JobUpdate) {
// BroadcastNewJob sends a "new job" notification to clients. // BroadcastNewJob sends a "new job" notification to clients.
// This function should be called when the job has been completely created, so // This function should be called when the job has been completely created, so
// including its tasks. // including its tasks.
func (b *BiDirComms) BroadcastNewJob(jobUpdate api.JobUpdate) { func (b *BiDirComms) BroadcastNewJob(jobUpdate api.SocketIOJobUpdate) {
if jobUpdate.PreviousStatus != nil { if jobUpdate.PreviousStatus != nil {
log.Warn().Interface("jobUpdate", jobUpdate).Msg("socketIO: new jobs should not have a previous state") log.Warn().Interface("jobUpdate", jobUpdate).Msg("socketIO: new jobs should not have a previous state")
jobUpdate.PreviousStatus = nil jobUpdate.PreviousStatus = nil
@ -72,7 +72,7 @@ func (b *BiDirComms) BroadcastTaskUpdate(taskUpdate api.SocketIOTaskUpdate) {
// this room will receive info scoped to this job, so for example updates to all // this room will receive info scoped to this job, so for example updates to all
// tasks of this job. // tasks of this job.
// //
// Note that `api.JobUpdate`s themselves are sent to all SocketIO clients, and // Note that `api.SocketIOJobUpdate`s themselves are sent to all SocketIO clients, and
// not to this room. // not to this room.
func roomForJob(jobUUID string) SocketIORoomName { func roomForJob(jobUUID string) SocketIORoomName {
return SocketIORoomName("job-" + jobUUID) return SocketIORoomName("job-" + jobUUID)

View File

@ -23,7 +23,7 @@ const (
// Predefined SocketIO event types. // Predefined SocketIO event types.
SIOEventChatMessageRcv SocketIOEventType = "/chat" // clients send chat messages here SIOEventChatMessageRcv SocketIOEventType = "/chat" // clients send chat messages here
SIOEventChatMessageSend SocketIOEventType = "/message" // chat messages are broadcasted here SIOEventChatMessageSend SocketIOEventType = "/message" // chat messages are broadcasted here
SIOEventJobUpdate SocketIOEventType = "/jobs" // sends api.JobUpdate SIOEventJobUpdate SocketIOEventType = "/jobs" // sends api.SocketIOJobUpdate
SIOEventTaskUpdate SocketIOEventType = "/task" // sends api.SocketIOTaskUpdate SIOEventTaskUpdate SocketIOEventType = "/task" // sends api.SocketIOTaskUpdate
SIOEventSubscription SocketIOEventType = "/subscription" // clients send api.SocketIOSubscription SIOEventSubscription SocketIOEventType = "/subscription" // clients send api.SocketIOSubscription
) )

View File

@ -42,7 +42,7 @@ export default {
const vueComponent = this; const vueComponent = this;
const options = { const options = {
// See pkg/api/flamenco-manager.yaml, schemas Job and JobUpdate. // See pkg/api/flamenco-manager.yaml, schemas Job and SocketIOJobUpdate.
columns: [ columns: [
// Useful for debugging when there are many similar jobs: // Useful for debugging when there are many similar jobs:
// { title: "ID", field: "id", headerSort: false, formatter: (cell) => cell.getData().id.substr(0, 8), }, // { title: "ID", field: "id", headerSort: false, formatter: (cell) => cell.getData().id.substr(0, 8), },

View File

@ -106,7 +106,7 @@ export default {
this.socket.on("/jobs", (jobUpdate) => { this.socket.on("/jobs", (jobUpdate) => {
// Convert to API object, in order to have the same parsing of data as // Convert to API object, in order to have the same parsing of data as
// when we'd do an API call. // when we'd do an API call.
const apiJobUpdate = API.JobUpdate.constructFromObject(jobUpdate) const apiJobUpdate = API.SocketIOJobUpdate.constructFromObject(jobUpdate)
this.$emit("jobUpdate", apiJobUpdate); this.$emit("jobUpdate", apiJobUpdate);
}); });