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

Unified Diff: logdog/client/butlerlib/streamclient/registry.go

Issue 2456953003: LogDog: Update client/bootstrap to generate URLs. (Closed)
Patch Set: Winders Created 4 years, 2 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 | « logdog/client/butlerlib/streamclient/local.go ('k') | logdog/client/butlerlib/streamclient/stream.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/client/butlerlib/streamclient/registry.go
diff --git a/logdog/client/butlerlib/streamclient/registry.go b/logdog/client/butlerlib/streamclient/registry.go
index 1a2b78c617ebc3a7adbd51161762fa54f1b4887e..0b0ca8d90fbcedee423c3e19533d9adedd9d2d0e 100644
--- a/logdog/client/butlerlib/streamclient/registry.go
+++ b/logdog/client/butlerlib/streamclient/registry.go
@@ -10,11 +10,6 @@ import (
"sync"
)
-var (
- // DefaultRegistry is the default protocol registry.
- DefaultRegistry = &Registry{}
-)
-
// ClientFactory is a generator function that is invoked by the Registry when a
// new Client is requested for its protocol.
type ClientFactory func(string) (Client, error)
@@ -53,22 +48,30 @@ func (r *Registry) Register(name string, f ClientFactory) {
// supplied protocol/address string, returning the generated Client.
func (r *Registry) NewClient(path string) (Client, error) {
parts := strings.SplitN(path, ":", 2)
- params := ""
+ value := ""
if len(parts) == 2 {
- params = parts[1]
+ value = parts[1]
}
r.lock.Lock()
defer r.lock.Unlock()
if f, ok := r.protocols[parts[0]]; ok {
- return f(params)
+ return f(value)
}
return nil, fmt.Errorf("streamclient: no protocol registered for [%s]", parts[0])
}
+// defaultRegistry is the default protocol registry.
+var defaultRegistry = &Registry{}
+
+// GetDefaultRegistry returns the default client registry instance.
+func GetDefaultRegistry() *Registry {
+ return defaultRegistry
+}
+
// registerProtocol registers a protocol with the default (global) protocol
// registry.
func registerProtocol(name string, f ClientFactory) {
- DefaultRegistry.Register(name, f)
+ defaultRegistry.Register(name, f)
}
« no previous file with comments | « logdog/client/butlerlib/streamclient/local.go ('k') | logdog/client/butlerlib/streamclient/stream.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698