Chromium Code Reviews| 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} |
| +} |