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

configuration at client creation #82

Merged
merged 5 commits into from
Apr 5, 2019
Merged

Conversation

arbll
Copy link
Member

@arbll arbll commented Mar 8, 2019

What does this PR do

This PR adds a generic way to deal with the client configuration. I decided to use function options here for the implementation. This is discussable and definitely has it's pro and cons. However I prefer it over it's alternative, using a configuration struct, since it allows for dumb default value logic while using a struct would add quite a bit of complexity dealing with Golang zero values. I'm happy to discuss if someone has an opinion here.

Motivation

The list of options is growing and some new ones require to be known at the client creation. Creating new constructors like NewBuffered is not scalable.

Allowing options to be mutable after the client creation isn't a very good practice IMO.

@arbll arbll changed the base branch from master to arbll/uds-async March 8, 2019 10:55
@arbll arbll marked this pull request as ready for review March 11, 2019 13:30
@arbll arbll requested a review from truthbk March 13, 2019 14:29
Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

Very, very clean - love what you've done here. Just a couple of questions, nits.

}

// Option is a client option. Can return an error if validation fails.
type Option func(*Options) error
Copy link
Member

Choose a reason for hiding this comment

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

I'm a fan 👌

// DefaultMaxMessagesPerPayload is the default value for the MaxMessagesPerPayload option
DefaultMaxMessagesPerPayload = 16
// DefaultBlockingUDS is the default value for the BlockingUDS option
DefaultBlockingUDS = false
Copy link
Member

Choose a reason for hiding this comment

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

Blocking UDS the default behavior earlier, so this would change the behavior for customer clients possibly unwillingly. I personally would love the gains, but maybe the buffered UDS sender should be an opt-in feature?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's keep blocking in 2.x

}

// BlockingUDS sets the BlockingUDS option.
func BlockingUDS() Option {
Copy link
Member

Choose a reason for hiding this comment

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

WithBlockingUDS for consistency, perhaps?

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

@truthbk truthbk merged commit 7138c30 into arbll/uds-async Apr 5, 2019
@truthbk truthbk deleted the arbll/config-options branch April 5, 2019 00:56
truthbk pushed a commit that referenced this pull request Apr 5, 2019
* move old uds writer to uds blocking

* add async implementation

* refactor tests

* remove some useless code in ensureConnection

* add comment about write thread safety

* configuration at client creation (#82)

* introduce options

* configuration at client creation

* remove EOL'd go versions from testing
@truthbk truthbk added this to the 2.2 milestone Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants