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

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: self review 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
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..947c52345b8aa076df757c4e60269fc62adc3fde
--- /dev/null
+++ b/appengine/cmd/dm/distributor/config.go
@@ -0,0 +1,39 @@
+// 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 distributor
+
+import (
+ "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 string
+
+ // 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, "")
+}

Powered by Google App Engine
This is Rietveld 408576698