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

Side by Side Diff: appengine/cmd/dm/distributor/test_registry.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 unified diff | Download patch
OLDNEW
(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 "fmt"
9
10 "github.com/luci/luci-go/appengine/tumble"
11 "github.com/luci/luci-go/common/api/dm/service/v1"
12 "golang.org/x/net/context"
13 )
14
15 type testRegistry struct {
16 finishExecutionImpl FinishExecutionFn
17 data map[string]D
18 }
19
20 var _ Registry = (*testRegistry)(nil)
21
22 // NewTestingRegistry returns a new testing registry.
23 //
24 // The mocks dictionary maps from cfgName to a mock implementation of the
25 // distributor.
26 func NewTestingRegistry(mocks map[string]D, fFn FinishExecutionFn) Registry {
27 return &testRegistry{fFn, mocks}
28 }
29
30 func (t *testRegistry) FinishExecution(c context.Context, eid *dm.Execution_ID, rslt *TaskResult) ([]tumble.Mutation, error) {
31 return t.finishExecutionImpl(c, eid, rslt)
32 }
33
34 func (t *testRegistry) MakeDistributor(_ context.Context, cfgName string) (D, st ring, error) {
35 ret, ok := t.data[cfgName]
36 if !ok {
37 return nil, "", fmt.Errorf("unknown distributor configuration: % q", cfgName)
38 }
39 return ret, "testing", nil
40 }
OLDNEW
« no previous file with comments | « appengine/cmd/dm/distributor/task_description.go ('k') | appengine/cmd/dm/distributor/tq_handler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698