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

Side by Side Diff: luci_config/server/cfgclient/backend/erroring/erroring.go

Issue 2576343002: server/config: Add an erroring config wrapper. (Closed)
Patch Set: Rebased. Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 erroring implements config.Backend that simply returns an error.
6 //
7 // May be handy as a placeholder in case some more useful implementation is not
8 // available.
9 package erroring
10
11 import (
12 "net/url"
13
14 "github.com/luci/luci-go/luci_config/server/cfgclient/backend"
15
16 "golang.org/x/net/context"
17 )
18
19 // New produces backend.B instance that returns the given error for all calls.
20 //
21 // Panics if given err is nil.
22 func New(err error) backend.B {
23 if err == nil {
24 panic("the error must not be nil")
25 }
26 return erroringImpl{err}
27 }
28
29 type erroringImpl struct {
30 err error
31 }
32
33 func (e erroringImpl) ServiceURL(context.Context) url.URL {
34 return url.URL{
35 Scheme: "error",
36 }
37 }
38
39 func (e erroringImpl) Get(c context.Context, configSet, path string, p backend.P arams) (*backend.Item, error) {
40 return nil, e.err
41 }
42
43 func (e erroringImpl) GetAll(c context.Context, t backend.GetAllTarget, path str ing, p backend.Params) (
44 []*backend.Item, error) {
45
46 return nil, e.err
47 }
48
49 func (e erroringImpl) ConfigSetURL(c context.Context, configSet string, p backen d.Params) (url.URL, error) {
50 return url.URL{}, e.err
51 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698