Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1582)

Unified Diff: appengine/logdog/coordinator/coordinatorTest/archival.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Minor fixes, works in dev now. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/logdog/coordinator/coordinatorTest/archival.go
diff --git a/appengine/logdog/coordinator/coordinatorTest/archival.go b/appengine/logdog/coordinator/coordinatorTest/archival.go
new file mode 100644
index 0000000000000000000000000000000000000000..040933097db908672c81c5cbc91b33d63c1b4c9e
--- /dev/null
+++ b/appengine/logdog/coordinator/coordinatorTest/archival.go
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package coordinatorTest
+
+import (
+ "fmt"
+ "sort"
+
+ "github.com/golang/protobuf/proto"
+ tq "github.com/luci/gae/service/taskqueue"
+ "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1"
+ "github.com/luci/luci-go/common/logdog/types"
+)
+
+// GetArchiveTaskStreams returns the set of archive tasks in the supplied task
+// queue.
+//
+// If one of the tasks in the specified queue is not an ArchiveTask, an error
+// will be returned.
+func GetArchiveTaskStreams(ti tq.Interface, qname string) ([]string, error) {
+ queueContents := ti.Testable().GetScheduledTasks()[qname]
+
+ archiveTasks := make([]string, 0, len(queueContents))
+ for _, task := range queueContents {
+ var at logdog.ArchiveTask
+ if err := proto.Unmarshal(task.Payload, &at); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal payload: %v", err)
+ }
+
+ _, name := types.StreamPath(at.Path).Split()
+ archiveTasks = append(archiveTasks, string(name))
+ }
+
+ sort.Strings(archiveTasks)
+ return archiveTasks, nil
+}

Powered by Google App Engine
This is Rietveld 408576698