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

Unified Diff: common/logdog/types/streamname.go

Issue 1967273002: LogDog: Implement RegisterPrefix RPC. (Closed) Base URL: https://github.com/luci/luci-go@logdog-butler-register-coordinator-endpoint
Patch Set: Updated patchset dependency Created 4 years, 7 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 | « common/api/logdog_coordinator/registration/v1/service.pb.go ('k') | common/logdog/types/streamsecret.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/logdog/types/streamname.go
diff --git a/common/logdog/types/streamname.go b/common/logdog/types/streamname.go
index af95358ed3741685e323cff20af25f68b508ba76..5a9727e26af1f1dc019511f0bba0b156dad737ed 100644
--- a/common/logdog/types/streamname.go
+++ b/common/logdog/types/streamname.go
@@ -164,6 +164,19 @@ func (s StreamName) Concat(o ...StreamName) StreamName {
return StreamName(Construct(parts...))
}
+// AsPathPrefix uses s as the prefix component of a StreamPath and constructs
+// the remainder of the path with the supplied name.
+//
+// If name is empty, the resulting path will end in the path separator. For
+// example, if s is "foo/bar" and name is "", the path will be "foo/bar/+".
+//
+// If both s and name are valid StreamNames, this will construct a valid
+// StreamPath. If s is a valid StreamName and name is empty, this will construct
+// a valid partial StreamPath.
+func (s StreamName) AsPathPrefix(name StreamName) StreamPath {
+ return StreamPath(Construct(string(s), StreamPathSepStr, string(name)))
+}
+
// Validate tests whether the stream name is valid.
func (s StreamName) Validate() error {
if len(s) == 0 {
@@ -238,21 +251,6 @@ func (s StreamName) MarshalJSON() ([]byte, error) {
// separator.
type StreamPath string
-// MakeStreamPath creates a StreamPath by joining prefix and name components.
-func MakeStreamPath(prefix, name []StreamName) StreamPath {
- o := len(prefix)
- sp := make([]string, o+len(name)+1)
- for i, v := range prefix {
- sp[i] = string(v)
- }
- sp[o] = StreamPathSepStr
- for _, v := range name {
- o++
- sp[o] = string(v)
- }
- return StreamPath(Construct(sp...))
-}
-
// Split splits a StreamPath into its prefix and name components.
//
// If there is no divider present (e.g., foo/bar/baz), the result will parse
« no previous file with comments | « common/api/logdog_coordinator/registration/v1/service.pb.go ('k') | common/logdog/types/streamsecret.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698