- 
                Notifications
    You must be signed in to change notification settings 
- Fork 131
Closed
Description
Related to an existing integration?
Yes
Existing integration
CommunityToolkit.Aspire.Hosting.Dapr
Overview
Revisit and refine the Dapr sidecar API to ensure it integrates smoothly with the overall builder pattern without breaking the chaining mechanism.
Usage example
With the release of CommunityToolkit 9.3 the following will be possible
var redis = builder.AddRedis("redis").WithRedisInsight();
var stateStore = builder.AddDaprStateStore("statestore").WithReference(redis); // <- Reference an aspire resource
var consumerId = builder.AddParameter("consumerID");
var redisPassword = builder.AddParameter("redisPassword", true);
var pubSub = builder.AddDaprPubSub("pubsub")
                    .WithMetadata("redisHost", "localhost:6379") // <- Ability to specify a metadata value
                    .WithMetadata("redisPassword", redisPassword) // <- Ability to specify a metadata secret 
                    .WithMetadata("consumerID", consumerId) // <- Ability to specify a metadata value
                    .WaitFor(redis);From here it would be good to refine the dapr sidecar api
var daprSidecar = builder.AddDaprSidecar("sidecar") // <- Create a dapr sidecar
                         .WithReference(stateStore) // <- reference a dapr component
                         .WithReference(pubSub); // <- reference another dapr component
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceA>("servicea")
       .WithReference(daprSidecar) // <- reference the sidecar
       .WaitFor(redis);
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceB>("serviceb")
       .WithReference(daprSidecar) // <- Should this be allowed or trigger an error?
       .WaitFor(redis);and for Azure:
var daprSidecar = builder.AddAzureDaprSidecar("sidecar") // <- Create an azure dapr sidecar
                         .WithReference(stateStore) // <- reference a dapr component
                         .WithReference(pubSub); // <- reference another dapr component
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceA>("servicea")
       .WithReference(daprSidecar) // <- reference the sidecar
       .WaitFor(redis);
builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_ServiceB>("serviceb")
       .WithReference(daprSidecar) // <- Should this be allowed or trigger an error?
       .WaitFor(redis);Breaking change?
Yes - but the existing api should be marked as deprecated and removed in a later version
Alternatives
Additional context
The approach above is based on that of the Orleans integration.
AddAzureDaprSidecar / AddDaprSidecar is based on the approach demonstrated by the Redis integration
Sidecar Reference:
- Option 1: Restrict the daprSidecar resource so that it can only be referenced by a single project. An analyzer could be implemented to enforce this rule to prevent accidental misuse and ensure clarity of sidecar ownership.
- Option 2: Allow the sidecar to be shared across multiple projects if each reference results in its own unique sidecar instance, because each reference would represent an individual sidecar instance, this would allow the sidecars to be defined by the combination of components rather than one for every resource which would be more verbose.
Help us help you
Yes, I'd like to be assigned to work on this item
Metadata
Metadata
Assignees
Labels
No labels