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 ClientFromContext examples for both pgx + dbsql #656

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

bgentry
Copy link
Contributor

@bgentry bgentry commented Oct 24, 2024

While researching #643, I decided to write examples to illustrate whether or not ClientFromContext was actually working as intended. Turns out it is, but that there's some nuanced differences between pgx and database/sql drivers here due to the fact that pgx.Tx is an interface, whereas sql.Tx is a struct which needs to be referenced by pointer with generics.

@bgentry bgentry force-pushed the bg-examples-for-client-from-context branch from da75042 to 9402c38 Compare October 25, 2024 01:18
// ExampleClientFromContext_databaseSQL demonstrates how to extract the River
// client from the worker context when using the [database/sql] driver.
// ([github.com/riverqueue/river/riverdriver/riverdatabasesql])
func ExampleClientFromContext_databaseSQL() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These examples are named so that they can be correctly associated with the ClientFromContext function. The pkgsite docs will group them together underneath the function's documentation.

https://pkg.go.dev/github.com/fluhus/godoc-tricks#Examples

@bgentry bgentry requested a review from brandur October 25, 2024 01:23
@bgentry bgentry merged commit 9f133ce into master Oct 25, 2024
14 checks passed
@bgentry bgentry deleted the bg-examples-for-client-from-context branch October 25, 2024 01:26
tigrato pushed a commit to gravitational/river that referenced this pull request Dec 18, 2024
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.

1 participant