Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Commit

Permalink
Rename GetQueueClient and move setting queue client to the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gregarndt committed Mar 21, 2016
1 parent 432fee1 commit e09668b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions runtime/taskcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,24 @@ func (c *TaskContextController) Dispose() error {
return c.logStream.Remove()
}

// GetQueueClient will return a client for the TaskCluster Queue. This client
// is useful for plugins that require interactions with the queue, such as creating
// artifacts.
func (c *TaskContext) GetQueueClient() QueueClient {
c.mu.RLock()
defer c.mu.RUnlock()
return c.queue
}

// CreateQueueClient will create a client for the TaskCluster Queue. This client
// SetQueueClient will set a client for the TaskCluster Queue. This client
// can then be used by others that have access to the task context and require
// interaction with the queue.
func (c *TaskContext) SetQueueClient(client QueueClient) {
func (c *TaskContextController) SetQueueClient(client QueueClient) {
c.mu.Lock()
c.queue = client
c.mu.Unlock()
}

// Queue will return a client for the TaskCluster Queue. This client
// is useful for plugins that require interactions with the queue, such as creating
// artifacts.
func (c *TaskContext) Queue() QueueClient {
c.mu.RLock()
defer c.mu.RUnlock()
return c.queue
}

// Abort sets the status to aborted
func (c *TaskContext) Abort() {
// TODO (garndt): add abort/cancel channels for plugins to listen on
Expand Down
6 changes: 3 additions & 3 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewTaskRun(

queueClient.BaseURL = config.Taskcluster.Queue.URL

ctxt.SetQueueClient(queueClient)
ctxtctl.SetQueueClient(queueClient)

if err != nil {
return nil, err
Expand Down Expand Up @@ -323,7 +323,7 @@ func (t *TaskRun) exceptionStage(taskError error) {
return
}

e := reportException(t.context.GetQueueClient(), t, reason, t.log)
e := reportException(t.context.Queue(), t, reason, t.log)
if e != nil {
t.log.WithField("error", e.Error()).Warn("Could not resolve task as exception.")
}
Expand All @@ -339,7 +339,7 @@ func (t *TaskRun) resolveTask() error {
resolve = reportFailed
}

err := resolve(t.context.GetQueueClient(), t, t.log)
err := resolve(t.context.Queue(), t, t.log)
if err != nil {
return errors.New(err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions worker/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestRunTask(t *testing.T) {
"1",
).Return(&queue.TaskStatusResponse{}, &tcclient.CallSummary{}, nil)

tr.context.SetQueueClient(mockedQueue)
tr.controller.SetQueueClient(mockedQueue)

tr.Run()
mockedQueue.AssertCalled(t, "ReportCompleted", "abc", "1")
Expand All @@ -209,7 +209,7 @@ func TestRunMalformedEnginePayloadTask(t *testing.T) {
&queue.TaskExceptionRequest{Reason: "malformed-payload"},
).Return(&queue.TaskStatusResponse{}, &tcclient.CallSummary{}, nil)

tr.context.SetQueueClient(mockedQueue)
tr.controller.SetQueueClient(mockedQueue)

tr.Run()
mockedQueue.AssertCalled(t, "ReportException", "abc", "1", &queue.TaskExceptionRequest{Reason: "malformed-payload"})
Expand Down

0 comments on commit e09668b

Please sign in to comment.