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

Unified Diff: appengine/cmd/dm/distributor/config.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fix imports and make dummy.go a real file Created 4 years, 6 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 | « appengine/cmd/dm/deps/walk_graph_test.go ('k') | appengine/cmd/dm/distributor/distributor.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/dm/distributor/config.go
diff --git a/appengine/cmd/dm/distributor/config.go b/appengine/cmd/dm/distributor/config.go
new file mode 100644
index 0000000000000000000000000000000000000000..db0f23703e57b3a48d83f42a8ce870eab17e56f5
--- /dev/null
+++ b/appengine/cmd/dm/distributor/config.go
@@ -0,0 +1,41 @@
+// Copyright 2016 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 distributor
+
+import (
+ "net/url"
+
+ "golang.org/x/net/context"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/luci/gae/service/taskqueue"
+)
+
+// Config represents the configuration for a single instance of a given
+// distributor implementation at a given point in time (e.g. version).
+type Config struct {
+ // DMBaseURL is the base url for the DM API. This may be used by the
+ // distributor implementation to pass to jobs so that they can call back into
+ // DM's api.
+ DMBaseURL *url.URL
+
+ // Name is the name of this distributor configuration. This is always the
+ // fully-resolved name of the configuration (i.e. aliases are dereferenced).
+ Name string
+
+ // Version is the version of the distributor configuration retrieved from
+ // luci-config.
+ Version string
+
+ // Content is the actual parsed implementation-specific configuration.
+ Content proto.Message
+}
+
+// EnqueueTask allows a Distributor to enqueue a TaskQueue task that will be
+// handled by the Distributor's HandleTaskQueueTask method.
+func (cfg *Config) EnqueueTask(c context.Context, tsk *taskqueue.Task) error {
+ tsk.Path = handlerPath(cfg.Name)
+ return taskqueue.Get(c).Add(tsk, "")
+}
« no previous file with comments | « appengine/cmd/dm/deps/walk_graph_test.go ('k') | appengine/cmd/dm/distributor/distributor.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698