-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
errorsbp package #239
errorsbp package #239
Conversation
We are about to add more stuff into that package, so the specific name of batcherror no longer makes sense.
This replaces #225 |
thriftbp/thrifttest/server.go
Outdated
@@ -157,6 +157,7 @@ func (s *Server) Close() error { | |||
func NewBaseplateServer( | |||
store *secrets.Store, | |||
processor thrift.TProcessor, | |||
suppressor errorsbp.Suppressor, |
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 super happy with this function signature change, but this function also makes less sense to convert to a struct arg.
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 this probably makes sense to put in ServerConfig
?
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.
That's the tricky part. ServerConfig
is used by NewServer
, which is the more customized version of NewBaseplateServer
. NewBaseplateServer
actually constructs ServerConfig
and calls NewServer
underneath.
In NewServer
, this is not needed as NewServer
does not create any middlewares by itself, it just applies all the middlewares passed in.
This is also the reason I said this function makes less sense to have a struct arg, because that new struct will be very confusing alongside ServerConfig
.
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.
OK I changed ServerConfig
to be used by both NewServer
and NewBaseplateServer
. This makes the function signatures much better.
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.
Ya, I agree that neither option is ideal. Looking forward though, I could see a world where we deprecate and remove NewServer
, and NewBaseplateServer
is the real focus anyways.
@@ -29,6 +32,6 @@ | |||
// return batch.Compile() | |||
// } | |||
// | |||
// This package is not thread-safe. | |||
// errorsbp.Batch is not thread-safe. | |||
// The same batch should not be operated on different goroutines concurrently. |
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 we add Suppressor
to this too?
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.
Yes I planned to but forgot. Added.
thriftbp/thrifttest/server.go
Outdated
@@ -157,6 +157,7 @@ func (s *Server) Close() error { | |||
func NewBaseplateServer( | |||
store *secrets.Store, | |||
processor thrift.TProcessor, | |||
suppressor errorsbp.Suppressor, |
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 this probably makes sense to put in ServerConfig
?
💇 |
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.
Code looks good, just have a couple comments on the... comments.
// regarding how it is used. | ||
ErrorSpanSuppressor errorsbp.Suppressor | ||
|
||
// Optional, used only by NewServer. |
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 don't think we really want to say used only by NewServer
? I think that's confusing since it's still used by NewBaseplateServer
because that calls NewServer
.
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.
It's "used only by NewServer" in the sense of when you pass ServerConfig
into NewBaseplateServer
, that field will be completely ignored by NewBaseplateServer
function (and overwritten by the actual address extracted from bp.Config()
). So that field is, indeed, used only by NewServer
.
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 agree that it is technically correct but I think it's misleading and can cause confusion.
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.
How about now?
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.
NewBaseplateServer
usesNewServer
so the field is still used byNewBaseplateServer
.- I don't think it's important to people trying to read the documentation that
NewBaseplateServer
callsNewServer
and if that ever changes, we'll likely have to use it directly inNewBaseplateServer
. From the perspective of someone trying to integrate with this, it is used byNewBaseplateServer
because that's all they interact with.
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.
Ok, I think this works well 🐟
// | ||
// The suppressor arg will be used as | ||
// DefaultProcessorMiddlewaresArgs.ErrorSpanSuppressor, | ||
// please refer to its documentation for more details. |
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.
It might be good to add that the Addr
and Timeout
will be pulled from bp.Config()
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.
Added.
Also update both server and client middlewares in thriftbp to support it, and also function signature changes to NewServer, NewBaseplateServer, etc. to support the new arguments.
With
batcherror.BatchError
renamed intoerrorsbp.Batch
, anderrorsbp.Suppressor
defined.