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

feat(dispatch): Cursor for easy pagination #1678

Merged
merged 3 commits into from Mar 5, 2021
Merged

Conversation

dustmop
Copy link
Contributor

@dustmop dustmop commented Mar 5, 2021

No description provided.

Registering MethodSets compares the MethodSet against the implementation to
make sure they match each other. Add tests for dispatch to ensure common
failure cases actually work.
Func implementations registered with Dispatch can return 1-3 values.
Only 1 value means it must be an error. 2 values means the first is
any output and the second is an error. 3 values means the first is any
output, the second is a Cursor, and the third is an error. Cursor will
be used for pagination of methods that support it.
@dustmop dustmop requested a review from b5 March 5, 2021 13:48
@b5 b5 added feat A code change that adds functionality lib labels Mar 5, 2021
@b5 b5 added this to In progress in Sprints via automation Mar 5, 2021
@dustmop dustmop self-assigned this Mar 5, 2021
@dustmop dustmop moved this from In progress to Needs Review in Sprints Mar 5, 2021
Copy link
Member

@b5 b5 left a comment

Choose a reason for hiding this comment

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

some comment nits, but this is fantastic!

@@ -95,8 +95,7 @@ func (o *CheckoutOptions) Run() (err error) {
return err
}

_, err = inst.Filesys().Checkout(ctx, &lib.LinkParams{Dir: o.Dir, Refstr: ref})
if err != nil {
if err = inst.Filesys().Checkout(ctx, &lib.LinkParams{Dir: o.Dir, Refstr: ref}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

lovely

lib/dispatch.go Outdated
Comment on lines 31 to 33
// as the input and output parameters for those methods, and associates a string name for each
// method. Dispatch works by looking up that method name, constructing the necessary input,
// then invoking the actual implementation.
Copy link
Member

Choose a reason for hiding this comment

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

mind adjusting the comment to talk about how dispatch returns a non-nil cursor for paginated responses?

Comment on lines 99 to 101
// Test data: methodSet and implementation

type animalMethods struct {
Copy link
Member

Choose a reason for hiding this comment

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

it's not "effective go" to label sections of code with comments. add these comments to the definition of each struct by (for example) removing line 100

"testing"
)

func TestRegisterMethods(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

thank you for writing these!

Comment on lines +108 to +111
// There are either 1, 2, or 3 output values:
// 1: func() (err)
// 2: func() (out, err)
// 3: func() (out, cur, err)
Copy link
Member

Choose a reason for hiding this comment

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

We should get this comment in a place where MethodSet implementers can find it. I think a big 'ol comment above the methodSet interface

Sprints automation moved this from Needs Review to Reviewer approved Mar 5, 2021
@b5
Copy link
Member

b5 commented Mar 5, 2021

Also, tests gotta pass 😄

@dustmop
Copy link
Contributor Author

dustmop commented Mar 5, 2021

All comments addressed, merging now!

@dustmop dustmop merged commit fab7149 into master Mar 5, 2021
Sprints automation moved this from Reviewer approved to Done Mar 5, 2021
@b5 b5 deleted the reg-methods-impl branch March 5, 2021 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat A code change that adds functionality lib
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants