-
Notifications
You must be signed in to change notification settings - Fork 38
refactor: use ValueTask
over Task
where appropriate
#710
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
Conversation
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the webhook processing API to use ValueTask
instead of Task
for better performance characteristics in scenarios where operations complete synchronously or use cached results. The primary motivation is to optimize allocations and improve performance for lightweight webhook processing operations.
Key Changes
- Replaced all
Task
return types withValueTask
in webhook processing methods - Updated sample applications and documentation to reflect the new API
- Modified Azure Functions integration to use the updated async patterns
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/Octokit.Webhooks/WebhookEventProcessor.cs | Core refactoring of all webhook processing methods from Task to ValueTask |
src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs | Updated Azure Functions integration to pass cancellation token |
samples/AzureFunctions/MyWebhookEventProcessor.cs | Updated sample to use ValueTask return type |
samples/AspNetCore/MyWebhookEventProcessor.cs | Updated sample to use ValueTask return type |
README.md | Updated documentation examples and added new parameter documentation |
src/Octokit.Webhooks.AzureFunctions/GitHubWebhooksHttpFunction.cs
Outdated
Show resolved
Hide resolved
@JamieMagee nitpick: not to meddle, do your thing, but i kinda tend to lean towards keeping
(emaphasis mine) I think the methods are always awaited, so this would cause less performance, and ValueTask isn't a common thing, people would know Task better. |
I think it's important to read that sentence as a whole, not in part:
This isn't a microbenchmark, and these tasks can't be cached. I think this is a good use case for
a) We call But let me split out the |
This change seems reasonable to me, particularly given that use of |
You've won me over, sounds good! |
Before the change?
WebhookEventProcessor
method signatures returnTask
After the change?
WebhookEventProcessor
method signatures returnValueTask
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!