Skip to content

Add event.ProcessorFunc() #99

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

Merged
merged 1 commit into from
Aug 5, 2025
Merged

Add event.ProcessorFunc() #99

merged 1 commit into from
Aug 5, 2025

Conversation

colinodell
Copy link
Member

Processors consist of a single function, so let's make it easier to run a single function as a processor.

@colinodell colinodell requested a review from Copilot August 5, 2025 10:53
@colinodell colinodell self-assigned this Aug 5, 2025
Copy link

@Copilot Copilot AI left a 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 introduces a ProcessorFunc type that allows using simple functions as event processors, making it easier to implement lightweight processing logic without requiring a full struct implementation of the Processor interface.

  • Adds ProcessorFunc type that wraps a function with the processor signature
  • Implements the Process method on ProcessorFunc to satisfy the Processor interface
  • Includes comprehensive test coverage demonstrating usage with a notification filtering example

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/event/types.go Defines the new ProcessorFunc type and its Process method implementation
pkg/event/types_test.go Adds test coverage for the new ProcessorFunc functionality with mock notifications
Comments suppressed due to low confidence (1)

pkg/event/types_test.go:320

  • The test only covers the success case. Consider adding a test case where the processor function returns an error to ensure error handling works correctly.
	notifications, err := event.ProcessorFunc(dropWithoutRecipients)(t.Context(), event.Event{}, []event.Notification{notificationWithRecipient, notificationWithoutRecipient})

Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.00%. Comparing base (da1dc35) to head (e2f392b).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #99      +/-   ##
==========================================
+ Coverage   87.96%   88.00%   +0.03%     
==========================================
  Files          20       20              
  Lines         997     1000       +3     
==========================================
+ Hits          877      880       +3     
  Misses        105      105              
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@colinodell colinodell merged commit 80ee854 into main Aug 5, 2025
11 checks passed
@colinodell colinodell deleted the processor-func branch August 5, 2025 11:16
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