OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package distributor |
| 6 |
| 7 import ( |
| 8 "net/url" |
| 9 |
| 10 "golang.org/x/net/context" |
| 11 |
| 12 "github.com/golang/protobuf/proto" |
| 13 "github.com/luci/gae/service/taskqueue" |
| 14 ) |
| 15 |
| 16 // Config represents the configuration for a single instance of a given |
| 17 // distributor implementation at a given point in time (e.g. version). |
| 18 type Config struct { |
| 19 // DMBaseURL is the base url for the DM API. This may be used by the |
| 20 // distributor implementation to pass to jobs so that they can call back
into |
| 21 // DM's api. |
| 22 DMBaseURL *url.URL |
| 23 |
| 24 // Name is the name of this distributor configuration. This is always th
e |
| 25 // fully-resolved name of the configuration (i.e. aliases are dereferenc
ed). |
| 26 Name string |
| 27 |
| 28 // Version is the version of the distributor configuration retrieved fro
m |
| 29 // luci-config. |
| 30 Version string |
| 31 |
| 32 // Content is the actual parsed implementation-specific configuration. |
| 33 Content proto.Message |
| 34 } |
| 35 |
| 36 // EnqueueTask allows a Distributor to enqueue a TaskQueue task that will be |
| 37 // handled by the Distributor's HandleTaskQueueTask method. |
| 38 func (cfg *Config) EnqueueTask(c context.Context, tsk *taskqueue.Task) error { |
| 39 tsk.Path = handlerPath(cfg.Name) |
| 40 return taskqueue.Get(c).Add(tsk, "") |
| 41 } |
OLD | NEW |