From 4a2920475703ebd23281dfacdd609d347a9d3285 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Sun, 25 Dec 2016 16:00:43 +0100 Subject: [PATCH 1/6] Use stdlib context instead of golang.org/x/net/context --- auth/jwt/README.md | 2 +- auth/jwt/middleware.go | 2 +- auth/jwt/middleware_test.go | 3 +-- auth/jwt/transport.go | 2 +- auth/jwt/transport_test.go | 3 +-- circuitbreaker/gobreaker.go | 3 ++- circuitbreaker/handy_breaker.go | 2 +- circuitbreaker/hystrix.go | 3 ++- circuitbreaker/util_test.go | 3 +-- endpoint/endpoint.go | 2 +- endpoint/endpoint_example_test.go | 3 +-- examples/addsvc/cmd/addcli/main.go | 2 +- examples/addsvc/cmd/addsvc/main.go | 2 +- examples/addsvc/endpoints.go | 2 +- examples/addsvc/pb/addsvc.pb.go | 2 +- examples/addsvc/service.go | 2 +- examples/addsvc/transport_grpc.go | 2 +- examples/addsvc/transport_http.go | 2 +- examples/addsvc/transport_thrift.go | 2 +- examples/apigateway/main.go | 2 +- examples/profilesvc/cmd/profilesvc/main.go | 3 +-- examples/profilesvc/endpoints.go | 3 +-- examples/profilesvc/middlewares.go | 3 +-- examples/profilesvc/service.go | 3 +-- examples/profilesvc/transport.go | 3 +-- examples/shipping/booking/endpoint.go | 3 +-- examples/shipping/booking/transport.go | 2 +- examples/shipping/handling/endpoint.go | 3 +-- examples/shipping/handling/transport.go | 2 +- examples/shipping/inspection/inspection.go | 4 +++- examples/shipping/location/location.go | 4 +++- examples/shipping/main.go | 2 +- examples/shipping/routing/proxying.go | 3 +-- examples/shipping/routing/routing.go | 4 +++- examples/shipping/tracking/endpoint.go | 2 +- examples/shipping/tracking/transport.go | 2 +- examples/stringsvc1/main.go | 3 +-- examples/stringsvc2/main.go | 2 +- examples/stringsvc2/transport.go | 3 +-- examples/stringsvc3/main.go | 2 +- examples/stringsvc3/proxying.go | 2 +- examples/stringsvc3/transport.go | 3 +-- ratelimit/token_bucket.go | 2 +- ratelimit/token_bucket_test.go | 2 +- sd/consul/client.go | 4 +++- sd/consul/client_test.go | 2 +- sd/consul/subscriber_test.go | 2 +- sd/etcd/client.go | 2 +- sd/etcd/client_test.go | 2 +- sd/etcd/example_test.go | 3 +-- sd/etcd/integration_test.go | 3 +-- sd/lb/random_test.go | 2 +- sd/lb/retry.go | 3 +-- sd/lb/retry_test.go | 3 +-- sd/lb/round_robin_test.go | 3 +-- sd/zk/util_test.go | 2 +- tracing/opentracing/endpoint.go | 3 ++- tracing/opentracing/endpoint_test.go | 2 +- tracing/opentracing/grpc.go | 2 +- tracing/opentracing/grpc_test.go | 2 +- tracing/opentracing/http.go | 2 +- tracing/opentracing/http_test.go | 2 +- transport/grpc/client.go | 2 +- transport/grpc/encode_decode.go | 4 +++- transport/grpc/request_response_funcs.go | 2 +- transport/grpc/server.go | 3 ++- transport/http/client.go | 2 +- transport/http/client_test.go | 3 +-- transport/http/encode_decode.go | 3 +-- transport/http/example_test.go | 3 +-- transport/http/request_response_funcs.go | 3 +-- transport/http/request_response_funcs_test.go | 3 +-- transport/http/server.go | 3 +-- transport/http/server_test.go | 3 +-- transport/httprp/server.go | 3 +-- transport/httprp/server_test.go | 3 +-- 76 files changed, 90 insertions(+), 105 deletions(-) diff --git a/auth/jwt/README.md b/auth/jwt/README.md index bec4f674d..d435e0f1e 100644 --- a/auth/jwt/README.md +++ b/auth/jwt/README.md @@ -92,7 +92,7 @@ Example of use in a server: ```go import ( - "golang.org/x/net/context" + "context" "github.com/go-kit/kit/auth/jwt" "github.com/go-kit/kit/log" diff --git a/auth/jwt/middleware.go b/auth/jwt/middleware.go index fceff6e3b..b5ccf0b4c 100644 --- a/auth/jwt/middleware.go +++ b/auth/jwt/middleware.go @@ -1,10 +1,10 @@ package jwt import ( + "context" "errors" jwt "github.com/dgrijalva/jwt-go" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/auth/jwt/middleware_test.go b/auth/jwt/middleware_test.go index 46bae6881..99b943c59 100644 --- a/auth/jwt/middleware_test.go +++ b/auth/jwt/middleware_test.go @@ -1,11 +1,10 @@ package jwt import ( + "context" "testing" jwt "github.com/dgrijalva/jwt-go" - - "golang.org/x/net/context" ) var ( diff --git a/auth/jwt/transport.go b/auth/jwt/transport.go index f4ab4d812..6d02f7dc5 100644 --- a/auth/jwt/transport.go +++ b/auth/jwt/transport.go @@ -1,11 +1,11 @@ package jwt import ( + "context" "fmt" stdhttp "net/http" "strings" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" "github.com/go-kit/kit/transport/grpc" diff --git a/auth/jwt/transport_test.go b/auth/jwt/transport_test.go index 829d87f47..8b8922a6a 100644 --- a/auth/jwt/transport_test.go +++ b/auth/jwt/transport_test.go @@ -1,13 +1,12 @@ package jwt import ( + "context" "fmt" "net/http" "testing" "google.golang.org/grpc/metadata" - - "golang.org/x/net/context" ) func TestToHTTPContext(t *testing.T) { diff --git a/circuitbreaker/gobreaker.go b/circuitbreaker/gobreaker.go index b00de9515..cf06304f4 100644 --- a/circuitbreaker/gobreaker.go +++ b/circuitbreaker/gobreaker.go @@ -1,8 +1,9 @@ package circuitbreaker import ( + "context" + "github.com/sony/gobreaker" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/circuitbreaker/handy_breaker.go b/circuitbreaker/handy_breaker.go index 5875d4fda..a5b60be2e 100644 --- a/circuitbreaker/handy_breaker.go +++ b/circuitbreaker/handy_breaker.go @@ -1,10 +1,10 @@ package circuitbreaker import ( + "context" "time" "github.com/streadway/handy/breaker" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/circuitbreaker/hystrix.go b/circuitbreaker/hystrix.go index 5e7b144dc..3c59ec41e 100644 --- a/circuitbreaker/hystrix.go +++ b/circuitbreaker/hystrix.go @@ -1,8 +1,9 @@ package circuitbreaker import ( + "context" + "github.com/afex/hystrix-go/hystrix" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/circuitbreaker/util_test.go b/circuitbreaker/util_test.go index 8d5d7b1fa..25123805a 100644 --- a/circuitbreaker/util_test.go +++ b/circuitbreaker/util_test.go @@ -1,6 +1,7 @@ package circuitbreaker_test import ( + "context" "errors" "fmt" "path/filepath" @@ -8,8 +9,6 @@ import ( "testing" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" ) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 786a28852..1b64f50ed 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -1,7 +1,7 @@ package endpoint import ( - "golang.org/x/net/context" + "context" ) // Endpoint is the fundamental building block of servers and clients. diff --git a/endpoint/endpoint_example_test.go b/endpoint/endpoint_example_test.go index dd25ec79d..e95062305 100644 --- a/endpoint/endpoint_example_test.go +++ b/endpoint/endpoint_example_test.go @@ -1,10 +1,9 @@ package endpoint_test import ( + "context" "fmt" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" ) diff --git a/examples/addsvc/cmd/addcli/main.go b/examples/addsvc/cmd/addcli/main.go index a2d647868..712bccf04 100644 --- a/examples/addsvc/cmd/addcli/main.go +++ b/examples/addsvc/cmd/addcli/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "fmt" "os" @@ -12,7 +13,6 @@ import ( "github.com/lightstep/lightstep-tracer-go" stdopentracing "github.com/opentracing/opentracing-go" zipkin "github.com/openzipkin/zipkin-go-opentracing" - "golang.org/x/net/context" "google.golang.org/grpc" "sourcegraph.com/sourcegraph/appdash" appdashot "sourcegraph.com/sourcegraph/appdash/opentracing" diff --git a/examples/addsvc/cmd/addsvc/main.go b/examples/addsvc/cmd/addsvc/main.go index b58d64d05..0049fb238 100644 --- a/examples/addsvc/cmd/addsvc/main.go +++ b/examples/addsvc/cmd/addsvc/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "fmt" "net" @@ -16,7 +17,6 @@ import ( stdopentracing "github.com/opentracing/opentracing-go" zipkin "github.com/openzipkin/zipkin-go-opentracing" stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "google.golang.org/grpc" "sourcegraph.com/sourcegraph/appdash" appdashot "sourcegraph.com/sourcegraph/appdash/opentracing" diff --git a/examples/addsvc/endpoints.go b/examples/addsvc/endpoints.go index 6c13d9921..b8d6313a1 100644 --- a/examples/addsvc/endpoints.go +++ b/examples/addsvc/endpoints.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - "golang.org/x/net/context" + "context" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" diff --git a/examples/addsvc/pb/addsvc.pb.go b/examples/addsvc/pb/addsvc.pb.go index a685eef04..9efa23d97 100644 --- a/examples/addsvc/pb/addsvc.pb.go +++ b/examples/addsvc/pb/addsvc.pb.go @@ -21,7 +21,7 @@ import fmt "fmt" import math "math" import ( - context "golang.org/x/net/context" + context "context" grpc "google.golang.org/grpc" ) diff --git a/examples/addsvc/service.go b/examples/addsvc/service.go index 65d72bfc6..505ea24e7 100644 --- a/examples/addsvc/service.go +++ b/examples/addsvc/service.go @@ -7,7 +7,7 @@ import ( "errors" "time" - "golang.org/x/net/context" + "context" "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" diff --git a/examples/addsvc/transport_grpc.go b/examples/addsvc/transport_grpc.go index 6ad30cb3c..3e6f027be 100644 --- a/examples/addsvc/transport_grpc.go +++ b/examples/addsvc/transport_grpc.go @@ -4,8 +4,8 @@ package addsvc // It utilizes the transport/grpc.Server. import ( + "context" stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" "github.com/go-kit/kit/examples/addsvc/pb" "github.com/go-kit/kit/log" diff --git a/examples/addsvc/transport_http.go b/examples/addsvc/transport_http.go index 20c8de32b..50cec8ff7 100644 --- a/examples/addsvc/transport_http.go +++ b/examples/addsvc/transport_http.go @@ -10,8 +10,8 @@ import ( "io/ioutil" "net/http" + "context" stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" "github.com/go-kit/kit/log" "github.com/go-kit/kit/tracing/opentracing" diff --git a/examples/addsvc/transport_thrift.go b/examples/addsvc/transport_thrift.go index 23b1f1c5f..593cd31e5 100644 --- a/examples/addsvc/transport_thrift.go +++ b/examples/addsvc/transport_thrift.go @@ -7,7 +7,7 @@ package addsvc // yet. See https://github.com/go-kit/kit/issues/184. import ( - "golang.org/x/net/context" + "context" "github.com/go-kit/kit/endpoint" thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" diff --git a/examples/apigateway/main.go b/examples/apigateway/main.go index b357e74a5..610418c76 100644 --- a/examples/apigateway/main.go +++ b/examples/apigateway/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "context" "encoding/json" "flag" "fmt" @@ -18,7 +19,6 @@ import ( "github.com/gorilla/mux" "github.com/hashicorp/consul/api" stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/examples/addsvc" diff --git a/examples/profilesvc/cmd/profilesvc/main.go b/examples/profilesvc/cmd/profilesvc/main.go index a340e69da..0cc9cd0e3 100644 --- a/examples/profilesvc/cmd/profilesvc/main.go +++ b/examples/profilesvc/cmd/profilesvc/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "fmt" "net/http" @@ -8,8 +9,6 @@ import ( "os/signal" "syscall" - "golang.org/x/net/context" - "github.com/go-kit/kit/examples/profilesvc" "github.com/go-kit/kit/log" ) diff --git a/examples/profilesvc/endpoints.go b/examples/profilesvc/endpoints.go index 6dd129f83..3da29b4aa 100644 --- a/examples/profilesvc/endpoints.go +++ b/examples/profilesvc/endpoints.go @@ -1,11 +1,10 @@ package profilesvc import ( + "context" "net/url" "strings" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" httptransport "github.com/go-kit/kit/transport/http" ) diff --git a/examples/profilesvc/middlewares.go b/examples/profilesvc/middlewares.go index 76708e594..1b738f5b5 100644 --- a/examples/profilesvc/middlewares.go +++ b/examples/profilesvc/middlewares.go @@ -1,10 +1,9 @@ package profilesvc import ( + "context" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/log" ) diff --git a/examples/profilesvc/service.go b/examples/profilesvc/service.go index 4ae67561f..cd34ecd9e 100644 --- a/examples/profilesvc/service.go +++ b/examples/profilesvc/service.go @@ -1,10 +1,9 @@ package profilesvc import ( + "context" "errors" "sync" - - "golang.org/x/net/context" ) // Service is a simple CRUD interface for user profiles. diff --git a/examples/profilesvc/transport.go b/examples/profilesvc/transport.go index 5a2284d4c..52aa017a0 100644 --- a/examples/profilesvc/transport.go +++ b/examples/profilesvc/transport.go @@ -4,15 +4,14 @@ package profilesvc import ( "bytes" + "context" "encoding/json" "errors" "io/ioutil" "net/http" - "net/url" "github.com/gorilla/mux" - "golang.org/x/net/context" "github.com/go-kit/kit/log" httptransport "github.com/go-kit/kit/transport/http" diff --git a/examples/shipping/booking/endpoint.go b/examples/shipping/booking/endpoint.go index fe74955b2..3d40d0d93 100644 --- a/examples/shipping/booking/endpoint.go +++ b/examples/shipping/booking/endpoint.go @@ -1,10 +1,9 @@ package booking import ( + "context" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/examples/shipping/cargo" diff --git a/examples/shipping/booking/transport.go b/examples/shipping/booking/transport.go index e4457737b..23f8b8aff 100644 --- a/examples/shipping/booking/transport.go +++ b/examples/shipping/booking/transport.go @@ -1,13 +1,13 @@ package booking import ( + "context" "encoding/json" "errors" "net/http" "time" "github.com/gorilla/mux" - "golang.org/x/net/context" kitlog "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" diff --git a/examples/shipping/handling/endpoint.go b/examples/shipping/handling/endpoint.go index 0ee3f2222..555d08738 100644 --- a/examples/shipping/handling/endpoint.go +++ b/examples/shipping/handling/endpoint.go @@ -1,10 +1,9 @@ package handling import ( + "context" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/examples/shipping/cargo" diff --git a/examples/shipping/handling/transport.go b/examples/shipping/handling/transport.go index e5d2c444a..9c59aa435 100644 --- a/examples/shipping/handling/transport.go +++ b/examples/shipping/handling/transport.go @@ -1,12 +1,12 @@ package handling import ( + "context" "encoding/json" "net/http" "time" "github.com/gorilla/mux" - "golang.org/x/net/context" kitlog "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" diff --git a/examples/shipping/inspection/inspection.go b/examples/shipping/inspection/inspection.go index 91cceb0d6..2ebf73d45 100644 --- a/examples/shipping/inspection/inspection.go +++ b/examples/shipping/inspection/inspection.go @@ -1,7 +1,9 @@ // Package inspection provides means to inspect cargos. package inspection -import "github.com/go-kit/kit/examples/shipping/cargo" +import ( + "github.com/go-kit/kit/examples/shipping/cargo" +) // EventHandler provides means of subscribing to inspection events. type EventHandler interface { diff --git a/examples/shipping/location/location.go b/examples/shipping/location/location.go index 4a9d2f9f3..ee2e5d45c 100644 --- a/examples/shipping/location/location.go +++ b/examples/shipping/location/location.go @@ -1,7 +1,9 @@ // Package location provides the Location aggregate. package location -import "errors" +import ( + "errors" +) // UNLocode is the United Nations location code that uniquely identifies a // particular location. diff --git a/examples/shipping/main.go b/examples/shipping/main.go index 4fbcd94b3..98adfd2d5 100644 --- a/examples/shipping/main.go +++ b/examples/shipping/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "fmt" "net/http" @@ -11,7 +12,6 @@ import ( "time" stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "github.com/go-kit/kit/log" kitprometheus "github.com/go-kit/kit/metrics/prometheus" diff --git a/examples/shipping/routing/proxying.go b/examples/shipping/routing/proxying.go index a53f265b4..0c9150b1e 100644 --- a/examples/shipping/routing/proxying.go +++ b/examples/shipping/routing/proxying.go @@ -1,13 +1,12 @@ package routing import ( + "context" "encoding/json" "net/http" "net/url" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/circuitbreaker" "github.com/go-kit/kit/endpoint" kithttp "github.com/go-kit/kit/transport/http" diff --git a/examples/shipping/routing/routing.go b/examples/shipping/routing/routing.go index dac3690bb..50496f2b8 100644 --- a/examples/shipping/routing/routing.go +++ b/examples/shipping/routing/routing.go @@ -3,7 +3,9 @@ // bounded context. package routing -import "github.com/go-kit/kit/examples/shipping/cargo" +import ( + "github.com/go-kit/kit/examples/shipping/cargo" +) // Service provides access to an external routing service. type Service interface { diff --git a/examples/shipping/tracking/endpoint.go b/examples/shipping/tracking/endpoint.go index ea105d591..ddb13172f 100644 --- a/examples/shipping/tracking/endpoint.go +++ b/examples/shipping/tracking/endpoint.go @@ -1,7 +1,7 @@ package tracking import ( - "golang.org/x/net/context" + "context" "github.com/go-kit/kit/endpoint" ) diff --git a/examples/shipping/tracking/transport.go b/examples/shipping/tracking/transport.go index 3cdb9b1d4..497aa36ea 100644 --- a/examples/shipping/tracking/transport.go +++ b/examples/shipping/tracking/transport.go @@ -1,12 +1,12 @@ package tracking import ( + "context" "encoding/json" "errors" "net/http" "github.com/gorilla/mux" - "golang.org/x/net/context" kitlog "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" diff --git a/examples/stringsvc1/main.go b/examples/stringsvc1/main.go index 876eb9cb0..007b884bd 100644 --- a/examples/stringsvc1/main.go +++ b/examples/stringsvc1/main.go @@ -1,14 +1,13 @@ package main import ( + "context" "encoding/json" "errors" "log" "net/http" "strings" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" httptransport "github.com/go-kit/kit/transport/http" ) diff --git a/examples/stringsvc2/main.go b/examples/stringsvc2/main.go index bdcc17d85..9958fab66 100644 --- a/examples/stringsvc2/main.go +++ b/examples/stringsvc2/main.go @@ -1,11 +1,11 @@ package main import ( + "context" "net/http" "os" stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "github.com/go-kit/kit/log" kitprometheus "github.com/go-kit/kit/metrics/prometheus" diff --git a/examples/stringsvc2/transport.go b/examples/stringsvc2/transport.go index a70ad3f11..297b3ffeb 100644 --- a/examples/stringsvc2/transport.go +++ b/examples/stringsvc2/transport.go @@ -1,11 +1,10 @@ package main import ( + "context" "encoding/json" "net/http" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" ) diff --git a/examples/stringsvc3/main.go b/examples/stringsvc3/main.go index b9b4e89a1..4b869b259 100644 --- a/examples/stringsvc3/main.go +++ b/examples/stringsvc3/main.go @@ -1,12 +1,12 @@ package main import ( + "context" "flag" "net/http" "os" stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "github.com/go-kit/kit/log" kitprometheus "github.com/go-kit/kit/metrics/prometheus" diff --git a/examples/stringsvc3/proxying.go b/examples/stringsvc3/proxying.go index 33bc1563e..d7c837f87 100644 --- a/examples/stringsvc3/proxying.go +++ b/examples/stringsvc3/proxying.go @@ -1,6 +1,7 @@ package main import ( + "context" "errors" "fmt" "net/url" @@ -9,7 +10,6 @@ import ( jujuratelimit "github.com/juju/ratelimit" "github.com/sony/gobreaker" - "golang.org/x/net/context" "github.com/go-kit/kit/circuitbreaker" "github.com/go-kit/kit/endpoint" diff --git a/examples/stringsvc3/transport.go b/examples/stringsvc3/transport.go index c6341c19a..c17a055c7 100644 --- a/examples/stringsvc3/transport.go +++ b/examples/stringsvc3/transport.go @@ -2,12 +2,11 @@ package main import ( "bytes" + "context" "encoding/json" "io/ioutil" "net/http" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" ) diff --git a/ratelimit/token_bucket.go b/ratelimit/token_bucket.go index 48a4f601f..f6df9d00e 100644 --- a/ratelimit/token_bucket.go +++ b/ratelimit/token_bucket.go @@ -1,11 +1,11 @@ package ratelimit import ( + "context" "errors" "time" "github.com/juju/ratelimit" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/ratelimit/token_bucket_test.go b/ratelimit/token_bucket_test.go index 6f815dec3..54225b80e 100644 --- a/ratelimit/token_bucket_test.go +++ b/ratelimit/token_bucket_test.go @@ -1,12 +1,12 @@ package ratelimit_test import ( + "context" "math" "testing" "time" jujuratelimit "github.com/juju/ratelimit" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/ratelimit" diff --git a/sd/consul/client.go b/sd/consul/client.go index 4d88ce3df..fd109aa5b 100644 --- a/sd/consul/client.go +++ b/sd/consul/client.go @@ -1,6 +1,8 @@ package consul -import consul "github.com/hashicorp/consul/api" +import ( + consul "github.com/hashicorp/consul/api" +) // Client is a wrapper around the Consul API. type Client interface { diff --git a/sd/consul/client_test.go b/sd/consul/client_test.go index cf02aea1d..bc988b3e2 100644 --- a/sd/consul/client_test.go +++ b/sd/consul/client_test.go @@ -1,13 +1,13 @@ package consul import ( + "context" "errors" "io" "reflect" "testing" stdconsul "github.com/hashicorp/consul/api" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/sd/consul/subscriber_test.go b/sd/consul/subscriber_test.go index f581216eb..da00458f8 100644 --- a/sd/consul/subscriber_test.go +++ b/sd/consul/subscriber_test.go @@ -1,10 +1,10 @@ package consul import ( + "context" "testing" consul "github.com/hashicorp/consul/api" - "golang.org/x/net/context" "github.com/go-kit/kit/log" ) diff --git a/sd/etcd/client.go b/sd/etcd/client.go index eda7d5eda..d6899a3e8 100644 --- a/sd/etcd/client.go +++ b/sd/etcd/client.go @@ -1,6 +1,7 @@ package etcd import ( + "context" "crypto/tls" "crypto/x509" "errors" @@ -10,7 +11,6 @@ import ( "time" etcd "github.com/coreos/etcd/client" - "golang.org/x/net/context" ) var ( diff --git a/sd/etcd/client_test.go b/sd/etcd/client_test.go index 96dd2e910..2b010b435 100644 --- a/sd/etcd/client_test.go +++ b/sd/etcd/client_test.go @@ -1,13 +1,13 @@ package etcd import ( + "context" "errors" "reflect" "testing" "time" etcd "github.com/coreos/etcd/client" - "golang.org/x/net/context" ) func TestNewClient(t *testing.T) { diff --git a/sd/etcd/example_test.go b/sd/etcd/example_test.go index 795164c1d..11b0a5669 100644 --- a/sd/etcd/example_test.go +++ b/sd/etcd/example_test.go @@ -1,11 +1,10 @@ package etcd import ( + "context" "io" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" "github.com/go-kit/kit/sd/lb" diff --git a/sd/etcd/integration_test.go b/sd/etcd/integration_test.go index e0fb3a7ad..4c7191268 100644 --- a/sd/etcd/integration_test.go +++ b/sd/etcd/integration_test.go @@ -3,13 +3,12 @@ package etcd import ( + "context" "io" "os" "testing" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" ) diff --git a/sd/lb/random_test.go b/sd/lb/random_test.go index c9b011789..8cee33e1e 100644 --- a/sd/lb/random_test.go +++ b/sd/lb/random_test.go @@ -1,12 +1,12 @@ package lb import ( + "context" "math" "testing" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/sd" - "golang.org/x/net/context" ) func TestRandom(t *testing.T) { diff --git a/sd/lb/retry.go b/sd/lb/retry.go index 1214a6698..c551b360a 100644 --- a/sd/lb/retry.go +++ b/sd/lb/retry.go @@ -1,12 +1,11 @@ package lb import ( + "context" "fmt" "strings" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" ) diff --git a/sd/lb/retry_test.go b/sd/lb/retry_test.go index 238198a68..7cdd89264 100644 --- a/sd/lb/retry_test.go +++ b/sd/lb/retry_test.go @@ -1,12 +1,11 @@ package lb_test import ( + "context" "errors" "testing" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/sd" "github.com/go-kit/kit/sd/lb" diff --git a/sd/lb/round_robin_test.go b/sd/lb/round_robin_test.go index 64a8baa45..b10ddbf75 100644 --- a/sd/lb/round_robin_test.go +++ b/sd/lb/round_robin_test.go @@ -1,14 +1,13 @@ package lb import ( + "context" "reflect" "sync" "sync/atomic" "testing" "time" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/sd" ) diff --git a/sd/zk/util_test.go b/sd/zk/util_test.go index c77fde9db..91ba966d6 100644 --- a/sd/zk/util_test.go +++ b/sd/zk/util_test.go @@ -1,6 +1,7 @@ package zk import ( + "context" "errors" "fmt" "io" @@ -8,7 +9,6 @@ import ( "time" "github.com/samuel/go-zookeeper/zk" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" diff --git a/tracing/opentracing/endpoint.go b/tracing/opentracing/endpoint.go index 51934fa69..0482e9c0d 100644 --- a/tracing/opentracing/endpoint.go +++ b/tracing/opentracing/endpoint.go @@ -1,9 +1,10 @@ package opentracing import ( + "context" + "github.com/opentracing/opentracing-go" otext "github.com/opentracing/opentracing-go/ext" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" ) diff --git a/tracing/opentracing/endpoint_test.go b/tracing/opentracing/endpoint_test.go index f1cc520bb..a26f7bab6 100644 --- a/tracing/opentracing/endpoint_test.go +++ b/tracing/opentracing/endpoint_test.go @@ -1,11 +1,11 @@ package opentracing_test import ( + "context" "testing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" - "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" kitot "github.com/go-kit/kit/tracing/opentracing" diff --git a/tracing/opentracing/grpc.go b/tracing/opentracing/grpc.go index e0bdbc986..56eb143f5 100644 --- a/tracing/opentracing/grpc.go +++ b/tracing/opentracing/grpc.go @@ -1,12 +1,12 @@ package opentracing import ( + "context" "encoding/base64" "strings" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" "github.com/go-kit/kit/log" diff --git a/tracing/opentracing/grpc_test.go b/tracing/opentracing/grpc_test.go index 657817a96..96a834fd8 100644 --- a/tracing/opentracing/grpc_test.go +++ b/tracing/opentracing/grpc_test.go @@ -1,11 +1,11 @@ package opentracing_test import ( + "context" "testing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" "github.com/go-kit/kit/log" diff --git a/tracing/opentracing/http.go b/tracing/opentracing/http.go index 9c608f6e7..78286cd7c 100644 --- a/tracing/opentracing/http.go +++ b/tracing/opentracing/http.go @@ -1,13 +1,13 @@ package opentracing import ( + "context" "net" "net/http" "strconv" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" - "golang.org/x/net/context" "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" diff --git a/tracing/opentracing/http_test.go b/tracing/opentracing/http_test.go index 359cba4ca..61c1c1623 100644 --- a/tracing/opentracing/http_test.go +++ b/tracing/opentracing/http_test.go @@ -1,6 +1,7 @@ package opentracing_test import ( + "context" "net/http" "reflect" "testing" @@ -8,7 +9,6 @@ import ( "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/mocktracer" - "golang.org/x/net/context" "github.com/go-kit/kit/log" kitot "github.com/go-kit/kit/tracing/opentracing" diff --git a/transport/grpc/client.go b/transport/grpc/client.go index ae4672a2b..7ab43c647 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -1,11 +1,11 @@ package grpc import ( + "context" "fmt" "reflect" "strings" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" diff --git a/transport/grpc/encode_decode.go b/transport/grpc/encode_decode.go index fb16c9999..4c1761b65 100644 --- a/transport/grpc/encode_decode.go +++ b/transport/grpc/encode_decode.go @@ -1,6 +1,8 @@ package grpc -import "golang.org/x/net/context" +import ( + "context" +) // DecodeRequestFunc extracts a user-domain request object from a gRPC request. // It's designed to be used in gRPC servers, for server-side endpoints. One diff --git a/transport/grpc/request_response_funcs.go b/transport/grpc/request_response_funcs.go index aceb84f9e..aa88ca65e 100644 --- a/transport/grpc/request_response_funcs.go +++ b/transport/grpc/request_response_funcs.go @@ -1,10 +1,10 @@ package grpc import ( + "context" "encoding/base64" "strings" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" ) diff --git a/transport/grpc/server.go b/transport/grpc/server.go index 637623b9e..17c893562 100644 --- a/transport/grpc/server.go +++ b/transport/grpc/server.go @@ -1,7 +1,8 @@ package grpc import ( - "golang.org/x/net/context" + "context" + "google.golang.org/grpc/metadata" "github.com/go-kit/kit/endpoint" diff --git a/transport/http/client.go b/transport/http/client.go index 737147a5c..b53368700 100644 --- a/transport/http/client.go +++ b/transport/http/client.go @@ -2,12 +2,12 @@ package http import ( "bytes" + "context" "encoding/json" "io/ioutil" "net/http" "net/url" - "golang.org/x/net/context" "golang.org/x/net/context/ctxhttp" "github.com/go-kit/kit/endpoint" diff --git a/transport/http/client_test.go b/transport/http/client_test.go index 048399d48..ad366d1ac 100644 --- a/transport/http/client_test.go +++ b/transport/http/client_test.go @@ -1,6 +1,7 @@ package http_test import ( + "context" "io" "io/ioutil" "net/http" @@ -9,8 +10,6 @@ import ( "testing" "time" - "golang.org/x/net/context" - httptransport "github.com/go-kit/kit/transport/http" ) diff --git a/transport/http/encode_decode.go b/transport/http/encode_decode.go index 8b8f6d7d1..3076e4d2a 100644 --- a/transport/http/encode_decode.go +++ b/transport/http/encode_decode.go @@ -1,9 +1,8 @@ package http import ( + "context" "net/http" - - "golang.org/x/net/context" ) // DecodeRequestFunc extracts a user-domain request object from an HTTP diff --git a/transport/http/example_test.go b/transport/http/example_test.go index 311b6c4c8..14153610c 100644 --- a/transport/http/example_test.go +++ b/transport/http/example_test.go @@ -1,11 +1,10 @@ package http import ( + "context" "fmt" "net/http" "net/http/httptest" - - "golang.org/x/net/context" ) func ExamplePopulateRequestContext() { diff --git a/transport/http/request_response_funcs.go b/transport/http/request_response_funcs.go index 88c6e7b66..7622375e3 100644 --- a/transport/http/request_response_funcs.go +++ b/transport/http/request_response_funcs.go @@ -1,9 +1,8 @@ package http import ( + "context" "net/http" - - "golang.org/x/net/context" ) // RequestFunc may take information from an HTTP request and put it into a diff --git a/transport/http/request_response_funcs_test.go b/transport/http/request_response_funcs_test.go index 4fb87d065..e003fc94f 100644 --- a/transport/http/request_response_funcs_test.go +++ b/transport/http/request_response_funcs_test.go @@ -1,11 +1,10 @@ package http_test import ( + "context" "net/http/httptest" "testing" - "golang.org/x/net/context" - httptransport "github.com/go-kit/kit/transport/http" ) diff --git a/transport/http/server.go b/transport/http/server.go index 4ae519bf0..524132816 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -1,11 +1,10 @@ package http import ( + "context" "encoding/json" "net/http" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" ) diff --git a/transport/http/server_test.go b/transport/http/server_test.go index faf20c6f6..8c112da2f 100644 --- a/transport/http/server_test.go +++ b/transport/http/server_test.go @@ -1,6 +1,7 @@ package http_test import ( + "context" "errors" "io/ioutil" "net/http" @@ -8,8 +9,6 @@ import ( "strings" "testing" - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" httptransport "github.com/go-kit/kit/transport/http" ) diff --git a/transport/httprp/server.go b/transport/httprp/server.go index 15b9cd5ca..25776ed8d 100644 --- a/transport/httprp/server.go +++ b/transport/httprp/server.go @@ -1,11 +1,10 @@ package httprp import ( + "context" "net/http" "net/http/httputil" "net/url" - - "golang.org/x/net/context" ) // RequestFunc may take information from an HTTP request and put it into a diff --git a/transport/httprp/server_test.go b/transport/httprp/server_test.go index ec7fb10a9..45fd429d1 100644 --- a/transport/httprp/server_test.go +++ b/transport/httprp/server_test.go @@ -1,14 +1,13 @@ package httprp_test import ( + "context" "io/ioutil" "net/http" "net/http/httptest" "net/url" "testing" - "golang.org/x/net/context" - httptransport "github.com/go-kit/kit/transport/httprp" ) From 1f862d6b30ac55caf194a298be9d0d8b8bd2f7ea Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Sun, 25 Dec 2016 16:14:03 +0100 Subject: [PATCH 2/6] Fixes for various CI errors --- .travis.yml | 5 ++--- circle.yml | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76adc0699..2c10ac22d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: go script: go test -race -v ./... go: - - 1.5.4 - - 1.6.3 - - 1.7.1 + - 1.7.4 + - 1.8beta2 - tip diff --git a/circle.yml b/circle.yml index a15a0a4f8..32aa3e31f 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,8 @@ machine: pre: - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0 + - sudo rm -rf /usr/local/go + - curl -sSL https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz | sudo tar xz -C /usr/local services: - docker @@ -14,6 +16,7 @@ test: pre: - mkdir -p /home/ubuntu/.go_workspace/src/github.com/go-kit - mv /home/ubuntu/kit /home/ubuntu/.go_workspace/src/github.com/go-kit + - ln -s /home/ubuntu/.go_workspace/src/github.com/go-kit/kit /home/ubuntu/kit - go get github.com/go-kit/kit/... override: - go test -v -race -tags integration github.com/go-kit/kit/...: From 1cb1fb5dcf4ec313ccf302d94ae7b3ebced77465 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Sun, 25 Dec 2016 16:57:09 +0100 Subject: [PATCH 3/6] transport/grpc: use the old context; not good enough --- examples/addsvc/pb/addsvc.pb.go | 2 +- transport/grpc/client.go | 2 +- transport/grpc/encode_decode.go | 2 +- transport/grpc/request_response_funcs.go | 2 +- transport/grpc/server.go | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/addsvc/pb/addsvc.pb.go b/examples/addsvc/pb/addsvc.pb.go index 9efa23d97..a685eef04 100644 --- a/examples/addsvc/pb/addsvc.pb.go +++ b/examples/addsvc/pb/addsvc.pb.go @@ -21,7 +21,7 @@ import fmt "fmt" import math "math" import ( - context "context" + context "golang.org/x/net/context" grpc "google.golang.org/grpc" ) diff --git a/transport/grpc/client.go b/transport/grpc/client.go index 7ab43c647..ae4672a2b 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -1,11 +1,11 @@ package grpc import ( - "context" "fmt" "reflect" "strings" + "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" diff --git a/transport/grpc/encode_decode.go b/transport/grpc/encode_decode.go index 4c1761b65..951768b4f 100644 --- a/transport/grpc/encode_decode.go +++ b/transport/grpc/encode_decode.go @@ -1,7 +1,7 @@ package grpc import ( - "context" + "golang.org/x/net/context" ) // DecodeRequestFunc extracts a user-domain request object from a gRPC request. diff --git a/transport/grpc/request_response_funcs.go b/transport/grpc/request_response_funcs.go index aa88ca65e..aceb84f9e 100644 --- a/transport/grpc/request_response_funcs.go +++ b/transport/grpc/request_response_funcs.go @@ -1,10 +1,10 @@ package grpc import ( - "context" "encoding/base64" "strings" + "golang.org/x/net/context" "google.golang.org/grpc/metadata" ) diff --git a/transport/grpc/server.go b/transport/grpc/server.go index 17c893562..637623b9e 100644 --- a/transport/grpc/server.go +++ b/transport/grpc/server.go @@ -1,8 +1,7 @@ package grpc import ( - "context" - + "golang.org/x/net/context" "google.golang.org/grpc/metadata" "github.com/go-kit/kit/endpoint" From cf9a3720e16010f7853ea2cb791c8aa4b2054ed7 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Mon, 16 Jan 2017 18:08:40 +0100 Subject: [PATCH 4/6] examples/addsvc: fix import grouping --- examples/addsvc/endpoints.go | 3 +-- examples/addsvc/service.go | 3 +-- examples/addsvc/transport_grpc.go | 1 + examples/addsvc/transport_http.go | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/addsvc/endpoints.go b/examples/addsvc/endpoints.go index b8d6313a1..1da33e41c 100644 --- a/examples/addsvc/endpoints.go +++ b/examples/addsvc/endpoints.go @@ -6,11 +6,10 @@ package addsvc // formats. It also includes endpoint middlewares. import ( + "context" "fmt" "time" - "context" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" diff --git a/examples/addsvc/service.go b/examples/addsvc/service.go index 505ea24e7..971590cc0 100644 --- a/examples/addsvc/service.go +++ b/examples/addsvc/service.go @@ -4,11 +4,10 @@ package addsvc // implementation. It also includes service middlewares. import ( + "context" "errors" "time" - "context" - "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" ) diff --git a/examples/addsvc/transport_grpc.go b/examples/addsvc/transport_grpc.go index 3e6f027be..2ed54b7c6 100644 --- a/examples/addsvc/transport_grpc.go +++ b/examples/addsvc/transport_grpc.go @@ -5,6 +5,7 @@ package addsvc import ( "context" + stdopentracing "github.com/opentracing/opentracing-go" "github.com/go-kit/kit/examples/addsvc/pb" diff --git a/examples/addsvc/transport_http.go b/examples/addsvc/transport_http.go index 50cec8ff7..2452fdad7 100644 --- a/examples/addsvc/transport_http.go +++ b/examples/addsvc/transport_http.go @@ -5,12 +5,12 @@ package addsvc import ( "bytes" + "context" "encoding/json" "errors" "io/ioutil" "net/http" - "context" stdopentracing "github.com/opentracing/opentracing-go" "github.com/go-kit/kit/log" From 45cd825d1c145669fb0521a98ea49c6d522ab172 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Mon, 16 Jan 2017 18:21:21 +0100 Subject: [PATCH 5/6] transport/grpc, examples/addsvc: adapt context --- examples/addsvc/transport_grpc.go | 5 +++-- transport/grpc/client.go | 2 +- transport/grpc/encode_decode.go | 18 +++++++++--------- transport/grpc/request_response_funcs.go | 2 +- transport/grpc/server.go | 10 ++++++---- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/examples/addsvc/transport_grpc.go b/examples/addsvc/transport_grpc.go index 2ed54b7c6..21e60bc4f 100644 --- a/examples/addsvc/transport_grpc.go +++ b/examples/addsvc/transport_grpc.go @@ -7,6 +7,7 @@ import ( "context" stdopentracing "github.com/opentracing/opentracing-go" + oldcontext "golang.org/x/net/context" "github.com/go-kit/kit/examples/addsvc/pb" "github.com/go-kit/kit/log" @@ -42,7 +43,7 @@ type grpcServer struct { concat grpctransport.Handler } -func (s *grpcServer) Sum(ctx context.Context, req *pb.SumRequest) (*pb.SumReply, error) { +func (s *grpcServer) Sum(ctx oldcontext.Context, req *pb.SumRequest) (*pb.SumReply, error) { _, rep, err := s.sum.ServeGRPC(ctx, req) if err != nil { return nil, err @@ -50,7 +51,7 @@ func (s *grpcServer) Sum(ctx context.Context, req *pb.SumRequest) (*pb.SumReply, return rep.(*pb.SumReply), nil } -func (s *grpcServer) Concat(ctx context.Context, req *pb.ConcatRequest) (*pb.ConcatReply, error) { +func (s *grpcServer) Concat(ctx oldcontext.Context, req *pb.ConcatRequest) (*pb.ConcatReply, error) { _, rep, err := s.concat.ServeGRPC(ctx, req) if err != nil { return nil, err diff --git a/transport/grpc/client.go b/transport/grpc/client.go index ae4672a2b..7ab43c647 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -1,11 +1,11 @@ package grpc import ( + "context" "fmt" "reflect" "strings" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" diff --git a/transport/grpc/encode_decode.go b/transport/grpc/encode_decode.go index 951768b4f..f2900ed6d 100644 --- a/transport/grpc/encode_decode.go +++ b/transport/grpc/encode_decode.go @@ -1,25 +1,25 @@ package grpc import ( - "golang.org/x/net/context" + "context" ) // DecodeRequestFunc extracts a user-domain request object from a gRPC request. // It's designed to be used in gRPC servers, for server-side endpoints. One -// straightforward DecodeRequestFunc could be something that -// decodes from the gRPC request message to the concrete request type. +// straightforward DecodeRequestFunc could be something that decodes from the +// gRPC request message to the concrete request type. type DecodeRequestFunc func(context.Context, interface{}) (request interface{}, err error) // EncodeRequestFunc encodes the passed request object into the gRPC request -// object. It's designed to be used in gRPC clients, for client-side -// endpoints. One straightforward EncodeRequestFunc could something that -// encodes the object directly to the gRPC request message. +// object. It's designed to be used in gRPC clients, for client-side endpoints. +// One straightforward EncodeRequestFunc could something that encodes the object +// directly to the gRPC request message. type EncodeRequestFunc func(context.Context, interface{}) (request interface{}, err error) // EncodeResponseFunc encodes the passed response object to the gRPC response -// message. It's designed to be used in gRPC servers, for server-side -// endpoints. One straightforward EncodeResponseFunc could be something that -// encodes the object directly to the gRPC response message. +// message. It's designed to be used in gRPC servers, for server-side endpoints. +// One straightforward EncodeResponseFunc could be something that encodes the +// object directly to the gRPC response message. type EncodeResponseFunc func(context.Context, interface{}) (response interface{}, err error) // DecodeResponseFunc extracts a user-domain response object from a gRPC diff --git a/transport/grpc/request_response_funcs.go b/transport/grpc/request_response_funcs.go index aceb84f9e..aa88ca65e 100644 --- a/transport/grpc/request_response_funcs.go +++ b/transport/grpc/request_response_funcs.go @@ -1,10 +1,10 @@ package grpc import ( + "context" "encoding/base64" "strings" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" ) diff --git a/transport/grpc/server.go b/transport/grpc/server.go index 637623b9e..84e27cfc9 100644 --- a/transport/grpc/server.go +++ b/transport/grpc/server.go @@ -1,18 +1,20 @@ package grpc import ( - "golang.org/x/net/context" + "context" + + oldcontext "golang.org/x/net/context" "google.golang.org/grpc/metadata" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" ) -// Handler which should be called from the grpc binding of the service +// Handler which should be called from the gRPC binding of the service // implementation. The incoming request parameter, and returned response // parameter, are both gRPC types, not user-domain. type Handler interface { - ServeGRPC(ctx context.Context, request interface{}) (context.Context, interface{}, error) + ServeGRPC(ctx oldcontext.Context, request interface{}) (oldcontext.Context, interface{}, error) } // Server wraps an endpoint and implements grpc.Handler. @@ -73,7 +75,7 @@ func ServerErrorLogger(logger log.Logger) ServerOption { } // ServeGRPC implements the Handler interface. -func (s Server) ServeGRPC(grpcCtx context.Context, req interface{}) (context.Context, interface{}, error) { +func (s Server) ServeGRPC(grpcCtx oldcontext.Context, req interface{}) (oldcontext.Context, interface{}, error) { ctx := s.ctx // Retrieve gRPC metadata. From 1f1ad4dd530fcc8c2552478334ba8763919e7c02 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Mon, 16 Jan 2017 18:28:36 +0100 Subject: [PATCH 6/6] sd/etcd: not ready for stdlib context yet, apparently --- sd/etcd/client_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sd/etcd/client_test.go b/sd/etcd/client_test.go index 2b010b435..4c8bd91c4 100644 --- a/sd/etcd/client_test.go +++ b/sd/etcd/client_test.go @@ -1,12 +1,13 @@ package etcd import ( - "context" "errors" "reflect" "testing" "time" + "golang.org/x/net/context" + etcd "github.com/coreos/etcd/client" )