| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package coordinatorTest |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 "sort" |
| 10 |
| 11 "github.com/golang/protobuf/proto" |
| 12 tq "github.com/luci/gae/service/taskqueue" |
| 13 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" |
| 14 "github.com/luci/luci-go/common/logdog/types" |
| 15 ) |
| 16 |
| 17 // GetArchiveTaskStreams returns the set of archive tasks in the supplied task |
| 18 // queue. |
| 19 // |
| 20 // If one of the tasks in the specified queue is not an ArchiveTask, an error |
| 21 // will be returned. |
| 22 func GetArchiveTaskStreams(ti tq.Interface, qname string) ([]string, error) { |
| 23 queueContents := ti.Testable().GetScheduledTasks()[qname] |
| 24 |
| 25 archiveTasks := make([]string, 0, len(queueContents)) |
| 26 for _, task := range queueContents { |
| 27 var at logdog.ArchiveTask |
| 28 if err := proto.Unmarshal(task.Payload, &at); err != nil { |
| 29 return nil, fmt.Errorf("failed to unmarshal payload: %v"
, err) |
| 30 } |
| 31 |
| 32 _, name := types.StreamPath(at.Path).Split() |
| 33 archiveTasks = append(archiveTasks, string(name)) |
| 34 } |
| 35 |
| 36 sort.Strings(archiveTasks) |
| 37 return archiveTasks, nil |
| 38 } |
| OLD | NEW |