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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 eventlog
6
7 import "net/http"
8
9 // A ClientOption is an optional argument to NewClient.
10 type ClientOption interface {
11 apply(*clientSettings)
12 }
13
14 type clientSettings struct {
15 HTTPClient *http.Client
16 }
17
18 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.
19 for _, o := range opts {
20 o.apply(cs)
21 }
22 }
23
24 type httpClientOption struct {
25 *http.Client
26 }
27
28 func (opt httpClientOption) apply(cs *clientSettings) {
29 cs.HTTPClient = opt.Client
30 }
31
32 // WithHTTPClient returns a ClientOption that specifies the HTTP client to use a s the basis of communications.
33 func WithHTTPClient(client *http.Client) ClientOption {
34 return httpClientOption{client}
35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698