From ae5abd5df87a89af7b208c1f07603048f50e0d47 Mon Sep 17 00:00:00 2001 From: Andrew Seigner Date: Thu, 20 Sep 2018 17:15:15 -0700 Subject: [PATCH] Updates for v0.0.5 release * Fix gRPC clients to honor `downstream-timeout`. * Remove `grpc-downstream-authority` flag in favor of `grpc-proxy` flag. If `grpc-proxy` is set, the target URL will be set by `grpc-proxy` and the `:authority` header will be set by `grpc-downstream-server`. If `grpc-proxy` is not set, the target URL will be set by `grpc-downstream-server`. * Change `log-level` default from `debug` to `info`. * Modify gRPC Client IDs to include `grpc-proxy` and `grpc-downstream-server`. * Additional debug logging around broadcast requests. * Bump `go-grpc` to `1.15.0`, `golang/protobuf` to `v1.2.0`, `logrus` to `v1.0.6`. * Bump Docker build Golang version to `1.11.0`. Signed-off-by: Andrew Seigner --- CHANGES.md | 14 ++++ Dockerfile | 4 +- Gopkg.lock | 85 +++++++++++++++------ Gopkg.toml | 6 +- README.md | 33 +++++---- cmd/root.go | 4 +- examples/bb-readme/application.yaml | 4 +- examples/heavy-east-west/application.yaml | 22 +++--- gen/api.pb.go | 90 ++++++++++++++++------- protocols/grpc.go | 31 ++++---- service/service.go | 2 +- strategies/broadcast_channel.go | 1 + 12 files changed, 191 insertions(+), 105 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3200508..0f834b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +## v0.0.5 + +* Fix gRPC clients to honor `downstream-timeout`. +* Remove `grpc-downstream-authority` flag in favor of `grpc-proxy` flag. + If `grpc-proxy` is set, the target URL will be set by `grpc-proxy` and the + `:authority` header will be set by `grpc-downstream-server`. If `grpc-proxy` + is not set, the target URL will be set by `grpc-downstream-server`. +* Change `log-level` default from `debug` to `info`. +* Modify gRPC Client IDs to include `grpc-proxy` and `grpc-downstream-server`. +* Additional debug logging around broadcast requests. +* Bump `go-grpc` to `1.15.0`, `golang/protobuf` to `v1.2.0`, `logrus` to + `v1.0.6`. +* Bump Docker build Golang version to `1.11.0`. + ## v0.0.4 * Introduce `grpc-downstream-authority` flag, to enable setting authority diff --git a/Dockerfile b/Dockerfile index 43a4741..f2e4b5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10.0-stretch as golang +FROM golang:1.11.0-stretch as golang WORKDIR /go/src/github.com/buoyantio/bb ADD . /go/src/github.com/buoyantio/bb @@ -10,4 +10,4 @@ FROM gcr.io/runconduit/base:2017-10-30.01 RUN apt-get update RUN apt-get install -y ca-certificates COPY --from=golang /out /out -ENTRYPOINT ["/out/bb"] \ No newline at end of file +ENTRYPOINT ["/out/bb"] diff --git a/Gopkg.lock b/Gopkg.lock index aa554f1..7648201 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,86 +2,107 @@ [[projects]] + digest = "1:6e73003ecd35f4487a5e88270d3ca0a81bc80dc88053ac7e4dcfec5fba30d918" name = "github.com/gogo/protobuf" packages = [ "jsonpb", "proto", "sortkeys", - "types" + "types", ] - revision = "1adfc126b41513cc696b209667c8656ea7aac67c" - version = "v1.0.0" + pruneopts = "" + revision = "636bf0302bc95575d69441b25a2603156ffdddf1" + version = "v1.1.1" [[projects]] + digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18" name = "github.com/golang/protobuf" packages = [ "proto", "protoc-gen-go", "protoc-gen-go/descriptor", "protoc-gen-go/generator", + "protoc-gen-go/generator/internal/remap", "protoc-gen-go/grpc", "protoc-gen-go/plugin", "ptypes", "ptypes/any", "ptypes/duration", - "ptypes/timestamp" + "ptypes/timestamp", ] - revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" + pruneopts = "" + revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" + version = "v1.2.0" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:3fcbf733a8d810a21265a7f2fe08a3353db2407da052b233f8b204b5afc03d9b" name = "github.com/sirupsen/logrus" packages = ["."] - revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" - version = "v1.0.5" + pruneopts = "" + revision = "3e01752db0189b9157070a0e1668a620f9a85da2" + version = "v1.0.6" [[projects]] + digest = "1:a1403cc8a94b8d7956ee5e9694badef0e7b051af289caad1cf668331e3ffa4f6" name = "github.com/spf13/cobra" packages = ["."] - revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b" - version = "v0.0.1" + pruneopts = "" + revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" + version = "v0.0.3" [[projects]] + digest = "1:0a52bcb568386d98f4894575d53ce3e456f56471de6897bb8b9de13c33d9340e" name = "github.com/spf13/pflag" packages = ["."] - revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" - version = "v1.0.0" + pruneopts = "" + revision = "9a97c102cda95a86cec2345a6f09f55a939babf5" + version = "v1.0.2" [[projects]] branch = "master" + digest = "1:61a86f0be8b466d6e3fbdabb155aaa4006137cb5e3fd3b949329d103fa0ceb0f" name = "golang.org/x/crypto" packages = ["ssh/terminal"] - revision = "c3a3ad6d03f7a915c0f7e194b7152974bb73d287" + pruneopts = "" + revision = "0e37d006457bf46f9e6692014ba72ef82c33022c" [[projects]] branch = "master" + digest = "1:fbdbb6cf8db3278412c9425ad78b26bb8eb788181f26a3ffb3e4f216b314f86a" name = "golang.org/x/net" packages = [ "context", + "http/httpguts", "http2", "http2/hpack", "idna", "internal/timeseries", - "lex/httplex", - "trace" + "trace", ] - revision = "92b859f39abd2d91a854c9f9c4621b2f5054a92d" + pruneopts = "" + revision = "26e67e76b6c3f6ce91f7c52def5af501b4e0f3a2" [[projects]] branch = "master" + digest = "1:70d519d5cddeb60ceda2db88c24c340b1b2d7efb25ab54bacb38f57ea1998df7" name = "golang.org/x/sys" packages = [ "unix", - "windows" + "windows", ] - revision = "d8e400bc7db4870d786864138af681469693d18c" + pruneopts = "" + revision = "d641721ec2dead6fe5ca284096fe4b1fcd49e427" [[projects]] + digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" name = "golang.org/x/text" packages = [ "collate", @@ -97,18 +118,22 @@ "unicode/bidi", "unicode/cldr", "unicode/norm", - "unicode/rangetable" + "unicode/rangetable", ] + pruneopts = "" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] branch = "master" + digest = "1:b6225010c089d419d86aa7bc8e80f50364a9464adad138bb6b46f4012c052177" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] - revision = "f8c8703595236ae70fdf8789ecb656ea0bcdcf46" + pruneopts = "" + revision = "c3f76f3b92d1ffa4c58a9ff842a58b8877655e0f" [[projects]] + digest = "1:15656947b87a6a240e61dcfae9e71a55a8d5677f240d12ab48f02cdbabf1e309" name = "google.golang.org/grpc" packages = [ ".", @@ -120,9 +145,13 @@ "credentials", "encoding", "encoding/proto", - "grpclb/grpc_lb_v1/messages", "grpclog", "internal", + "internal/backoff", + "internal/channelz", + "internal/envconfig", + "internal/grpcrand", + "internal/transport", "keepalive", "metadata", "naming", @@ -133,14 +162,22 @@ "stats", "status", "tap", - "transport" ] - revision = "8e4536a86ab602859c20df5ebfd0bd4228d08655" - version = "v1.10.0" + pruneopts = "" + revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1" + version = "v1.15.0" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "5f9fb7e12dfbc631acd1fa0e5e7e9cac0dd0c315281322b8a35ee0622fd14384" + input-imports = [ + "github.com/gogo/protobuf/jsonpb", + "github.com/golang/protobuf/proto", + "github.com/golang/protobuf/protoc-gen-go", + "github.com/sirupsen/logrus", + "github.com/spf13/cobra", + "golang.org/x/net/context", + "google.golang.org/grpc", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 11a67ba..af62763 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -2,12 +2,12 @@ required = ["github.com/golang/protobuf/protoc-gen-go"] [[constraint]] name = "github.com/sirupsen/logrus" - version = "v1.0.3" + version = "v1.0.6" [[constraint]] name = "github.com/golang/protobuf" - revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" # protobuf has no release tags at time of writing + version = "v1.2.0" [[constraint]] name = "google.golang.org/grpc" - version = "1.8.0" \ No newline at end of file + version = "1.15.0" diff --git a/README.md b/README.md index e42e4df..1772d81 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Building Blocks or `bb` is a tool that can simulate many of the typical scenario of a cloud-native Service-Oriented Architecture based on microservices. ## Using `bb` -`bb` publishes a single container, `buoyantio/bb:v0.0.3`. Instances of this +`bb` publishes a single container, `buoyantio/bb:v0.0.5`. Instances of this container receive and return a simple message, described by the protobuf schema [in this repository](api.proto). This known interface allows for `bb` containers to be arranged in many different ways, just like building a structure @@ -79,11 +79,12 @@ You should then build a Docker image for `bb`: [...] Removing intermediate container f4f571b01dd8 Successfully built e6d76c5df612 - Successfully tagged buoyantio/bb:v0.0.3 + Successfully tagged buoyantio/bb:v0.0.5 A test run using the Docker CLI should return usage information and confirm that everything is ok: - $ docker run buoyantio/bb:v0.0.3 + $ docker run buoyantio/bb:v0.0.5 + Building Blocks or `bb` is a tool that can simulate many of the typical scenarios of a cloud-native Service-Oriented Architecture based on microservices. Usage: @@ -97,19 +98,19 @@ A test run using the Docker CLI should return usage information and confirm that terminus Receives the request and returns a pre-defined response Flags: - --downstream-timeout duration timeout to use when making downstream connections. (default 1m0s) - --fire-and-forget do not wait for a response when contacting downstream services. - --grpc-downstream-authority stringSlice list of authority headers to specify routing, if set, ordering and count should match grpc-downstream-server - --grpc-downstream-server stringSlice list of servers (hostname:port) to send messages to using gRPC, can be repeated - --grpc-server-port int port to bind a gRPC server to (default -1) - --h1-downstream-server stringSlice list of servers (protocol://hostname:port) to send messages to using HTTP 1.1, can be repeated - --h1-server-port int port to bind a HTTP 1.1 server to (default -1) - -h, --help help for bb - --id string identifier for this container - --log-level string log level, must be one of: panic, fatal, error, warn, info, debug (default "debug") - --percent-failure int percentage of requests that this service will automatically fail - --sleep-in-millis int amount of milliseconds to wait before actually start processing a request - --terminate-after int terminate the process after this many requests + --downstream-timeout duration timeout to use when making downstream connections. (default 1m0s) + --fire-and-forget do not wait for a response when contacting downstream services. + --grpc-downstream-server stringSlice list of servers (hostname:port) to send messages to using gRPC, can be repeated + --grpc-proxy string optional proxy to route gRPC requests + --grpc-server-port int port to bind a gRPC server to (default -1) + --h1-downstream-server stringSlice list of servers (protocol://hostname:port) to send messages to using HTTP 1.1, can be repeated + --h1-server-port int port to bind a HTTP 1.1 server to (default -1) + -h, --help help for bb + --id string identifier for this container + --log-level string log level, must be one of: panic, fatal, error, warn, info, debug (default "info") + --percent-failure int percentage of requests that this service will automatically fail + --sleep-in-millis int amount of milliseconds to wait before actually start processing a request + --terminate-after int terminate the process after this many requests Use "bb [command] --help" for more information about a command. diff --git a/cmd/root.go b/cmd/root.go index 9a3f770..dcd07d5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -51,8 +51,8 @@ func init() { RootCmd.PersistentFlags().IntVar(&config.TerminateAfter, "terminate-after", 0, "terminate the process after this many requests") RootCmd.PersistentFlags().BoolVar(&config.FireAndForget, "fire-and-forget", false, "do not wait for a response when contacting downstream services.") RootCmd.PersistentFlags().StringSliceVar(&config.GRPCDownstreamServers, "grpc-downstream-server", []string{}, "list of servers (hostname:port) to send messages to using gRPC, can be repeated") - RootCmd.PersistentFlags().StringSliceVar(&config.GRPCDownstreamAuthorities, "grpc-downstream-authority", []string{}, "list of authority headers to specify routing, if set, ordering and count should match grpc-downstream-server") + RootCmd.PersistentFlags().StringVar(&config.GRPCProxy, "grpc-proxy", "", "optional proxy to route gRPC requests") RootCmd.PersistentFlags().StringSliceVar(&config.H1DownstreamServers, "h1-downstream-server", []string{}, "list of servers (protocol://hostname:port) to send messages to using HTTP 1.1, can be repeated") RootCmd.PersistentFlags().DurationVar(&config.DownstreamConnectionTimeout, "downstream-timeout", time.Minute*1, "timeout to use when making downstream connections.") - RootCmd.PersistentFlags().StringVar(&logLevel, "log-level", log.DebugLevel.String(), "log level, must be one of: panic, fatal, error, warn, info, debug") + RootCmd.PersistentFlags().StringVar(&logLevel, "log-level", log.InfoLevel.String(), "log level, must be one of: panic, fatal, error, warn, info, debug") } diff --git a/examples/bb-readme/application.yaml b/examples/bb-readme/application.yaml index 307a9dd..ea96b95 100644 --- a/examples/bb-readme/application.yaml +++ b/examples/bb-readme/application.yaml @@ -21,7 +21,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "9090", "--response-text", "BANANA"] ports: - containerPort: 9090 @@ -56,7 +56,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["point-to-point-channel", "--grpc-downstream-server", "bb-readme-terminus-svc:9090", "--h1-server-port", "8080"] ports: - containerPort: 8080 diff --git a/examples/heavy-east-west/application.yaml b/examples/heavy-east-west/application.yaml index 2acd7fa..0ced3b7 100644 --- a/examples/heavy-east-west/application.yaml +++ b/examples/heavy-east-west/application.yaml @@ -23,7 +23,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--h1-downstream-server", "http://heavy-east-west-lab-t1-n1-svc:80", "--h1-downstream-server", "http://heavy-east-west-lab-t1-n2-svc:80", @@ -68,7 +68,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n1-svc:80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n2-svc:80", @@ -110,7 +110,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n1-svc:80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n2-svc:80", @@ -152,7 +152,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n1-svc:80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n2-svc:80", @@ -194,7 +194,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n1-svc:80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n2-svc:80", @@ -236,7 +236,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["broadcast-channel", "--h1-server-port", "80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n1-svc:80", "--grpc-downstream-server", "heavy-east-west-lab-t2-n2-svc:80", @@ -280,7 +280,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "80", "--response-text", "t2-n1", "--fire-and-forget"] ports: @@ -317,7 +317,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "80", "--response-text", "t2-n2", "--fire-and-forget"] ports: @@ -354,7 +354,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "80", "--response-text", "t2-n3", "--fire-and-forget"] ports: @@ -391,7 +391,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "80", "--response-text", "t2-n4", "--fire-and-forget"] ports: @@ -428,7 +428,7 @@ spec: spec: containers: - name: http-to-grpc - image: buoyantio/bb:v0.0.3 + image: buoyantio/bb:v0.0.5 args: ["terminus", "--grpc-server-port", "80", "--response-text", "t2-n5", "--fire-and-forget"] ports: diff --git a/gen/api.pb.go b/gen/api.pb.go index 143d134..38c2bbe 100644 --- a/gen/api.pb.go +++ b/gen/api.pb.go @@ -1,16 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: api.proto -/* -Package buoyantio_bb is a generated protocol buffer package. - -It is generated from these files: - api.proto - -It has these top-level messages: - TheRequest - TheResponse -*/ package buoyantio_bb import proto "github.com/golang/protobuf/proto" @@ -34,13 +24,35 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type TheRequest struct { - RequestUID string `protobuf:"bytes,1,opt,name=requestUID" json:"requestUID,omitempty"` + RequestUID string `protobuf:"bytes,1,opt,name=requestUID,proto3" json:"requestUID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TheRequest) Reset() { *m = TheRequest{} } +func (m *TheRequest) String() string { return proto.CompactTextString(m) } +func (*TheRequest) ProtoMessage() {} +func (*TheRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_api_a4df1ba5ef4ed377, []int{0} +} +func (m *TheRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TheRequest.Unmarshal(m, b) +} +func (m *TheRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TheRequest.Marshal(b, m, deterministic) +} +func (dst *TheRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_TheRequest.Merge(dst, src) +} +func (m *TheRequest) XXX_Size() int { + return xxx_messageInfo_TheRequest.Size(m) +} +func (m *TheRequest) XXX_DiscardUnknown() { + xxx_messageInfo_TheRequest.DiscardUnknown(m) } -func (m *TheRequest) Reset() { *m = TheRequest{} } -func (m *TheRequest) String() string { return proto.CompactTextString(m) } -func (*TheRequest) ProtoMessage() {} -func (*TheRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_TheRequest proto.InternalMessageInfo func (m *TheRequest) GetRequestUID() string { if m != nil { @@ -50,14 +62,36 @@ func (m *TheRequest) GetRequestUID() string { } type TheResponse struct { - RequestUID string `protobuf:"bytes,1,opt,name=requestUID" json:"requestUID,omitempty"` - Payload string `protobuf:"bytes,2,opt,name=payload" json:"payload,omitempty"` + RequestUID string `protobuf:"bytes,1,opt,name=requestUID,proto3" json:"requestUID,omitempty"` + Payload string `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *TheResponse) Reset() { *m = TheResponse{} } -func (m *TheResponse) String() string { return proto.CompactTextString(m) } -func (*TheResponse) ProtoMessage() {} -func (*TheResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +func (m *TheResponse) Reset() { *m = TheResponse{} } +func (m *TheResponse) String() string { return proto.CompactTextString(m) } +func (*TheResponse) ProtoMessage() {} +func (*TheResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_api_a4df1ba5ef4ed377, []int{1} +} +func (m *TheResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TheResponse.Unmarshal(m, b) +} +func (m *TheResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TheResponse.Marshal(b, m, deterministic) +} +func (dst *TheResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_TheResponse.Merge(dst, src) +} +func (m *TheResponse) XXX_Size() int { + return xxx_messageInfo_TheResponse.Size(m) +} +func (m *TheResponse) XXX_DiscardUnknown() { + xxx_messageInfo_TheResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_TheResponse proto.InternalMessageInfo func (m *TheResponse) GetRequestUID() string { if m != nil { @@ -86,8 +120,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for TheService service - +// TheServiceClient is the client API for TheService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type TheServiceClient interface { TheFunction(ctx context.Context, in *TheRequest, opts ...grpc.CallOption) (*TheResponse, error) } @@ -102,15 +137,14 @@ func NewTheServiceClient(cc *grpc.ClientConn) TheServiceClient { func (c *theServiceClient) TheFunction(ctx context.Context, in *TheRequest, opts ...grpc.CallOption) (*TheResponse, error) { out := new(TheResponse) - err := grpc.Invoke(ctx, "/buoyantio.bb.TheService/theFunction", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/buoyantio.bb.TheService/theFunction", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for TheService service - +// TheServiceServer is the server API for TheService service. type TheServiceServer interface { TheFunction(context.Context, *TheRequest) (*TheResponse, error) } @@ -150,9 +184,9 @@ var _TheService_serviceDesc = grpc.ServiceDesc{ Metadata: "api.proto", } -func init() { proto.RegisterFile("api.proto", fileDescriptor0) } +func init() { proto.RegisterFile("api.proto", fileDescriptor_api_a4df1ba5ef4ed377) } -var fileDescriptor0 = []byte{ +var fileDescriptor_api_a4df1ba5ef4ed377 = []byte{ // 161 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0x2c, 0xc8, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x49, 0x2a, 0xcd, 0xaf, 0x4c, 0xcc, 0x2b, 0xc9, 0xcc, diff --git a/protocols/grpc.go b/protocols/grpc.go index ede7aa7..ad063ad 100644 --- a/protocols/grpc.go +++ b/protocols/grpc.go @@ -82,29 +82,28 @@ func NewGrpcServerIfConfigured(config *service.Config, serviceHandler *service.R func NewGrpcClientsIfConfigured(config *service.Config) ([]service.Client, error) { clients := make([]service.Client, 0) - withAuthorities := false - if len(config.GRPCDownstreamAuthorities) > 0 { - if len(config.GRPCDownstreamAuthorities) != len(config.GRPCDownstreamServers) { - err := fmt.Errorf("Authorities count (%d) does not match gRPC downstream server count (%d)", len(config.GRPCDownstreamAuthorities), len(config.GRPCDownstreamServers)) - log.Error(err) - return nil, err - } - - withAuthorities = true - } - - for i, serverURL := range config.GRPCDownstreamServers { + for _, serverURL := range config.GRPCDownstreamServers { + target := serverURL authority := "" - if withAuthorities { - authority = config.GRPCDownstreamAuthorities[i] + clientID := serverURL + if config.GRPCProxy != "" { + target = config.GRPCProxy + authority = serverURL + clientID = config.GRPCProxy + " / " + serverURL } - conn, err := grpc.Dial(serverURL, grpc.WithInsecure(), grpc.WithAuthority(authority)) + + conn, err := grpc.Dial( + target, + grpc.WithTimeout(config.DownstreamConnectionTimeout), + grpc.WithInsecure(), + grpc.WithAuthority(authority), + ) if err != nil { return nil, err } client := pb.NewTheServiceClient(conn) - clients = append(clients, &theGrpcClient{id: serverURL, conn: conn, grpcClient: client}) + clients = append(clients, &theGrpcClient{id: clientID, conn: conn, grpcClient: client}) } return clients, nil diff --git a/service/service.go b/service/service.go index 0d9f096..8b7bc3d 100644 --- a/service/service.go +++ b/service/service.go @@ -16,7 +16,7 @@ type Config struct { GRPCServerPort int H1ServerPort int GRPCDownstreamServers []string - GRPCDownstreamAuthorities []string + GRPCProxy string H1DownstreamServers []string PercentageFailedRequests int SleepInMillis int diff --git a/strategies/broadcast_channel.go b/strategies/broadcast_channel.go index f70a941..ec4b528 100644 --- a/strategies/broadcast_channel.go +++ b/strategies/broadcast_channel.go @@ -37,6 +37,7 @@ func (s *BroadcastChannelStrategy) Do(_ context.Context, req *pb.TheRequest) (*p log.Errorf("Error when broadcasting request [%v] to client [%s]: %v", req, c.GetID(), err) allResults <- fmt.Errorf("downstream server [%s] returned error: %v", c.GetID(), err) } else { + log.Debugf("Received response from [%s]: %+v", c.GetID(), clientResp) allResults <- clientResp } }(client)