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

Add AppendInvoke convenience wrapper #47

Merged
merged 8 commits into from May 6, 2021
Merged

Conversation

prskr
Copy link
Contributor

@prskr prskr commented Mar 22, 2021

This is meant as a WIP PR for issues #46
For now this shall only showcase the proposed change and allow further discussions on different aspects of the proposed change to ease the overall process.

@CLAassistant
Copy link

CLAassistant commented Mar 22, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #47 (bc56bb9) into master (e015acf) will not change coverage.
The diff coverage is 100.00%.

❗ Current head bc56bb9 differs from pull request most recent head 6a41b80. Consider uploading reports for the commit 6a41b80 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##            master       #47   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          102       105    +3     
=========================================
+ Hits           102       105    +3     
Impacted Files Coverage Δ
error.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e015acf...6a41b80. Read the comment docs.

@prskr prskr force-pushed the 46-append-call branch 3 times, most recently from 97f8485 to 42dee48 Compare March 24, 2021 20:18
@prskr prskr changed the title WIP: add AppendCall convenience wrapper Add AppendCall convenience wrapper Mar 25, 2021
@prskr prskr changed the title Add AppendCall convenience wrapper Add AppendInvoke convenience wrapper Mar 25, 2021
This takes a pass over the provided documentation to add more examples and
explanations.
This adds more information about AppendInvoke to the package level
documentation.
This simplifies the tests for multierr.AppendInvoke with multierr.Close.
Primarily, this moves the shared logic of building a mock closer and using
multierr.Close into the test body rather than in individual test cases.
@abhinav
Copy link
Collaborator

abhinav commented Mar 26, 2021

Thanks for the contribution, @baez90! This is generally looking pretty good.
I took a second pass over the documentation and examples to add more explanations and examples.

CC @prashantv

@abhinav abhinav requested a review from prashantv March 26, 2021 16:32
@prskr
Copy link
Contributor Author

prskr commented Mar 26, 2021

Thanks for your work on the documentation!
I wasn't sure how to keept it short and concise with the one already in place and I'm really not good with docs 😅
Looking forward to be able to use this already a lot! Thank you for the support!

@prskr
Copy link
Contributor Author

prskr commented Apr 12, 2021

@prashantv any chance to get a review any time soon? I'd love to be able to use this 😄

error.go Outdated Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
error.go Show resolved Hide resolved
error.go Outdated Show resolved Hide resolved
}

func TestAppendInvokeClose(t *testing.T) {
tests := []struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like these cases are exactly the same as AppendInvoke, should we instead share the cases? Then we could have the same cases be used across all variances:

  • an Invoke function that returns the specified error
  • an object implementing Invoker that returns the specified error
  • Closer
  • possible also with AppendInvokeFn if we add that method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting idea, unfortunately this is not directly possible.
You would need to recreate the inputs for every case that would 'reuse' the input because the into modifies the original input and I'm not aware of any good solution how to handle this without introducing either weird side effects or rather complex test input generation.

Comment on lines +115 to +117
defer func() {
fmt.Println(err)
}()
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional: I wonder if we should do a full file example instead, as it may be easier to see the print from a separate function that calls a function using AppendInvoke. It's a little easier to think of this as the result the caller sees IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean moving this to a new file only containing this very example and refactoring the anonymous function to normal functions?

@prashantv
Copy link
Collaborator

@prashantv any chance to get a review any time soon? I'd love to be able to use this

Sorry for the delay in reviewing, I started reviewing a few weeks ago but never finished my review, thanks for the reminder!

@prskr prskr requested a review from prashantv May 6, 2021 06:21
@prskr
Copy link
Contributor Author

prskr commented May 6, 2021

I applied as much of the comments as I though that would make sense - can this be merged now?

error.go Outdated Show resolved Hide resolved
We never documented AppendInto at the package level. This adds a basic
explanation of the function.
@abhinav
Copy link
Collaborator

abhinav commented May 6, 2021

Apologies for the delay @baez90. It's been a bit busy recently.
We'll merge and release this shortly.

Copy link
Collaborator

@prashantv prashantv left a comment

Choose a reason for hiding this comment

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

This looks good, I think my remaining open comments can be addressed in a follow-up.

Thanks for the contribution and your patience @baez90

@abhinav abhinav merged commit a402392 into uber-go:master May 6, 2021
abhinav added a commit that referenced this pull request May 6, 2021
Follow up to #47 with the following changes.

- The tests for AppendInvoke with Close duplicate the tests for
  AppendInvoke. These can be merged, and the unit tests for Close only
  need to verify whether the Invoker returned by multierr.Close calls
  the Close function in the provided io.Closer.
- Replace AppendInvoke example with something more realistic.
- Update changelog.
@abhinav
Copy link
Collaborator

abhinav commented May 6, 2021

Released in v1.7.0. Thanks for the contribution and your patience, @baez90!

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

4 participants