Skip to content

Add Reaction for dapr output bindings #229

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ms-nateb
Copy link
Contributor

@ms-nateb ms-nateb commented May 21, 2025

Waiting on #226 will update with changes made and then rebase!

This pull request introduces a new reaction, PostDaprOutputBindings, to the system. It includes updates to configuration files, Dockerfiles, and the addition of unit tests for the new functionality. Below is a summary of the key changes:

Dockerfile Additions

  • Created Dockerfile for PostDaprOutputBinding to build and publish the reaction using .NET 9.0, with production-specific logging configurations.
  • Created Dockerfile.debug for debugging purposes, including additional runtime dependencies and debug-specific logging configurations.

Unit Tests for New Reaction

  • Added comprehensive unit tests for ChangeFormatter in Drasi.Reactions.PostDaprOutputBinding.Tests/ChangeFormatterTests.cs, covering scenarios like formatting added, updated, and deleted results.
  • Added unit tests for ChangeHandler in Drasi.Reactions.PostDaprOutputBinding.Tests/ChangeHandlerTests.cs, testing behavior for various configurations, error handling, and event publishing.# Description

Please explain the changes you've made.

Type of change

  • This pull request adds or changes features of Drasi and has an approved issue (issue link required).

Implements #248

@ms-nateb ms-nateb requested a review from a team as a code owner May 21, 2025 01:07
@ms-nateb ms-nateb force-pushed the dev/reaction-binding branch from 7c7c711 to 5932770 Compare May 21, 2025 01:10
?? throw new ArgumentNullException(nameof(config), $"Query configuration is null for query {queryId}");

// Check if the query is already in a failed state
if (_failureTracker.IsQueryFailed(queryId))
Copy link
Contributor

Choose a reason for hiding this comment

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

Polly is the most popular .net library for resilience - https://www.pollydocs.org/
I think we should look at adopting that instead of writing our own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,59 @@
.PHONY: all deploy-postgres deploy-redis deploy-dapr-components build-subscribers load-subscribers deploy-subscribers logs-alpha logs-beta clean-subscribers clean-dapr-components clean-redis clean-postgres clean-all
Copy link
Member

Choose a reason for hiding this comment

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

ms-nateb added 2 commits June 2, 2025 14:43
# Conflicts:
#	.github/workflows/draft-release.yml
#	cli/installers/resources/default-reaction-providers.yaml
"bindingName": "drasi-output-binding",
"bindingType": "http",
"bindingOperation": "put"
"packed": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to follow up on the enum instead of bool and add a comma

name: PostDaprOutputBinding
spec:
services:
reaction:
Copy link
Contributor

@danielgerlag danielgerlag Jun 5, 2025

Choose a reason for hiding this comment

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

We need to include the config schema section here. See the StorageQueue reaction for a relevant example.

/// <summary>
/// Implementation of the query failure tracker using ConcurrentDictionary.
/// </summary>
public class QueryFailureTracker : IQueryFailureTracker
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use a library like Polly for this?
https://github.com/App-vNext/Polly

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, does invoking through Dapr not already add circuit breaker functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dapr provides a default circuit breaker https://docs.dapr.io/operations/resiliency/policies/default-policies/ would we need to extend it?

Copy link
Contributor

Choose a reason for hiding this comment

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

We would not need to do anything. If Dapr is already providing this functionality, we don't need to build it into the Reaction.

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