Skip to content
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

Merged
merged 3 commits into from
Jun 18, 2020
Merged

errorsbp package #239

merged 3 commits into from
Jun 18, 2020

Conversation

fishy
Copy link
Member

@fishy fishy commented Jun 17, 2020

With batcherror.BatchError renamed into errorsbp.Batch, and errorsbp.Suppressor defined.

We are about to add more stuff into that package, so the specific name
of batcherror no longer makes sense.
@fishy
Copy link
Member Author

fishy commented Jun 17, 2020

This replaces #225

@@ -157,6 +157,7 @@ func (s *Server) Close() error {
func NewBaseplateServer(
store *secrets.Store,
processor thrift.TProcessor,
suppressor errorsbp.Suppressor,
Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Member Author

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.

@@ -157,6 +157,7 @@ func (s *Server) Close() error {
func NewBaseplateServer(
store *secrets.Store,
processor thrift.TProcessor,
suppressor errorsbp.Suppressor,
Copy link
Contributor

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?

@fishy
Copy link
Member Author

fishy commented Jun 18, 2020

💇

Copy link
Contributor

@pacejackson pacejackson left a 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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. NewBaseplateServer uses NewServer so the field is still used by NewBaseplateServer.
  2. I don't think it's important to people trying to read the documentation that NewBaseplateServer calls NewServer and if that ever changes, we'll likely have to use it directly in NewBaseplateServer. From the perspective of someone trying to integrate with this, it is used by NewBaseplateServer because that's all they interact with.

Copy link
Contributor

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.
Copy link
Contributor

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()

Copy link
Member Author

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.
@fishy fishy merged commit aa68921 into reddit:master Jun 18, 2020
@fishy fishy deleted the errorsbp branch June 18, 2020 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants