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

postgres binding, ping on init #3595

Merged
merged 5 commits into from
Nov 20, 2024

Conversation

famarting
Copy link
Contributor

Description

Implementation for #3594

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation / Created issue in the https://github.com/dapr/docs/ repo: dapr/docs#[issue number]

Signed-off-by: Fabian Martinez <[email protected]>
@famarting famarting requested review from a team as code owners November 11, 2024 12:26
Comment on lines 76 to 78
connCtx, connCancel := context.WithTimeout(ctx, m.Timeout)
p.db, err = pgxpool.NewWithConfig(connCtx, poolConfig)
connCancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
connCtx, connCancel := context.WithTimeout(ctx, m.Timeout)
p.db, err = pgxpool.NewWithConfig(connCtx, poolConfig)
connCancel()
connCtx, connCancel := context.WithTimeout(ctx, m.Timeout)
defer connCancel()
p.db, err = pgxpool.NewWithConfig(connCtx, poolConfig)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have this exact same code in the postgres state store

Copy link
Contributor

Choose a reason for hiding this comment

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

Please also update there

Comment on lines 83 to 85
pingCtx, pingCancel := context.WithTimeout(ctx, m.Timeout)
err = p.db.Ping(pingCtx)
pingCancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pingCtx, pingCancel := context.WithTimeout(ctx, m.Timeout)
err = p.db.Ping(pingCtx)
pingCancel()
pingCtx, pingCancel := context.WithTimeout(ctx, m.Timeout)
defer pingCancel()
err = p.db.Ping(pingCtx)

p.db, err = pgxpool.NewWithConfig(ctx, poolConfig)
connCtx, connCancel := context.WithTimeout(ctx, m.Timeout)
p.db, err = pgxpool.NewWithConfig(connCtx, poolConfig)
connCancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this meant to be deferred? Wouldn't we still need the p.db connection for the ping below?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ha! Josh was faster :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have this exact same code in the postgres state store

@elena-kolevska
Copy link
Contributor

Can you also please see if it's possible to add a test for this, possibly following this pattern? https://github.com/dapr/components-contrib/pull/3285/files#diff-6bd238ae78b3ac8a1e9d990dab894d9a9e90a402f52adfdc605c311ae8728712

Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
@famarting
Copy link
Contributor Author

done all

elena-kolevska
elena-kolevska previously approved these changes Nov 12, 2024
@famarting
Copy link
Contributor Author

ping @yaron2

@yaron2
Copy link
Member

yaron2 commented Nov 19, 2024

Linter is failing. otherwise LGTM

Signed-off-by: Fabian Martinez <[email protected]>
@famarting
Copy link
Contributor Author

updated

@yaron2 yaron2 merged commit 0f09d25 into dapr:main Nov 20, 2024
88 of 89 checks passed
@famarting famarting deleted the postgres-binding-validate-init branch November 20, 2024 14:52
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.

4 participants