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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: luci_config/server/cfgclient/backend/erroring/erroring.go
diff --git a/luci_config/server/cfgclient/backend/erroring/erroring.go b/luci_config/server/cfgclient/backend/erroring/erroring.go
new file mode 100644
index 0000000000000000000000000000000000000000..cbd8ef89d124c27dcb4d2355b1708974cc969856
--- /dev/null
+++ b/luci_config/server/cfgclient/backend/erroring/erroring.go
@@ -0,0 +1,51 @@
+// Copyright 2015 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+// Package erroring implements config.Backend that simply returns an error.
+//
+// May be handy as a placeholder in case some more useful implementation is not
+// available.
+package erroring
+
+import (
+ "net/url"
+
+ "github.com/luci/luci-go/luci_config/server/cfgclient/backend"
+
+ "golang.org/x/net/context"
+)
+
+// New produces backend.B instance that returns the given error for all calls.
+//
+// Panics if given err is nil.
+func New(err error) backend.B {
+ if err == nil {
+ panic("the error must not be nil")
+ }
+ return erroringImpl{err}
+}
+
+type erroringImpl struct {
+ err error
+}
+
+func (e erroringImpl) ServiceURL(context.Context) url.URL {
+ return url.URL{
+ Scheme: "error",
+ }
+}
+
+func (e erroringImpl) Get(c context.Context, configSet, path string, p backend.Params) (*backend.Item, error) {
+ return nil, e.err
+}
+
+func (e erroringImpl) GetAll(c context.Context, t backend.GetAllTarget, path string, p backend.Params) (
+ []*backend.Item, error) {
+
+ return nil, e.err
+}
+
+func (e erroringImpl) ConfigSetURL(c context.Context, configSet string, p backend.Params) (url.URL, error) {
+ return url.URL{}, e.err
+}
« 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