| OLD | NEW |
| (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 } |
| OLD | NEW |