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

chore: add context.Context everywhere #1132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joschi
Copy link
Contributor

@joschi joschi commented Aug 8, 2024

This PR changes the internal API of the database.Driver and source.Driver interfaces so that every function accepts a context.Context to enable future use cases which require passing around data between these functions.

There are no other functional changes in this PR except for fixing the Redshift tests via #1128.

@coveralls
Copy link

coveralls commented Aug 8, 2024

Coverage Status

coverage: 56.247% (-0.07%) from 56.319%
when pulling d8b0199 on joschi:chore-context-everywhere
into 555501f on golang-migrate:master.

@@ -122,10 +123,11 @@ Database drivers: `+strings.Join(database.List(), ", ")+"\n", createUsage, gotoU
// initialize migrate
// don't catch migraterErr here and let each command decide
// how it wants to handle the error
migrater, migraterErr := migrate.New(*sourcePtr, *databasePtr)
ctx := context.Background()
Copy link

Choose a reason for hiding this comment

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

This is the only place where passing the context is clearly an improvement.
Changing every other place without an explicit use case seems excessive 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have an explicit use case: adding OpenTelemetry support to this project so that the progress can be followed in the observability tool of your choice with additional information on what's happening and what exactly went wrong in case of an error.

This relies heavily on passing around context, but I don't want to spend more time on it (outside of my internal WIP) if this particular change isn't viable or desired.

I acknowledge that on its own it's pretty useless and mostly adds noise to the existing code while breaking backward compatibility. 🤷

@joschi joschi force-pushed the chore-context-everywhere branch 3 times, most recently from 4ff8b07 to d8b0199 Compare September 8, 2024 21:20
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.

3 participants