Moved to google.golang.org/genproto/googleapis/api/annotations
Fixes #52
This commit is contained in:
		
							
								
								
									
										75
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
// Package grpc provides a gRPC client for the add service.
 | 
			
		||||
package grpc
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	jujuratelimit "github.com/juju/ratelimit"
 | 
			
		||||
	stdopentracing "github.com/opentracing/opentracing-go"
 | 
			
		||||
	"github.com/sony/gobreaker"
 | 
			
		||||
	"google.golang.org/grpc"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-kit/kit/circuitbreaker"
 | 
			
		||||
	"github.com/go-kit/kit/endpoint"
 | 
			
		||||
	"github.com/go-kit/kit/examples/addsvc"
 | 
			
		||||
	"github.com/go-kit/kit/examples/addsvc/pb"
 | 
			
		||||
	"github.com/go-kit/kit/log"
 | 
			
		||||
	"github.com/go-kit/kit/ratelimit"
 | 
			
		||||
	"github.com/go-kit/kit/tracing/opentracing"
 | 
			
		||||
	grpctransport "github.com/go-kit/kit/transport/grpc"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// New returns an AddService backed by a gRPC client connection. It is the
 | 
			
		||||
// responsibility of the caller to dial, and later close, the connection.
 | 
			
		||||
func New(conn *grpc.ClientConn, tracer stdopentracing.Tracer, logger log.Logger) addsvc.Service {
 | 
			
		||||
	// We construct a single ratelimiter middleware, to limit the total outgoing
 | 
			
		||||
	// QPS from this client to all methods on the remote instance. We also
 | 
			
		||||
	// construct per-endpoint circuitbreaker middlewares to demonstrate how
 | 
			
		||||
	// that's done, although they could easily be combined into a single breaker
 | 
			
		||||
	// for the entire remote instance, too.
 | 
			
		||||
 | 
			
		||||
	limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
 | 
			
		||||
 | 
			
		||||
	var sumEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		sumEndpoint = grpctransport.NewClient(
 | 
			
		||||
			conn,
 | 
			
		||||
			"Add",
 | 
			
		||||
			"Sum",
 | 
			
		||||
			addsvc.EncodeGRPCSumRequest,
 | 
			
		||||
			addsvc.DecodeGRPCSumResponse,
 | 
			
		||||
			pb.SumReply{},
 | 
			
		||||
			grpctransport.ClientBefore(opentracing.ToGRPCRequest(tracer, logger)),
 | 
			
		||||
		).Endpoint()
 | 
			
		||||
		sumEndpoint = opentracing.TraceClient(tracer, "Sum")(sumEndpoint)
 | 
			
		||||
		sumEndpoint = limiter(sumEndpoint)
 | 
			
		||||
		sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Sum",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(sumEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var concatEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		concatEndpoint = grpctransport.NewClient(
 | 
			
		||||
			conn,
 | 
			
		||||
			"Add",
 | 
			
		||||
			"Concat",
 | 
			
		||||
			addsvc.EncodeGRPCConcatRequest,
 | 
			
		||||
			addsvc.DecodeGRPCConcatResponse,
 | 
			
		||||
			pb.ConcatReply{},
 | 
			
		||||
			grpctransport.ClientBefore(opentracing.ToGRPCRequest(tracer, logger)),
 | 
			
		||||
		).Endpoint()
 | 
			
		||||
		concatEndpoint = opentracing.TraceClient(tracer, "Concat")(concatEndpoint)
 | 
			
		||||
		concatEndpoint = limiter(concatEndpoint)
 | 
			
		||||
		concatEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Concat",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(concatEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return addsvc.Endpoints{
 | 
			
		||||
		SumEndpoint:    sumEndpoint,
 | 
			
		||||
		ConcatEndpoint: concatEndpoint,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										86
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
			
		||||
// Package http provides an HTTP client for the add service.
 | 
			
		||||
package http
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	jujuratelimit "github.com/juju/ratelimit"
 | 
			
		||||
	stdopentracing "github.com/opentracing/opentracing-go"
 | 
			
		||||
	"github.com/sony/gobreaker"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-kit/kit/circuitbreaker"
 | 
			
		||||
	"github.com/go-kit/kit/endpoint"
 | 
			
		||||
	"github.com/go-kit/kit/examples/addsvc"
 | 
			
		||||
	"github.com/go-kit/kit/log"
 | 
			
		||||
	"github.com/go-kit/kit/ratelimit"
 | 
			
		||||
	"github.com/go-kit/kit/tracing/opentracing"
 | 
			
		||||
	httptransport "github.com/go-kit/kit/transport/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// New returns an AddService backed by an HTTP server living at the remote
 | 
			
		||||
// instance. We expect instance to come from a service discovery system, so
 | 
			
		||||
// likely of the form "host:port".
 | 
			
		||||
