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

Receive and pass context.Context by value in IndexConnection methods #20

Merged
merged 1 commit into from
May 1, 2024

Conversation

austin-denoble
Copy link
Contributor

Problem

From this issue: #19

We're receiving and passing *context.Context in IndexConnection methods. This differs from our Client methods and is non-standard for how most libraries handle Context.

Solution

  • Swap to receiving and passing context.Context by value rather than a pointer in IndexConnection methods, update README example to account.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

CI Testing, make sure you can just test locally or go build

…a pointer in IndexConnection and its methods, update README
@@ -1,5 +1,5 @@
> **Warning**
>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prettier did a bunch of auto-formatting on some of this locally, sorry about that. 😬

@@ -4,12 +4,13 @@ import (
"context"
"crypto/tls"
"fmt"
"log"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My gofmt settings seem to rearrange imports. Should look into turning that off maybe...

@@ -46,7 +47,7 @@ func (idx *IndexConnection) Close() error {
return err
}

func (idx *IndexConnection) UpsertVectors(ctx *context.Context, in []*Vector) (uint32, error) {
func (idx *IndexConnection) UpsertVectors(ctx context.Context, in []*Vector) (uint32, error) {
Copy link
Contributor Author

@austin-denoble austin-denoble May 1, 2024

Choose a reason for hiding this comment

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

I think this is fine, especially given akCtx returns by value, and you pass context.Context in Client methods. At least that's my understanding.

@austin-denoble austin-denoble changed the title Receive and pass context.Context by value in IndexConnection Receive and pass context.Context by value in IndexConnection methods May 1, 2024
Copy link
Contributor

@haruska haruska left a comment

Choose a reason for hiding this comment

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

Looks good!

Just double check on the Context copy.
Sorry, should have read more carefully. Thanks for taking care of this.

@austin-denoble austin-denoble merged commit 32391bc into main May 1, 2024
3 checks passed
@austin-denoble austin-denoble deleted the adenoble/swap-to-non-pointer-context branch May 1, 2024 21:24
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