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

Unified Diff: logdog/client/annotee/link_generator.go

Issue 2719183003: Annotee: Export Coordinator link generator. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | logdog/client/annotee/processor.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/client/annotee/link_generator.go
diff --git a/logdog/client/annotee/link_generator.go b/logdog/client/annotee/link_generator.go
new file mode 100644
index 0000000000000000000000000000000000000000..93ab0c1f27e4b011a9a641333ca63d73a2f4cc9e
--- /dev/null
+++ b/logdog/client/annotee/link_generator.go
@@ -0,0 +1,41 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package annotee
+
+import (
+ "github.com/luci/luci-go/logdog/common/types"
+ "github.com/luci/luci-go/logdog/common/viewer"
+ "github.com/luci/luci-go/luci_config/common/cfgtypes"
+)
+
+// LinkGenerator generates links for a given log stream.
+type LinkGenerator interface {
+ // GetLink returns a link for the specified aggregate streams.
nodir 2017/02/28 00:22:38 typo
dnj 2017/02/28 00:24:43 Acknowledged.
+ //
+ // If no link could be generated, GetLink may return an empty string.
+ GetLink(name ...types.StreamName) string
+}
+
+// CoordinatorLinkGenerator is a LinkGenerator implementation
+type CoordinatorLinkGenerator struct {
+ Host string
+ Project cfgtypes.ProjectName
+ Prefix types.StreamName
+}
+
+// CanGenerateLinks returns true if g is sufficiently configured to generate
+// LogDog Coordinator links.
+func (g *CoordinatorLinkGenerator) CanGenerateLinks() bool {
+ return (g.Host != "" && g.Prefix != "")
+}
+
+// GetLink implements LinkGenerator.
+func (g *CoordinatorLinkGenerator) GetLink(names ...types.StreamName) string {
+ paths := make([]types.StreamPath, len(names))
+ for i, name := range names {
+ paths[i] = g.Prefix.AsPathPrefix(name)
+ }
+ return viewer.GetURL(g.Host, g.Project, paths...)
+}
« no previous file with comments | « no previous file | logdog/client/annotee/processor.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698