Add some forgotten files
Peter Bourgon
8 years ago
14 | 14 | // pureAdd implements Add with no dependencies. |
15 | 15 | func pureAdd(_ context.Context, a, b int64) int64 { return a + b } |
16 | 16 | |
17 | // proxyAdd implements Add by invoking a remote Add service. | |
18 | func proxyAdd(e endpoint.Endpoint) Add { | |
17 | // proxyAdd returns an implementation of Add that invokes a remote Add | |
18 | // service. | |
19 | func proxyAdd(e endpoint.Endpoint, logger log.Logger) Add { | |
19 | 20 | return func(ctx context.Context, a, b int64) int64 { |
20 | 21 | resp, err := e(ctx, &addRequest{a, b}) |
21 | 22 | if err != nil { |
22 | log.DefaultLogger.Log("err", err) | |
23 | logger.Log("err", err) | |
23 | 24 | return 0 |
24 | 25 | } |
25 | 26 | addResp, ok := resp.(*addResponse) |
26 | 27 | if !ok { |
27 | log.DefaultLogger.Log("err", endpoint.ErrBadCast) | |
28 | logger.Log("err", endpoint.ErrBadCast) | |
28 | 29 | return 0 |
29 | 30 | } |
30 | 31 | return addResp.V |
97 | 97 | e = httptransport.NewClient(*proxyHTTPAddr, codec, makeResponse, httptransport.ClientBefore(zipkin.ToRequest(zipkinSpanFunc))) |
98 | 98 | e = zipkin.AnnotateClient(zipkinSpanFunc, zipkinCollector)(e) |
99 | 99 | |
100 | a = proxyAdd(e) | |
100 | a = proxyAdd(e, logger) | |
101 | 101 | } |
102 | 102 | a = logging(logger)(a) |
103 | 103 |
5 | 5 | "strconv" |
6 | 6 | "time" |
7 | 7 | |
8 | "github.com/go-kit/kit/log" | |
9 | 8 | "github.com/go-kit/kit/tracing/zipkin/_thrift/gen-go/zipkincore" |
10 | 9 | ) |
11 | 10 | |
46 | 45 | func makeEndpoint(hostport, serviceName string) *zipkincore.Endpoint { |
47 | 46 | host, port, err := net.SplitHostPort(hostport) |
48 | 47 | if err != nil { |
49 | log.DefaultLogger.Log("hostport", hostport, "err", err) | |
48 | Log.Log("hostport", hostport, "err", err) | |
50 | 49 | return nil |
51 | 50 | } |
52 | 51 | addrs, err := net.LookupIP(host) |
53 | 52 | if err != nil { |
54 | log.DefaultLogger.Log("host", host, "err", err) | |
53 | Log.Log("host", host, "err", err) | |
55 | 54 | return nil |
56 | 55 | } |
57 | 56 | if len(addrs) <= 0 { |
58 | log.DefaultLogger.Log("host", host, "err", "no IPs") | |
57 | Log.Log("host", host, "err", "no IPs") | |
59 | 58 | return nil |
60 | 59 | } |
61 | 60 | portInt, err := strconv.ParseInt(port, 10, 16) |
62 | 61 | if err != nil { |
63 | log.DefaultLogger.Log("port", port, "err", err) | |
62 | Log.Log("port", port, "err", err) | |
64 | 63 | return nil |
65 | 64 | } |
66 | 65 | endpoint := zipkincore.NewEndpoint() |