Skip to content

Conversation

kpfleming
Copy link
Contributor

This introduces full support for Go context.Context objects, following best practices documented by the Go community.

All exported functions which can generate HTTP requests now require a context.Context object as their first parameter; the 'ctx' fields in Input structures (used in previous versions of go-fastly) have been removed. The provided context will be used for all HTTP requests generated by the function.

If the application using go-fastly does not have existing context.Context objects of its own, then context.TODO() can be passed to the go-fastly functions.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

  • What is the user impact of this change?

This is a major breaking change and will require a version-bump of the module, as well as a forum post and other types of outbound communication.

This introduces full support for Go context.Context objects, following
best practices documented by the Go community.

All exported functions which can generate HTTP requests now require a
context.Context object as their first parameter; the 'ctx' fields in
Input structures (used in previous versions of go-fastly) have been
removed. The provided context will be used for all HTTP requests
generated by the function.

If the application using go-fastly does not have existing
context.Context objects of its own, then context.TODO() can be passed
to the go-fastly functions.
@kpfleming kpfleming changed the title BREAKING: Implement full support for Go 'context.Context BREAKING: Implement full support for Go 'context.Context' Jul 11, 2025
@kpfleming kpfleming marked this pull request as ready for review July 11, 2025 19:55
@kpfleming kpfleming requested a review from a team as a code owner July 11, 2025 19:55
@kpfleming kpfleming requested a review from philippschulte July 11, 2025 19:55
@kpfleming
Copy link
Contributor Author

I suggest focusing on client.go first, as that's the only file which contains non-mechanical changes; the remainder of the files had the same changes made to them as all other files.

Copy link
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for doing this!

@kpfleming kpfleming merged commit 44ea9d9 into fastly:main Jul 11, 2025
4 checks passed
@kpfleming kpfleming deleted the context-param branch July 11, 2025 20:13
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.

2 participants