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

Unified Diff: common/eventlog/settings.go

Issue 2517503002: luci-go: Basic support for event logging in Go. (Closed)
Patch Set: Created 4 years, 1 month 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
Index: common/eventlog/settings.go
diff --git a/common/eventlog/settings.go b/common/eventlog/settings.go
new file mode 100644
index 0000000000000000000000000000000000000000..1f4c917e3db5d600b583e188499b562da59aad73
--- /dev/null
+++ b/common/eventlog/settings.go
@@ -0,0 +1,35 @@
+// Copyright 2016 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 eventlog
+
+import "net/http"
+
+// A ClientOption is an optional argument to NewClient.
+type ClientOption interface {
+ apply(*clientSettings)
+}
+
+type clientSettings struct {
+ HTTPClient *http.Client
+}
+
+func (cs *clientSettings) Populate(opts []ClientOption) {
djd-OOO-Apr2017 2016/11/21 04:02:24 This seems like overkill today – can we just have
mcgreevy 2016/11/21 04:51:06 Done.
+ for _, o := range opts {
+ o.apply(cs)
+ }
+}
+
+type httpClientOption struct {
+ *http.Client
+}
+
+func (opt httpClientOption) apply(cs *clientSettings) {
+ cs.HTTPClient = opt.Client
+}
+
+// WithHTTPClient returns a ClientOption that specifies the HTTP client to use as the basis of communications.
+func WithHTTPClient(client *http.Client) ClientOption {
+ return httpClientOption{client}
+}

Powered by Google App Engine
This is Rietveld 408576698