func New(instance string, tracer stdopentracing.Tracer, logger log.Logger) (addsvc.Service, error) {
 | 
			
		||||
	if !strings.HasPrefix(instance, "http") {
 | 
			
		||||
		instance = "http://" + instance
 | 
			
		||||
	}
 | 
			
		||||
	u, err := url.Parse(instance)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// We construct a single ratelimiter middleware, to limit the total outgoing
 | 
			
		||||
	// QPS from this client to all methods on the remote instance. We also
 | 
			
		||||
	// construct per-endpoint circuitbreaker middlewares to demonstrate how
 | 
			
		||||
	// that's done, although they could easily be combined into a single breaker
 | 
			
		||||
	// for the entire remote instance, too.
 | 
			
		||||
 | 
			
		||||
	limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
 | 
			
		||||
 | 
			
		||||
	var sumEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		sumEndpoint = httptransport.NewClient(
 | 
			
		||||
			"POST",
 | 
			
		||||
			copyURL(u, "/sum"),
 | 
			
		||||
			addsvc.EncodeHTTPGenericRequest,
 | 
			
		||||
			addsvc.DecodeHTTPSumResponse,
 | 
			
		||||
			httptransport.ClientBefore(opentracing.ToHTTPRequest(tracer, logger)),
 | 
			
		||||
		).Endpoint()
 | 
			
		||||
		sumEndpoint = opentracing.TraceClient(tracer, "Sum")(sumEndpoint)
 | 
			
		||||
		sumEndpoint = limiter(sumEndpoint)
 | 
			
		||||
		sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Sum",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(sumEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var concatEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		concatEndpoint = httptransport.NewClient(
 | 
			
		||||
			"POST",
 | 
			
		||||
			copyURL(u, "/concat"),
 | 
			
		||||
			addsvc.EncodeHTTPGenericRequest,
 | 
			
		||||
			addsvc.DecodeHTTPConcatResponse,
 | 
			
		||||
			httptransport.ClientBefore(opentracing.ToHTTPRequest(tracer, logger)),
 | 
			
		||||
		).Endpoint()
 | 
			
		||||
		concatEndpoint = opentracing.TraceClient(tracer, "Concat")(concatEndpoint)
 | 
			
		||||
		concatEndpoint = limiter(concatEndpoint)
 | 
			
		||||
		concatEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Concat",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(concatEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return addsvc.Endpoints{
 | 
			
		||||
		SumEndpoint:    sumEndpoint,
 | 
			
		||||
		ConcatEndpoint: concatEndpoint,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func copyURL(base *url.URL, path string) *url.URL {
 | 
			
		||||
	next := *base
 | 
			
		||||
	next.Path = path
 | 
			
		||||
	return &next
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
// Package thrift provides a Thrift client for the add service.
 | 
			
		||||
package thrift
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	jujuratelimit "github.com/juju/ratelimit"
 | 
			
		||||
	"github.com/sony/gobreaker"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-kit/kit/circuitbreaker"
 | 
			
		||||
	"github.com/go-kit/kit/endpoint"
 | 
			
		||||
	"github.com/go-kit/kit/examples/addsvc"
 | 
			
		||||
	thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc"
 | 
			
		||||
	"github.com/go-kit/kit/ratelimit"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// New returns an AddService backed by a Thrift server described by the provided
 | 
			
		||||
// client. The caller is responsible for constructing the client, and eventually
 | 
			
		||||
// closing the underlying transport.
 | 
			
		||||
func New(client *thriftadd.AddServiceClient) addsvc.Service {
 | 
			
		||||
	// We construct a single ratelimiter middleware, to limit the total outgoing
 | 
			
		||||
	// QPS from this client to all methods on the remote instance. We also
 | 
			
		||||
	// construct per-endpoint circuitbreaker middlewares to demonstrate how
 | 
			
		||||
	// that's done, although they could easily be combined into a single breaker
 | 
			
		||||
	// for the entire remote instance, too.
 | 
			
		||||
 | 
			
		||||
	limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100))
 | 
			
		||||
 | 
			
		||||
	// Thrift does not currently have tracer bindings, so we skip tracing.
 | 
			
		||||
 | 
			
		||||
	var sumEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		sumEndpoint = addsvc.MakeThriftSumEndpoint(client)
 | 
			
		||||
		sumEndpoint = limiter(sumEndpoint)
 | 
			
		||||
		sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Sum",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(sumEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var concatEndpoint endpoint.Endpoint
 | 
			
		||||
	{
 | 
			
		||||
		concatEndpoint = addsvc.MakeThriftConcatEndpoint(client)
 | 
			
		||||
		concatEndpoint = limiter(concatEndpoint)
 | 
			
		||||
		concatEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{
 | 
			
		||||
			Name:    "Concat",
 | 
			
		||||
			Timeout: 30 * time.Second,
 | 
			
		||||
		}))(concatEndpoint)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return addsvc.Endpoints{
 | 
			
		||||
		SumEndpoint:    sumEndpoint,
 | 
			
		||||
		ConcatEndpoint: concatEndpoint,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user