Merge pull request #421 from go-kit/stdlib-context
Use stdlib context instead of golang.org/x/net/context
Peter Bourgon authored 7 years ago
GitHub committed 7 years ago
2 | 2 | script: go test -race -v ./... |
3 | 3 | |
4 | 4 | go: |
5 | - 1.5.4 | |
6 | - 1.6.3 | |
7 | - 1.7.1 | |
5 | - 1.7.4 | |
6 | - 1.8beta2 | |
8 | 7 | - tip |
91 | 91 | |
92 | 92 | ```go |
93 | 93 | import ( |
94 | "golang.org/x/net/context" | |
94 | "context" | |
95 | 95 | |
96 | 96 | "github.com/go-kit/kit/auth/jwt" |
97 | 97 | "github.com/go-kit/kit/log" |
0 | 0 | package jwt |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | |
5 | 6 | jwt "github.com/dgrijalva/jwt-go" |
6 | "golang.org/x/net/context" | |
7 | 7 | |
8 | 8 | "github.com/go-kit/kit/endpoint" |
9 | 9 | ) |
0 | 0 | package jwt |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "testing" |
4 | 5 | |
5 | 6 | jwt "github.com/dgrijalva/jwt-go" |
6 | ||
7 | "golang.org/x/net/context" | |
8 | 7 | ) |
9 | 8 | |
10 | 9 | var ( |
0 | 0 | package jwt |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | 5 | stdhttp "net/http" |
5 | 6 | "strings" |
6 | 7 | |
7 | "golang.org/x/net/context" | |
8 | 8 | "google.golang.org/grpc/metadata" |
9 | 9 | |
10 | 10 | "github.com/go-kit/kit/transport/grpc" |
0 | 0 | package jwt |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | 5 | "net/http" |
5 | 6 | "testing" |
6 | 7 | |
7 | 8 | "google.golang.org/grpc/metadata" |
8 | ||
9 | "golang.org/x/net/context" | |
10 | 9 | ) |
11 | 10 | |
12 | 11 | func TestToHTTPContext(t *testing.T) { |
0 | 0 | machine: |
1 | 1 | pre: |
2 | 2 | - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0 |
3 | - sudo rm -rf /usr/local/go | |
4 | - curl -sSL https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz | sudo tar xz -C /usr/local | |
3 | 5 | services: |
4 | 6 | - docker |
5 | 7 | |
13 | 15 | pre: |
14 | 16 | - mkdir -p /home/ubuntu/.go_workspace/src/github.com/go-kit |
15 | 17 | - mv /home/ubuntu/kit /home/ubuntu/.go_workspace/src/github.com/go-kit |
18 | - ln -s /home/ubuntu/.go_workspace/src/github.com/go-kit/kit /home/ubuntu/kit | |
16 | 19 | - go get github.com/go-kit/kit/... |
17 | 20 | override: |
18 | 21 | - go test -v -race -tags integration github.com/go-kit/kit/...: |
0 | 0 | package circuitbreaker |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
4 | ||
3 | 5 | "github.com/sony/gobreaker" |
4 | "golang.org/x/net/context" | |
5 | 6 | |
6 | 7 | "github.com/go-kit/kit/endpoint" |
7 | 8 | ) |
0 | 0 | package circuitbreaker |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "time" |
4 | 5 | |
5 | 6 | "github.com/streadway/handy/breaker" |
6 | "golang.org/x/net/context" | |
7 | 7 | |
8 | 8 | "github.com/go-kit/kit/endpoint" |
9 | 9 | ) |
0 | 0 | package circuitbreaker |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
4 | ||
3 | 5 | "github.com/afex/hystrix-go/hystrix" |
4 | "golang.org/x/net/context" | |
5 | 6 | |
6 | 7 | "github.com/go-kit/kit/endpoint" |
7 | 8 | ) |
0 | 0 | package circuitbreaker_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "fmt" |
5 | 6 | "path/filepath" |
6 | 7 | "runtime" |
7 | 8 | "testing" |
8 | 9 | "time" |
9 | ||
10 | "golang.org/x/net/context" | |
11 | 10 | |
12 | 11 | "github.com/go-kit/kit/endpoint" |
13 | 12 | ) |
0 | 0 | package endpoint |
1 | 1 | |
2 | 2 | import ( |
3 | "golang.org/x/net/context" | |
3 | "context" | |
4 | 4 | ) |
5 | 5 | |
6 | 6 | // Endpoint is the fundamental building block of servers and clients. |
0 | 0 | package endpoint_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | |
7 | 6 | "github.com/go-kit/kit/endpoint" |
8 | 7 | ) |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "flag" |
4 | 5 | "fmt" |
5 | 6 | "os" |
11 | 12 | "github.com/lightstep/lightstep-tracer-go" |
12 | 13 | stdopentracing "github.com/opentracing/opentracing-go" |
13 | 14 | zipkin "github.com/openzipkin/zipkin-go-opentracing" |
14 | "golang.org/x/net/context" | |
15 | 15 | "google.golang.org/grpc" |
16 | 16 | "sourcegraph.com/sourcegraph/appdash" |
17 | 17 | appdashot "sourcegraph.com/sourcegraph/appdash/opentracing" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "flag" |
4 | 5 | "fmt" |
5 | 6 | "net" |
15 | 16 | stdopentracing "github.com/opentracing/opentracing-go" |
16 | 17 | zipkin "github.com/openzipkin/zipkin-go-opentracing" |
17 | 18 | stdprometheus "github.com/prometheus/client_golang/prometheus" |
18 | "golang.org/x/net/context" | |
19 | 19 | "google.golang.org/grpc" |
20 | 20 | "sourcegraph.com/sourcegraph/appdash" |
21 | 21 | appdashot "sourcegraph.com/sourcegraph/appdash/opentracing" |
5 | 5 | // formats. It also includes endpoint middlewares. |
6 | 6 | |
7 | 7 | import ( |
8 | "context" | |
8 | 9 | "fmt" |
9 | 10 | "time" |
10 | ||
11 | "golang.org/x/net/context" | |
12 | 11 | |
13 | 12 | "github.com/go-kit/kit/endpoint" |
14 | 13 | "github.com/go-kit/kit/log" |
3 | 3 | // implementation. It also includes service middlewares. |
4 | 4 | |
5 | 5 | import ( |
6 | "context" | |
6 | 7 | "errors" |
7 | 8 | "time" |
8 | ||
9 | "golang.org/x/net/context" | |
10 | 9 | |
11 | 10 | "github.com/go-kit/kit/log" |
12 | 11 | "github.com/go-kit/kit/metrics" |
3 | 3 | // It utilizes the transport/grpc.Server. |
4 | 4 | |
5 | 5 | import ( |
6 | "context" | |
7 | ||
6 | 8 | stdopentracing "github.com/opentracing/opentracing-go" |
7 | "golang.org/x/net/context" | |
9 | oldcontext "golang.org/x/net/context" | |
8 | 10 | |
9 | 11 | "github.com/go-kit/kit/examples/addsvc/pb" |
10 | 12 | "github.com/go-kit/kit/log" |
40 | 42 | concat grpctransport.Handler |
41 | 43 | } |
42 | 44 | |
43 | func (s *grpcServer) Sum(ctx context.Context, req *pb.SumRequest) (*pb.SumReply, error) { | |
45 | func (s *grpcServer) Sum(ctx oldcontext.Context, req *pb.SumRequest) (*pb.SumReply, error) { | |
44 | 46 | _, rep, err := s.sum.ServeGRPC(ctx, req) |
45 | 47 | if err != nil { |
46 | 48 | return nil, err |
48 | 50 | return rep.(*pb.SumReply), nil |
49 | 51 | } |
50 | 52 | |
51 | func (s *grpcServer) Concat(ctx context.Context, req *pb.ConcatRequest) (*pb.ConcatReply, error) { | |
53 | func (s *grpcServer) Concat(ctx oldcontext.Context, req *pb.ConcatRequest) (*pb.ConcatReply, error) { | |
52 | 54 | _, rep, err := s.concat.ServeGRPC(ctx, req) |
53 | 55 | if err != nil { |
54 | 56 | return nil, err |
4 | 4 | |
5 | 5 | import ( |
6 | 6 | "bytes" |
7 | "context" | |
7 | 8 | "encoding/json" |
8 | 9 | "errors" |
9 | 10 | "io/ioutil" |
10 | 11 | "net/http" |
11 | 12 | |
12 | 13 | stdopentracing "github.com/opentracing/opentracing-go" |
13 | "golang.org/x/net/context" | |
14 | 14 | |
15 | 15 | "github.com/go-kit/kit/log" |
16 | 16 | "github.com/go-kit/kit/tracing/opentracing" |
6 | 6 | // yet. See https://github.com/go-kit/kit/issues/184. |
7 | 7 | |
8 | 8 | import ( |
9 | "golang.org/x/net/context" | |
9 | "context" | |
10 | 10 | |
11 | 11 | "github.com/go-kit/kit/endpoint" |
12 | 12 | thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" |
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "bytes" |
4 | "context" | |
4 | 5 | "encoding/json" |
5 | 6 | "flag" |
6 | 7 | "fmt" |
17 | 18 | "github.com/gorilla/mux" |
18 | 19 | "github.com/hashicorp/consul/api" |
19 | 20 | stdopentracing "github.com/opentracing/opentracing-go" |
20 | "golang.org/x/net/context" | |
21 | 21 | |
22 | 22 | "github.com/go-kit/kit/endpoint" |
23 | 23 | "github.com/go-kit/kit/examples/addsvc" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "flag" |
4 | 5 | "fmt" |
5 | 6 | "net/http" |
6 | 7 | "os" |
7 | 8 | "os/signal" |
8 | 9 | "syscall" |
9 | ||
10 | "golang.org/x/net/context" | |
11 | 10 | |
12 | 11 | "github.com/go-kit/kit/examples/profilesvc" |
13 | 12 | "github.com/go-kit/kit/log" |
0 | 0 | package profilesvc |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/url" |
4 | 5 | "strings" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | |
8 | 7 | "github.com/go-kit/kit/endpoint" |
9 | 8 | httptransport "github.com/go-kit/kit/transport/http" |
0 | 0 | package profilesvc |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "time" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | |
7 | 6 | "github.com/go-kit/kit/log" |
8 | 7 | ) |
0 | 0 | package profilesvc |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "sync" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | ) |
8 | 7 | |
9 | 8 | // Service is a simple CRUD interface for user profiles. |
3 | 3 | |
4 | 4 | import ( |
5 | 5 | "bytes" |
6 | "context" | |
6 | 7 | "encoding/json" |
7 | 8 | "errors" |
8 | 9 | "io/ioutil" |
9 | 10 | "net/http" |
10 | ||
11 | 11 | "net/url" |
12 | 12 | |
13 | 13 | "github.com/gorilla/mux" |
14 | "golang.org/x/net/context" | |
15 | 14 | |
16 | 15 | "github.com/go-kit/kit/log" |
17 | 16 | httptransport "github.com/go-kit/kit/transport/http" |
0 | 0 | package booking |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "time" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | |
7 | 6 | "github.com/go-kit/kit/endpoint" |
8 | 7 |
0 | 0 | package booking |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "errors" |
5 | 6 | "net/http" |
6 | 7 | "time" |
7 | 8 | |
8 | 9 | "github.com/gorilla/mux" |
9 | "golang.org/x/net/context" | |
10 | 10 | |
11 | 11 | kitlog "github.com/go-kit/kit/log" |
12 | 12 | kithttp "github.com/go-kit/kit/transport/http" |
0 | 0 | package handling |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "time" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | |
7 | 6 | "github.com/go-kit/kit/endpoint" |
8 | 7 |
0 | 0 | package handling |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "net/http" |
5 | 6 | "time" |
6 | 7 | |
7 | 8 | "github.com/gorilla/mux" |
8 | "golang.org/x/net/context" | |
9 | 9 | |
10 | 10 | kitlog "github.com/go-kit/kit/log" |
11 | 11 | kithttp "github.com/go-kit/kit/transport/http" |
0 | 0 | // Package inspection provides means to inspect cargos. |
1 | 1 | package inspection |
2 | 2 | |
3 | import "github.com/go-kit/kit/examples/shipping/cargo" | |
3 | import ( | |
4 | "github.com/go-kit/kit/examples/shipping/cargo" | |
5 | ) | |
4 | 6 | |
5 | 7 | // EventHandler provides means of subscribing to inspection events. |
6 | 8 | type EventHandler interface { |
0 | 0 | // Package location provides the Location aggregate. |
1 | 1 | package location |
2 | 2 | |
3 | import "errors" | |
3 | import ( | |
4 | "errors" | |
5 | ) | |
4 | 6 | |
5 | 7 | // UNLocode is the United Nations location code that uniquely identifies a |
6 | 8 | // particular location. |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "flag" |
4 | 5 | "fmt" |
5 | 6 | "net/http" |
10 | 11 | "time" |
11 | 12 | |
12 | 13 | stdprometheus "github.com/prometheus/client_golang/prometheus" |
13 | "golang.org/x/net/context" | |
14 | 14 | |
15 | 15 | "github.com/go-kit/kit/log" |
16 | 16 | kitprometheus "github.com/go-kit/kit/metrics/prometheus" |
0 | 0 | package routing |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "net/http" |
5 | 6 | "net/url" |
6 | 7 | "time" |
7 | ||
8 | "golang.org/x/net/context" | |
9 | 8 | |
10 | 9 | "github.com/go-kit/kit/circuitbreaker" |
11 | 10 | "github.com/go-kit/kit/endpoint" |
2 | 2 | // bounded context. |
3 | 3 | package routing |
4 | 4 | |
5 | import "github.com/go-kit/kit/examples/shipping/cargo" | |
5 | import ( | |
6 | "github.com/go-kit/kit/examples/shipping/cargo" | |
7 | ) | |
6 | 8 | |
7 | 9 | // Service provides access to an external routing service. |
8 | 10 | type Service interface { |
0 | 0 | package tracking |
1 | 1 | |
2 | 2 | import ( |
3 | "golang.org/x/net/context" | |
3 | "context" | |
4 | 4 | |
5 | 5 | "github.com/go-kit/kit/endpoint" |
6 | 6 | ) |
0 | 0 | package tracking |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "errors" |
5 | 6 | "net/http" |
6 | 7 | |
7 | 8 | "github.com/gorilla/mux" |
8 | "golang.org/x/net/context" | |
9 | 9 | |
10 | 10 | kitlog "github.com/go-kit/kit/log" |
11 | 11 | kithttp "github.com/go-kit/kit/transport/http" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "errors" |
5 | 6 | "log" |
6 | 7 | "net/http" |
7 | 8 | "strings" |
8 | ||
9 | "golang.org/x/net/context" | |
10 | 9 | |
11 | 10 | "github.com/go-kit/kit/endpoint" |
12 | 11 | httptransport "github.com/go-kit/kit/transport/http" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/http" |
4 | 5 | "os" |
5 | 6 | |
6 | 7 | stdprometheus "github.com/prometheus/client_golang/prometheus" |
7 | "golang.org/x/net/context" | |
8 | 8 | |
9 | 9 | "github.com/go-kit/kit/log" |
10 | 10 | kitprometheus "github.com/go-kit/kit/metrics/prometheus" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "net/http" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | |
8 | 7 | "github.com/go-kit/kit/endpoint" |
9 | 8 | ) |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "flag" |
4 | 5 | "net/http" |
5 | 6 | "os" |
6 | 7 | |
7 | 8 | stdprometheus "github.com/prometheus/client_golang/prometheus" |
8 | "golang.org/x/net/context" | |
9 | 9 | |
10 | 10 | "github.com/go-kit/kit/log" |
11 | 11 | kitprometheus "github.com/go-kit/kit/metrics/prometheus" |
0 | 0 | package main |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "fmt" |
5 | 6 | "net/url" |
8 | 9 | |
9 | 10 | jujuratelimit "github.com/juju/ratelimit" |
10 | 11 | "github.com/sony/gobreaker" |
11 | "golang.org/x/net/context" | |
12 | 12 | |
13 | 13 | "github.com/go-kit/kit/circuitbreaker" |
14 | 14 | "github.com/go-kit/kit/endpoint" |
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "bytes" |
4 | "context" | |
4 | 5 | "encoding/json" |
5 | 6 | "io/ioutil" |
6 | 7 | "net/http" |
7 | ||
8 | "golang.org/x/net/context" | |
9 | 8 | |
10 | 9 | "github.com/go-kit/kit/endpoint" |
11 | 10 | ) |
0 | 0 | package ratelimit |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "time" |
5 | 6 | |
6 | 7 | "github.com/juju/ratelimit" |
7 | "golang.org/x/net/context" | |
8 | 8 | |
9 | 9 | "github.com/go-kit/kit/endpoint" |
10 | 10 | ) |
0 | 0 | package ratelimit_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "math" |
4 | 5 | "testing" |
5 | 6 | "time" |
6 | 7 | |
7 | 8 | jujuratelimit "github.com/juju/ratelimit" |
8 | "golang.org/x/net/context" | |
9 | 9 | |
10 | 10 | "github.com/go-kit/kit/endpoint" |
11 | 11 | "github.com/go-kit/kit/ratelimit" |
0 | 0 | package consul |
1 | 1 | |
2 | import consul "github.com/hashicorp/consul/api" | |
2 | import ( | |
3 | consul "github.com/hashicorp/consul/api" | |
4 | ) | |
3 | 5 | |
4 | 6 | // Client is a wrapper around the Consul API. |
5 | 7 | type Client interface { |
0 | 0 | package consul |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "io" |
5 | 6 | "reflect" |
6 | 7 | "testing" |
7 | 8 | |
8 | 9 | stdconsul "github.com/hashicorp/consul/api" |
9 | "golang.org/x/net/context" | |
10 | 10 | |
11 | 11 | "github.com/go-kit/kit/endpoint" |
12 | 12 | ) |
0 | 0 | package consul |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "testing" |
4 | 5 | |
5 | 6 | consul "github.com/hashicorp/consul/api" |
6 | "golang.org/x/net/context" | |
7 | 7 | |
8 | 8 | "github.com/go-kit/kit/log" |
9 | 9 | ) |
0 | 0 | package etcd |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "crypto/tls" |
4 | 5 | "crypto/x509" |
5 | 6 | "errors" |
9 | 10 | "time" |
10 | 11 | |
11 | 12 | etcd "github.com/coreos/etcd/client" |
12 | "golang.org/x/net/context" | |
13 | 13 | ) |
14 | 14 | |
15 | 15 | var ( |
5 | 5 | "testing" |
6 | 6 | "time" |
7 | 7 | |
8 | "golang.org/x/net/context" | |
9 | ||
8 | 10 | etcd "github.com/coreos/etcd/client" |
9 | "golang.org/x/net/context" | |
10 | 11 | ) |
11 | 12 | |
12 | 13 | func TestNewClient(t *testing.T) { |
0 | 0 | package etcd |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "io" |
4 | 5 | "time" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | |
8 | 7 | "github.com/go-kit/kit/endpoint" |
9 | 8 | "github.com/go-kit/kit/log" |
2 | 2 | package etcd |
3 | 3 | |
4 | 4 | import ( |
5 | "context" | |
5 | 6 | "io" |
6 | 7 | "os" |
7 | 8 | "testing" |
8 | 9 | "time" |
9 | ||
10 | "golang.org/x/net/context" | |
11 | 10 | |
12 | 11 | "github.com/go-kit/kit/endpoint" |
13 | 12 | "github.com/go-kit/kit/log" |
0 | 0 | package lb |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "math" |
4 | 5 | "testing" |
5 | 6 | |
6 | 7 | "github.com/go-kit/kit/endpoint" |
7 | 8 | "github.com/go-kit/kit/sd" |
8 | "golang.org/x/net/context" | |
9 | 9 | ) |
10 | 10 | |
11 | 11 | func TestRandom(t *testing.T) { |
0 | 0 | package lb |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | 5 | "strings" |
5 | 6 | "time" |
6 | ||
7 | "golang.org/x/net/context" | |
8 | 7 | |
9 | 8 | "github.com/go-kit/kit/endpoint" |
10 | 9 | ) |
0 | 0 | package lb_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "testing" |
5 | 6 | "time" |
6 | ||
7 | "golang.org/x/net/context" | |
8 | 7 | |
9 | 8 | "github.com/go-kit/kit/endpoint" |
10 | 9 | "github.com/go-kit/kit/sd" |
0 | 0 | package lb |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "reflect" |
4 | 5 | "sync" |
5 | 6 | "sync/atomic" |
6 | 7 | "testing" |
7 | 8 | "time" |
8 | ||
9 | "golang.org/x/net/context" | |
10 | 9 | |
11 | 10 | "github.com/go-kit/kit/endpoint" |
12 | 11 | "github.com/go-kit/kit/sd" |
0 | 0 | package zk |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "fmt" |
5 | 6 | "io" |
7 | 8 | "time" |
8 | 9 | |
9 | 10 | "github.com/samuel/go-zookeeper/zk" |
10 | "golang.org/x/net/context" | |
11 | 11 | |
12 | 12 | "github.com/go-kit/kit/endpoint" |
13 | 13 | "github.com/go-kit/kit/log" |
0 | 0 | package opentracing |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
4 | ||
3 | 5 | "github.com/opentracing/opentracing-go" |
4 | 6 | otext "github.com/opentracing/opentracing-go/ext" |
5 | "golang.org/x/net/context" | |
6 | 7 | |
7 | 8 | "github.com/go-kit/kit/endpoint" |
8 | 9 | ) |
0 | 0 | package opentracing_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "testing" |
4 | 5 | |
5 | 6 | "github.com/opentracing/opentracing-go" |
6 | 7 | "github.com/opentracing/opentracing-go/mocktracer" |
7 | "golang.org/x/net/context" | |
8 | 8 | |
9 | 9 | "github.com/go-kit/kit/endpoint" |
10 | 10 | kitot "github.com/go-kit/kit/tracing/opentracing" |
0 | 0 | package opentracing |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/base64" |
4 | 5 | "strings" |
5 | 6 | |
6 | 7 | "github.com/opentracing/opentracing-go" |
7 | 8 | "github.com/opentracing/opentracing-go/ext" |
8 | "golang.org/x/net/context" | |
9 | 9 | "google.golang.org/grpc/metadata" |
10 | 10 | |
11 | 11 | "github.com/go-kit/kit/log" |
0 | 0 | package opentracing_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "testing" |
4 | 5 | |
5 | 6 | "github.com/opentracing/opentracing-go" |
6 | 7 | "github.com/opentracing/opentracing-go/mocktracer" |
7 | "golang.org/x/net/context" | |
8 | 8 | "google.golang.org/grpc/metadata" |
9 | 9 | |
10 | 10 | "github.com/go-kit/kit/log" |
0 | 0 | package opentracing |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net" |
4 | 5 | "net/http" |
5 | 6 | "strconv" |
6 | 7 | |
7 | 8 | "github.com/opentracing/opentracing-go" |
8 | 9 | "github.com/opentracing/opentracing-go/ext" |
9 | "golang.org/x/net/context" | |
10 | 10 | |
11 | 11 | "github.com/go-kit/kit/log" |
12 | 12 | kithttp "github.com/go-kit/kit/transport/http" |
0 | 0 | package opentracing_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/http" |
4 | 5 | "reflect" |
5 | 6 | "testing" |
7 | 8 | "github.com/opentracing/opentracing-go" |
8 | 9 | "github.com/opentracing/opentracing-go/ext" |
9 | 10 | "github.com/opentracing/opentracing-go/mocktracer" |
10 | "golang.org/x/net/context" | |
11 | 11 | |
12 | 12 | "github.com/go-kit/kit/log" |
13 | 13 | kitot "github.com/go-kit/kit/tracing/opentracing" |
0 | 0 | package grpc |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | 5 | "reflect" |
5 | 6 | "strings" |
6 | 7 | |
7 | "golang.org/x/net/context" | |
8 | 8 | "google.golang.org/grpc" |
9 | 9 | "google.golang.org/grpc/metadata" |
10 | 10 |
0 | 0 | package grpc |
1 | 1 | |
2 | import "golang.org/x/net/context" | |
2 | import ( | |
3 | "context" | |
4 | ) | |
3 | 5 | |
4 | 6 | // DecodeRequestFunc extracts a user-domain request object from a gRPC request. |
5 | 7 | // It's designed to be used in gRPC servers, for server-side endpoints. One |
6 | // straightforward DecodeRequestFunc could be something that | |
7 | // decodes from the gRPC request message to the concrete request type. | |
8 | // straightforward DecodeRequestFunc could be something that decodes from the | |
9 | // gRPC request message to the concrete request type. | |
8 | 10 | type DecodeRequestFunc func(context.Context, interface{}) (request interface{}, err error) |
9 | 11 | |
10 | 12 | // EncodeRequestFunc encodes the passed request object into the gRPC request |
11 | // object. It's designed to be used in gRPC clients, for client-side | |
12 | // endpoints. One straightforward EncodeRequestFunc could something that | |
13 | // encodes the object directly to the gRPC request message. | |
13 | // object. It's designed to be used in gRPC clients, for client-side endpoints. | |
14 | // One straightforward EncodeRequestFunc could something that encodes the object | |
15 | // directly to the gRPC request message. | |
14 | 16 | type EncodeRequestFunc func(context.Context, interface{}) (request interface{}, err error) |
15 | 17 | |
16 | 18 | // EncodeResponseFunc encodes the passed response object to the gRPC response |
17 | // message. It's designed to be used in gRPC servers, for server-side | |
18 | // endpoints. One straightforward EncodeResponseFunc could be something that | |
19 | // encodes the object directly to the gRPC response message. | |
19 | // message. It's designed to be used in gRPC servers, for server-side endpoints. | |
20 | // One straightforward EncodeResponseFunc could be something that encodes the | |
21 | // object directly to the gRPC response message. | |
20 | 22 | type EncodeResponseFunc func(context.Context, interface{}) (response interface{}, err error) |
21 | 23 | |
22 | 24 | // DecodeResponseFunc extracts a user-domain response object from a gRPC |
0 | 0 | package grpc |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/base64" |
4 | 5 | "strings" |
5 | 6 | |
6 | "golang.org/x/net/context" | |
7 | 7 | "google.golang.org/grpc/metadata" |
8 | 8 | ) |
9 | 9 |
0 | 0 | package grpc |
1 | 1 | |
2 | 2 | import ( |
3 | "golang.org/x/net/context" | |
3 | "context" | |
4 | ||
5 | oldcontext "golang.org/x/net/context" | |
4 | 6 | "google.golang.org/grpc/metadata" |
5 | 7 | |
6 | 8 | "github.com/go-kit/kit/endpoint" |
7 | 9 | "github.com/go-kit/kit/log" |
8 | 10 | ) |
9 | 11 | |
10 | // Handler which should be called from the grpc binding of the service | |
12 | // Handler which should be called from the gRPC binding of the service | |
11 | 13 | // implementation. The incoming request parameter, and returned response |
12 | 14 | // parameter, are both gRPC types, not user-domain. |
13 | 15 | type Handler interface { |
14 | ServeGRPC(ctx context.Context, request interface{}) (context.Context, interface{}, error) | |
16 | ServeGRPC(ctx oldcontext.Context, request interface{}) (oldcontext.Context, interface{}, error) | |
15 | 17 | } |
16 | 18 | |
17 | 19 | // Server wraps an endpoint and implements grpc.Handler. |
72 | 74 | } |
73 | 75 | |
74 | 76 | // ServeGRPC implements the Handler interface. |
75 | func (s Server) ServeGRPC(grpcCtx context.Context, req interface{}) (context.Context, interface{}, error) { | |
77 | func (s Server) ServeGRPC(grpcCtx oldcontext.Context, req interface{}) (oldcontext.Context, interface{}, error) { | |
76 | 78 | ctx := s.ctx |
77 | 79 | |
78 | 80 | // Retrieve gRPC metadata. |
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "bytes" |
4 | "context" | |
4 | 5 | "encoding/json" |
5 | 6 | "io/ioutil" |
6 | 7 | "net/http" |
7 | 8 | "net/url" |
8 | 9 | |
9 | "golang.org/x/net/context" | |
10 | 10 | "golang.org/x/net/context/ctxhttp" |
11 | 11 | |
12 | 12 | "github.com/go-kit/kit/endpoint" |
0 | 0 | package http_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "io" |
4 | 5 | "io/ioutil" |
5 | 6 | "net/http" |
7 | 8 | "net/url" |
8 | 9 | "testing" |
9 | 10 | "time" |
10 | ||
11 | "golang.org/x/net/context" | |
12 | 11 | |
13 | 12 | httptransport "github.com/go-kit/kit/transport/http" |
14 | 13 | ) |
0 | 0 | package http |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/http" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | ) |
7 | 6 | |
8 | 7 | // DecodeRequestFunc extracts a user-domain request object from an HTTP |
0 | 0 | package http |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "fmt" |
4 | 5 | "net/http" |
5 | 6 | "net/http/httptest" |
6 | ||
7 | "golang.org/x/net/context" | |
8 | 7 | ) |
9 | 8 | |
10 | 9 | func ExamplePopulateRequestContext() { |
0 | 0 | package http |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/http" |
4 | ||
5 | "golang.org/x/net/context" | |
6 | 5 | ) |
7 | 6 | |
8 | 7 | // RequestFunc may take information from an HTTP request and put it into a |
0 | 0 | package http_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "net/http/httptest" |
4 | 5 | "testing" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | |
8 | 7 | httptransport "github.com/go-kit/kit/transport/http" |
9 | 8 | ) |
0 | 0 | package http |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "encoding/json" |
4 | 5 | "net/http" |
5 | ||
6 | "golang.org/x/net/context" | |
7 | 6 | |
8 | 7 | "github.com/go-kit/kit/endpoint" |
9 | 8 | "github.com/go-kit/kit/log" |
0 | 0 | package http_test |
1 | 1 | |
2 | 2 | import ( |
3 | "context" | |
3 | 4 | "errors" |
4 | 5 | "io/ioutil" |
5 | 6 | "net/http" |
6 | 7 | "net/http/httptest" |
7 | 8 | "strings" |
8 | 9 | "testing" |
9 | ||
10 | "golang.org/x/net/context" | |
11 | 10 | |
12 | 11 | "github.com/go-kit/kit/endpoint" |
13 | 12 | httptransport "github.com/go-kit/kit/transport/http" |