OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package service | 5 package service |
6 | 6 |
7 import ( | 7 import ( |
8 "github.com/GoogleCloudPlatform/go-endpoints/endpoints" | 8 "github.com/GoogleCloudPlatform/go-endpoints/endpoints" |
| 9 "github.com/luci/luci-go/appengine/cmd/dm/distributor" |
9 "github.com/luci/luci-go/appengine/ephelper" | 10 "github.com/luci/luci-go/appengine/ephelper" |
10 ) | 11 ) |
11 | 12 |
12 // DungeonMaster is the endpoints server object. | 13 // DungeonMaster is the endpoints server object. |
13 type DungeonMaster struct { | 14 type DungeonMaster struct { |
14 ephelper.ServiceBase | 15 ephelper.ServiceBase |
| 16 |
| 17 distributors distributor.Registry |
15 } | 18 } |
16 | 19 |
17 // MethodInfo provides the method info map that each service | 20 // MethodInfo provides the method info map that each service |
18 // registers itself in. | 21 // registers itself in. |
19 var MethodInfo = ephelper.MethodInfoMap{} | 22 var MethodInfo = ephelper.MethodInfoMap{} |
20 | 23 |
21 // DungeonMasterServiceInfo is the service-wide endpoints configuration. | 24 // DungeonMasterServiceInfo is the service-wide endpoints configuration. |
22 var DungeonMasterServiceInfo = &endpoints.ServiceInfo{ | 25 var DungeonMasterServiceInfo = &endpoints.ServiceInfo{ |
23 Name: "dm", | 26 Name: "dm", |
24 Version: "v1", | 27 Version: "v1", |
25 Description: "DungeonMaster task scheduling service", | 28 Description: "DungeonMaster task scheduling service", |
26 Default: true, | 29 Default: true, |
27 } | 30 } |
28 | 31 |
29 // RegisterEndpointsService is used to integrate with ephelper. | 32 // RegisterEndpointsService is used to integrate with ephelper. |
30 func RegisterEndpointsService(srv *endpoints.Server) error { | 33 func RegisterEndpointsService(srv *endpoints.Server) error { |
31 return ephelper.Register(srv, &DungeonMaster{}, | 34 return ephelper.Register(srv, &DungeonMaster{}, |
32 DungeonMasterServiceInfo, MethodInfo) | 35 DungeonMasterServiceInfo, MethodInfo) |
33 } | 36 } |
| 37 |
| 38 // RegisterEndpointsServiceWithDistributors is used to actually set up the DM |
| 39 // frontends. |
| 40 func RegisterEndpointsServiceWithDistributors(srv *endpoints.Server, reg distrib
utor.Registry) error { |
| 41 return ephelper.Register(srv, &DungeonMaster{distributors: reg}, |
| 42 DungeonMasterServiceInfo, MethodInfo) |
| 43 } |
OLD | NEW |