-
Notifications
You must be signed in to change notification settings - Fork 99
Conversation
ebd6407
to
e885db6
Compare
CHANGES: * Introduced HTTPClient * Integrating DUH-RPC * Updated tests with new client * Fixed some lint issues * GRPC is no more * OTEL tracing for new client and handler * Updated benchmarks * Isolate the trace benchmark
e885db6
to
b6caf07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
{HTTPAddress: "127.0.0.1:9883", DataCenter: cluster.DataCenterOne}, | ||
}); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not t.Fatal(msg)
?
err := conf.SetDefaults() | ||
require.NoError(b, err, "Error in conf.SetDefaults") | ||
|
||
//b.Run("Forward() NO_BATCHING", func(b *testing.B) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These code blocks needed?
defer func() { tracing.EndScope(ctx, err) }() | ||
span := trace.SpanFromContext(ctx) | ||
span.SetAttributes( | ||
attribute.String("peer.HTTPAddress", p.conf.Info.HTTPAddress), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure OTel/Honeycomb prefer dot.delimited.snake_case instead of PascalCase.
Suggest: peer.http_address
}() | ||
|
||
// If config asked for no batching | ||
if HasBehavior(r.Behavior, Behavior_NO_BATCHING) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also like the global "Disable batching" feature here.
} | ||
|
||
// Wait for a response or context cancel | ||
ctx2 := tracing.StartNamedScopeDebug(ctx, "Wait for response") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: If you don't need original ctx
value later, I would just overwrite it.
return err | ||
} | ||
|
||
// TODO: Replace this with modern error handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define "modern"?
@@ -289,20 +278,10 @@ Example response: | |||
``` | |||
|
|||
### Deployment | |||
NOTE: Gubernator uses `etcd`, Kubernetes or round-robin DNS to discover peers and | |||
NOTE: Gubernator uses `memberlist` Kubernetes or round-robin DNS to discover peers and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Gubernator uses `memberlist` Kubernetes or round-robin DNS to discover peers and | |
NOTE: Gubernator uses `memberlist`, Kubernetes, or round-robin DNS to discover peers and |
Just to make it clear that memberlist != K8S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go as far as adding the Oxford comma, too.
@@ -59,7 +60,7 @@ $ curl http://localhost:9080/v1/GetRateLimits \ | |||
|
|||
### ProtoBuf Structure | |||
|
|||
An example rate limit request sent via GRPC might look like the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's strictly necessary but it may be worth adding a note that gRPC was dropped? Just for anyone who may have been using Gub with gRPC has an explicit warning
func (c *client) Forward(ctx context.Context, req *ForwardRequest, resp *ForwardResponse) error { | ||
payload, err := proto.Marshal(req) | ||
if err != nil { | ||
return duh.NewClientError(fmt.Errorf("while marshaling request payload: %w", err), nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More a suggestion for duh
- it might be helpful for this method to accept the error and wrap for you, like: duh.NewClientError(err, "while marshaling request payload")
. Tiny tiny stylistic item for reducing code read time (and absolutely not required!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This. ☝🏻
@@ -97,7 +101,7 @@ func Start(numInstances int) error { | |||
// Restart the cluster | |||
func Restart(ctx context.Context) error { | |||
for i := 0; i < len(daemons); i++ { | |||
daemons[i].Close() | |||
daemons[i].Close(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For both Restart() and Close() (and the others, it seems) - do these ctx instances need timeouts?
) | ||
|
||
func main() { | ||
url := os.Getenv("GUBER_HTTP_ADDRESS") | ||
if url == "" { | ||
url = "localhost:80" | ||
} | ||
resp, err := http.DefaultClient.Get(fmt.Sprintf("http://%s/v1/HealthCheck", url)) | ||
resp, err := http.DefaultClient.Get(fmt.Sprintf("http://%s/healthz", url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be /health.check
? README mentions /health.check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those are two different endpoints. Could we document the purpose of each?
require.NoError(t, err) | ||
reqNoClientCertRequired, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://%s/v1/HealthCheck", conf.HTTPStatusListenAddress), nil) | ||
reqNoClientCertRequired, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://%s/healthz", conf.HTTPStatusListenAddress), nil) | ||
require.NoError(t, err) | ||
|
||
// Test that a client without a cert can access /v1/HealthCheck at status address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here for if this should be /health.check
for README consistency
|
||
# Make a rate limit request | ||
$ curl http://localhost:9080/v1/GetRateLimits \ | ||
$ curl http://localhost:9080/v1/rate-limits.check \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ curl http://localhost:9080/v1/rate-limits.check \ | |
$ curl http://localhost:9080/v1/rate-limit.check \ |
According to handler.go
, at least :D
PR moved to new repo at: gubernator-io/gubernator#8. |
CHANGES: