diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs
new file mode 100644
index 0000000000..b5866c5a68
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs
@@ -0,0 +1,296 @@
+// ------------------------------------------------------------------------
+// Copyright 2021 The Dapr Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Dapr
+{
+ ///
+ /// This class defines configurations for the subscribe endpoint.
+ ///
+ public class AbpSubscribeOptions
+ {
+ ///
+ /// Gets or Sets a value which indicates whether to enable or disable processing raw messages.
+ ///
+ public bool EnableRawPayload { get; set; }
+
+ ///
+ /// An optional delegate used to configure the subscriptions.
+ ///
+ public Func, Task> SubscriptionsCallback { get; set; }
+ }
+
+ ///
+ /// This class defines subscribe endpoint response
+ ///
+ public class AbpSubscription
+ {
+ ///
+ /// Gets or sets the topic name.
+ ///
+ public string Topic { get; set; }
+
+ ///
+ /// Gets or sets the pubsub name
+ ///
+ public string PubsubName { get; set; }
+
+ ///
+ /// Gets or sets the route
+ ///
+ public string Route { get; set; }
+
+ ///
+ /// Gets or sets the routes
+ ///
+ public AbpRoutes Routes { get; set; }
+
+ ///
+ /// Gets or sets the metadata.
+ ///
+ public AbpMetadata Metadata { get; set; }
+
+ ///
+ /// Gets or sets the deadletter topic.
+ ///
+ public string DeadLetterTopic { get; set; }
+ }
+
+ ///
+ /// This class defines the metadata for subscribe endpoint.
+ ///
+ public class AbpMetadata : Dictionary
+ {
+ ///
+ /// Initializes a new instance of the Metadata class.
+ ///
+ public AbpMetadata() { }
+
+ ///
+ /// Initializes a new instance of the Metadata class.
+ ///
+ ///
+ public AbpMetadata(IDictionary dictionary) : base(dictionary) { }
+
+ ///
+ /// RawPayload key
+ ///
+ internal const string RawPayload = "rawPayload";
+ }
+
+ ///
+ /// This class defines the routes for subscribe endpoint.
+ ///
+ public class AbpRoutes
+ {
+ ///
+ /// Gets or sets the default route
+ ///
+ public string Default { get; set; }
+
+ ///
+ /// Gets or sets the routing rules
+ ///
+ public List Rules { get; set; }
+ }
+
+ ///
+ /// This class defines the rule for subscribe endpoint.
+ ///
+ public class AbpRule
+ {
+ ///
+ /// Gets or sets the CEL expression to match this route.
+ ///
+ public string Match { get; set; }
+
+ ///
+ /// Gets or sets the path of the route.
+ ///
+ public string Path { get; set; }
+ }
+}
+
+namespace Microsoft.AspNetCore.Builder
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text.Json;
+ using System.Text.Json.Serialization;
+ using Dapr;
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Routing;
+ using Microsoft.AspNetCore.Routing.Patterns;
+ using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.Logging;
+
+ ///
+ /// Contains extension methods for .
+ ///
+ public static class AbpDaprEndpointRouteBuilderExtensions
+ {
+ ///
+ /// Maps an endpoint that will respond to requests to /dapr/subscribe from the
+ /// Dapr runtime.
+ ///
+ /// The .
+ /// The .
+ public static IEndpointConventionBuilder MapAbpSubscribeHandler(this IEndpointRouteBuilder endpoints)
+ {
+ return CreateSubscribeEndPoint(endpoints);
+ }
+
+ ///
+ /// Maps an endpoint that will respond to requests to /dapr/subscribe from the
+ /// Dapr runtime.
+ ///
+ /// The .
+ /// Configuration options
+ /// The .
+ ///
+ public static IEndpointConventionBuilder MapAbpSubscribeHandler(this IEndpointRouteBuilder endpoints, AbpSubscribeOptions options)
+ {
+ return CreateSubscribeEndPoint(endpoints, options);
+ }
+
+ private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRouteBuilder endpoints, AbpSubscribeOptions options = null)
+ {
+ if (endpoints is null)
+ {
+ throw new System.ArgumentNullException(nameof(endpoints));
+ }
+
+ return endpoints.MapGet("dapr/subscribe", async context =>
+ {
+ var logger = context.RequestServices.GetRequiredService().CreateLogger("DaprTopicSubscription");
+ var dataSource = context.RequestServices.GetRequiredService();
+ var subscriptions = dataSource.Endpoints
+ .OfType()
+ .Where(e => e.Metadata.GetOrderedMetadata().Any(t => t.Name != null)) // only endpoints which have TopicAttribute with not null Name.
+ .SelectMany(e =>
+ {
+ var topicMetadata = e.Metadata.GetOrderedMetadata();
+ var originalTopicMetadata = e.Metadata.GetOrderedMetadata();
+
+ var subs = new List<(string PubsubName, string Name, string DeadLetterTopic, bool? EnableRawPayload, string Match, int Priority, Dictionary OriginalTopicMetadata, string MetadataSeparator, RoutePattern RoutePattern)>();
+
+ for (int i = 0; i < topicMetadata.Count(); i++)
+ {
+ subs.Add((topicMetadata[i].PubsubName,
+ topicMetadata[i].Name,
+ (topicMetadata[i] as IDeadLetterTopicMetadata)?.DeadLetterTopic,
+ (topicMetadata[i] as IRawTopicMetadata)?.EnableRawPayload,
+ topicMetadata[i].Match,
+ topicMetadata[i].Priority,
+ originalTopicMetadata.Where(m => (topicMetadata[i] as IOwnedOriginalTopicMetadata)?.OwnedMetadatas?.Any(o => o.Equals(m.Id)) == true || string.IsNullOrEmpty(m.Id))
+ .GroupBy(c => c.Name)
+ .ToDictionary(m => m.Key, m => m.Select(c => c.Value).Distinct().ToArray()),
+ (topicMetadata[i] as IOwnedOriginalTopicMetadata)?.MetadataSeparator,
+ e.RoutePattern));
+ }
+
+ return subs;
+ })
+ .Distinct()
+ .GroupBy(e => new { e.PubsubName, e.Name })
+ .Select(e => e.OrderBy(e => e.Priority))
+ .Select(e =>
+ {
+ var first = e.First();
+ var rawPayload = e.Any(e => e.EnableRawPayload.GetValueOrDefault());
+ var metadataSeparator = e.FirstOrDefault(e => !string.IsNullOrEmpty(e.MetadataSeparator)).MetadataSeparator ?? ",";
+ var rules = e.Where(e => !string.IsNullOrEmpty(e.Match)).ToList();
+ var defaultRoutes = e.Where(e => string.IsNullOrEmpty(e.Match)).Select(e => RoutePatternToString(e.RoutePattern)).ToList();
+ var defaultRoute = defaultRoutes.FirstOrDefault();
+
+ //multiple identical names. use comma separation.
+ var metadata = new AbpMetadata(e.SelectMany(c => c.OriginalTopicMetadata).GroupBy(c => c.Key).ToDictionary(c => c.Key, c => string.Join(metadataSeparator, c.SelectMany(c => c.Value).Distinct())));
+ if (rawPayload || options?.EnableRawPayload is true)
+ {
+ metadata.Add(AbpMetadata.RawPayload, "true");
+ }
+
+ if (logger != null)
+ {
+ if (defaultRoutes.Count > 1)
+ {
+ logger.LogError("A default subscription to topic {name} on pubsub {pubsub} already exists.", first.Name, first.PubsubName);
+ }
+
+ var duplicatePriorities = rules.GroupBy(e => e.Priority)
+ .Where(g => g.Count() > 1)
+ .ToDictionary(x => x.Key, y => y.Count());
+
+ foreach (var entry in duplicatePriorities)
+ {
+ logger.LogError("A subscription to topic {name} on pubsub {pubsub} has duplicate priorities for {priority}: found {count} occurrences.", first.Name, first.PubsubName, entry.Key, entry.Value);
+ }
+ }
+
+ var subscription = new AbpSubscription
+ {
+ Topic = first.Name,
+ PubsubName = first.PubsubName,
+ Metadata = metadata.Count > 0 ? metadata : null,
+ };
+
+ if (first.DeadLetterTopic != null)
+ {
+ subscription.DeadLetterTopic = first.DeadLetterTopic;
+ }
+
+ // Use the V2 routing rules structure
+ if (rules.Count > 0)
+ {
+ subscription.Routes = new AbpRoutes
+ {
+ Rules = rules.Select(e => new AbpRule
+ {
+ Match = e.Match,
+ Path = RoutePatternToString(e.RoutePattern),
+ }).ToList(),
+ Default = defaultRoute,
+ };
+ }
+ // Use the V1 structure for backward compatibility.
+ else
+ {
+ subscription.Route = defaultRoute;
+ }
+
+ return subscription;
+ })
+ .OrderBy(e => (e.PubsubName, e.Topic))
+ .ToList();
+
+ await options?.SubscriptionsCallback(subscriptions);
+ await context.Response.WriteAsync(JsonSerializer.Serialize(subscriptions,
+ new JsonSerializerOptions
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
+ }));
+ });
+ }
+
+ private static string RoutePatternToString(RoutePattern routePattern)
+ {
+ return string.Join("/", routePattern.PathSegments
+ .Select(segment => string.Concat(segment.Parts.Cast()
+ .Select(part => part.Content))));
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
index e1ede9fe69..f31ded0e06 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
@@ -5,8 +5,6 @@
net7.0
- enable
- enable
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs
index 333a5aae9a..e3c199c001 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusModule.cs
@@ -1,7 +1,15 @@
-using Microsoft.AspNetCore.Http.Json;
-using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Dapr;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.EventBus;
using Volo.Abp.EventBus.Dapr;
-using Volo.Abp.Json.SystemTextJson;
+using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
@@ -14,16 +22,36 @@ public class AbpAspNetCoreMvcDaprEventBusModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
- // TODO: Add NewtonsoftJson json converter.
+ var subscribeOptions = context.Services.ExecutePreConfiguredActions();
- Configure(options =>
+ Configure(options =>
{
- options.SerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter());
- });
+ options.EndpointConfigureActions.Add(endpointContext =>
+ {
+ var rootServiceProvider = endpointContext.ScopeServiceProvider.GetRequiredService();
+ subscribeOptions.SubscriptionsCallback = subscriptions =>
+ {
+ var daprEventBusOptions = rootServiceProvider.GetRequiredService>().Value;
+ foreach (var handler in rootServiceProvider.GetRequiredService>().Value.Handlers)
+ {
+ foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>)))
+ {
+ var eventType = @interface.GetGenericArguments()[0];
+ var eventName = EventNameAttribute.GetNameOrDefault(eventType);
+ subscriptions.Add(new AbpSubscription()
+ {
+ PubsubName = daprEventBusOptions.PubSubName,
+ Topic = eventName,
+ Route = AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl
+ });
+ }
+ }
- Configure(options =>
- {
- options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter());
+ return Task.CompletedTask;
+ };
+
+ endpointContext.Endpoints.MapAbpSubscribeHandler(subscribeOptions);
+ });
});
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs
deleted file mode 100644
index 02ca4c8e22..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprEventBusOptions.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
-
-public class AbpAspNetCoreMvcDaprEventBusOptions
-{
- public List Contributors { get; }
-
- public AbpAspNetCoreMvcDaprEventBusOptions()
- {
- Contributors = new List();
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs
index e785f2e737..5f224abc7e 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubConsts.cs
@@ -2,7 +2,5 @@
public class AbpAspNetCoreMvcDaprPubSubConsts
{
- public const string DaprSubscribeUrl = "dapr/subscribe";
-
public const string DaprEventCallbackUrl = "api/abp/dapr/event";
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs
deleted file mode 100644
index e797bd2fc0..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProvider.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
-using Volo.Abp.DependencyInjection;
-using Volo.Abp.EventBus;
-using Volo.Abp.EventBus.Dapr;
-using Volo.Abp.EventBus.Distributed;
-
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
-
-public class AbpAspNetCoreMvcDaprPubSubProvider : ITransientDependency
-{
- protected IServiceProvider ServiceProvider { get; }
- protected AbpAspNetCoreMvcDaprEventBusOptions AspNetCoreMvcDaprEventBusOptions { get; }
- protected AbpDaprEventBusOptions DaprEventBusOptions { get; }
- protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; }
-
- public AbpAspNetCoreMvcDaprPubSubProvider(
- IServiceProvider serviceProvider,
- IOptions aspNetCoreDaprEventBusOptions,
- IOptions daprEventBusOptions,
- IOptions distributedEventBusOptions)
- {
- ServiceProvider = serviceProvider;
- AspNetCoreMvcDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value;
- DaprEventBusOptions = daprEventBusOptions.Value;
- DistributedEventBusOptions = distributedEventBusOptions.Value;
- }
-
- public virtual async Task> GetSubscriptionsAsync()
- {
- var subscriptions = new List();
- foreach (var handler in DistributedEventBusOptions.Handlers)
- {
- foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>)))
- {
- var eventType = @interface.GetGenericArguments()[0];
- var eventName = EventNameAttribute.GetNameOrDefault(eventType);
-
- subscriptions.Add(new AbpAspNetCoreMvcDaprSubscriptionDefinition()
- {
- PubSubName = DaprEventBusOptions.PubSubName,
- Topic = eventName,
- Route = AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl
- });
- }
- }
-
- if (AspNetCoreMvcDaprEventBusOptions.Contributors.Any())
- {
- using (var scope = ServiceProvider.CreateScope())
- {
- var context = new AbpAspNetCoreMvcDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions);
- foreach (var contributor in AspNetCoreMvcDaprEventBusOptions.Contributors)
- {
- await contributor.ContributeAsync(context);
- }
- }
- }
-
- return subscriptions;
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs
deleted file mode 100644
index 564b541dec..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/AbpAspNetCoreMvcDaprPubSubProviderContributorContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
-
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
-
-public class AbpAspNetCoreMvcDaprPubSubProviderContributorContext
-{
- public IServiceProvider ServiceProvider { get; }
-
- public List Subscriptions { get; }
-
- public AbpAspNetCoreMvcDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels)
- {
- ServiceProvider = serviceProvider;
- Subscriptions = daprSubscriptionModels;
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
similarity index 75%
rename from framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs
rename to framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
index 674e227cd0..92953350ae 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprPubSubController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
@@ -1,4 +1,5 @@
using System.Text.Json;
+using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@@ -10,19 +11,13 @@ namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Controllers;
[Area("abp")]
[RemoteService(Name = "abp")]
-public class AbpAspNetCoreMvcDaprPubSubController : AbpController
+public class AbpAspNetCoreMvcDaprEventsController : AbpController
{
- [HttpGet(AbpAspNetCoreMvcDaprPubSubConsts.DaprSubscribeUrl)]
- public virtual async Task> SubscribeAsync()
- {
- return await HttpContext.RequestServices.GetRequiredService().GetSubscriptionsAsync();
- }
-
[HttpPost(AbpAspNetCoreMvcDaprPubSubConsts.DaprEventCallbackUrl)]
public virtual async Task EventsAsync()
{
- this.HttpContext.ValidateDaprAppApiToken();
-
+ await HttpContext.ValidateDaprAppApiTokenAsync();
+
var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body);
var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(),
HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs
deleted file mode 100644
index 87047cd7ec..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/IAbpAspNetCoreMvcDaprPubSubProviderContributor.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus;
-
-public interface IAbpAspNetCoreMvcDaprPubSubProviderContributor
-{
- Task ContributeAsync(AbpAspNetCoreMvcDaprPubSubProviderContributorContext context);
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs
deleted file mode 100644
index 287e78e01a..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Models/AbpAspNetCoreMvcDaprSubscriptionDefinition.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
-
-public class AbpAspNetCoreMvcDaprSubscriptionDefinition
-{
- public string PubSubName { get; set; }
-
- public string Topic { get; set; }
-
- public string Route { get; set; }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs
deleted file mode 100644
index 0aa6bd4f7c..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Text.Json;
-
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
-
-public class AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy : JsonNamingPolicy
-{
- public override string ConvertName(string name)
- {
- return name.ToLower();
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs
deleted file mode 100644
index bcd2a0e1be..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/SystemTextJson/AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Text.Json;
-using System.Text.Json.Serialization;
-using Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.Models;
-
-namespace Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.SystemTextJson;
-
-public class AbpAspNetCoreMvcDaprSubscriptionDefinitionConverter : JsonConverter
-{
- private JsonSerializerOptions? _writeJsonSerializerOptions;
-
- public override AbpAspNetCoreMvcDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- throw new NotSupportedException();
- }
-
- public override void Write(Utf8JsonWriter writer, AbpAspNetCoreMvcDaprSubscriptionDefinition value, JsonSerializerOptions options)
- {
- _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options)
- {
- PropertyNamingPolicy = new AbpAspNetCoreMvcDaprPubSubJsonNamingPolicy()
- }, x => x == this);
-
- JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions);
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
index 0c72d5acc5..03bb453ba2 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
@@ -5,8 +5,6 @@
net7.0
- enable
- enable
@@ -16,7 +14,7 @@
-
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
index 817eb9824d..90432ebe53 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
@@ -1,5 +1,6 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.SignalR;
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Authorization;
using Volo.Abp.Dapr;
@@ -10,22 +11,22 @@ namespace Volo.Abp.AspNetCore.Mvc.Dapr;
public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDependency
{
protected IHttpContextAccessor HttpContextAccessor { get; }
- protected HttpContext HttpContext => GetHttpContext();
+ protected HttpContext HttpContext => GetHttpContext();
public DaprAppApiTokenValidator(IHttpContextAccessor httpContextAccessor)
{
HttpContextAccessor = httpContextAccessor;
}
-
- public virtual void CheckDaprAppApiToken()
+
+ public virtual async Task CheckDaprAppApiTokenAsync()
{
- var expectedAppApiToken = GetConfiguredAppApiTokenOrNull();
+ var expectedAppApiToken = await GetConfiguredAppApiTokenOrNullAsync();
if (expectedAppApiToken.IsNullOrWhiteSpace())
{
return;
}
-
- var headerAppApiToken = GetDaprAppApiTokenOrNull();
+
+ var headerAppApiToken = await GetDaprAppApiTokenOrNullAsync();
if (headerAppApiToken.IsNullOrWhiteSpace())
{
throw new AbpAuthorizationException("Expected Dapr App API Token is not provided! Dapr should set the 'dapr-api-token' HTTP header.");
@@ -37,39 +38,39 @@ public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDep
}
}
- public virtual bool IsValidDaprAppApiToken()
+ public virtual async Task IsValidDaprAppApiTokenAsync()
{
- var expectedAppApiToken = GetConfiguredAppApiTokenOrNull();
+ var expectedAppApiToken = await GetConfiguredAppApiTokenOrNullAsync();
if (expectedAppApiToken.IsNullOrWhiteSpace())
{
return true;
}
-
- var headerAppApiToken = GetDaprAppApiTokenOrNull();
+
+ var headerAppApiToken = await GetDaprAppApiTokenOrNullAsync();
return expectedAppApiToken == headerAppApiToken;
}
- public virtual string? GetDaprAppApiTokenOrNull()
+ public virtual Task GetDaprAppApiTokenOrNullAsync()
{
string apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"];
if (string.IsNullOrEmpty(apiTokenHeader) || apiTokenHeader.Length < 1)
{
- return null;
+ return Task.FromResult(null);
}
- return apiTokenHeader;
+ return Task.FromResult(apiTokenHeader);
}
-
- protected virtual string? GetConfiguredAppApiTokenOrNull()
+
+ protected virtual async Task GetConfiguredAppApiTokenOrNullAsync()
{
- return HttpContext
+ return await HttpContext
.RequestServices
.GetRequiredService()
- .GetAppApiToken();
+ .GetAppApiTokenAsync();
}
protected virtual HttpContext GetHttpContext()
{
return HttpContextAccessor.HttpContext ?? throw new AbpException("HttpContext is not available!");
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
index 15663d0c3c..e221af3f4d 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
@@ -1,31 +1,32 @@
-using Microsoft.AspNetCore.Http;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.Dapr;
public static class DaprHttpContextExtensions
{
- public static void ValidateDaprAppApiToken(this HttpContext httpContext)
+ public static async Task ValidateDaprAppApiTokenAsync(this HttpContext httpContext)
{
- httpContext
+ await httpContext
.RequestServices
.GetRequiredService()
- .CheckDaprAppApiToken();
+ .CheckDaprAppApiTokenAsync();
}
-
- public static bool IsValidDaprAppApiToken(this HttpContext httpContext)
+
+ public static async Task IsValidDaprAppApiTokenAsync(this HttpContext httpContext)
{
- return httpContext
+ return await httpContext
.RequestServices
.GetRequiredService()
- .IsValidDaprAppApiToken();
+ .IsValidDaprAppApiTokenAsync();
}
-
- public static string? GetDaprAppApiTokenOrNull(HttpContext httpContext)
+
+ public static async Task GetDaprAppApiTokenOrNullAsync(HttpContext httpContext)
{
- return httpContext
+ return await httpContext
.RequestServices
.GetRequiredService()
- .GetDaprAppApiTokenOrNull();
+ .GetDaprAppApiTokenOrNullAsync();
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
index ed5f281ea8..40ed6035cc 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
@@ -1,8 +1,12 @@
+using System.Threading.Tasks;
+
namespace Volo.Abp.AspNetCore.Mvc.Dapr;
public interface IDaprAppApiTokenValidator
{
- void CheckDaprAppApiToken();
- bool IsValidDaprAppApiToken();
- string? GetDaprAppApiTokenOrNull();
-}
\ No newline at end of file
+ Task CheckDaprAppApiTokenAsync();
+
+ Task IsValidDaprAppApiTokenAsync();
+
+ Task GetDaprAppApiTokenOrNullAsync();
+}
diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj
index ab079747e9..f21af371bb 100644
--- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj
+++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj
@@ -5,8 +5,6 @@
net7.0
- enable
- enable
@@ -15,7 +13,7 @@
-
+
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs
index ad284ce156..a2f5069214 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs
@@ -1,4 +1,7 @@
-using System.Text.Json;
+using System;
+using System.Net.Http;
+using System.Text.Json;
+using System.Threading.Tasks;
using Dapr.Client;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
@@ -22,7 +25,7 @@ public class AbpDaprClientFactory : IAbpDaprClientFactory, ISingletonDependency
JsonSerializerOptions = CreateJsonSerializerOptions(systemTextJsonSerializerOptions.Value);
}
- public virtual DaprClient Create(Action? builderAction = null)
+ public virtual async Task CreateAsync(Action builderAction = null)
{
var builder = new DaprClientBuilder()
.UseJsonSerializationOptions(JsonSerializerOptions);
@@ -37,7 +40,7 @@ public class AbpDaprClientFactory : IAbpDaprClientFactory, ISingletonDependency
builder.UseGrpcEndpoint(DaprOptions.GrpcEndpoint);
}
- var apiToken = DaprApiTokenProvider.GetDaprApiToken();
+ var apiToken = await DaprApiTokenProvider.GetDaprApiTokenAsync();
if (!apiToken.IsNullOrWhiteSpace())
{
builder.UseDaprApiToken(apiToken);
@@ -48,10 +51,10 @@ public class AbpDaprClientFactory : IAbpDaprClientFactory, ISingletonDependency
return builder.Build();
}
- public virtual HttpClient CreateHttpClient(
- string? appId = null,
- string? daprEndpoint = null,
- string? daprApiToken = null)
+ public virtual async Task CreateHttpClientAsync(
+ string appId = null,
+ string daprEndpoint = null,
+ string daprApiToken = null)
{
if(daprEndpoint.IsNullOrWhiteSpace() &&
!DaprOptions.HttpEndpoint.IsNullOrWhiteSpace())
@@ -62,12 +65,12 @@ public class AbpDaprClientFactory : IAbpDaprClientFactory, ISingletonDependency
return DaprClient.CreateInvokeHttpClient(
appId,
daprEndpoint,
- daprApiToken ?? DaprApiTokenProvider.GetDaprApiToken()
+ daprApiToken ?? await DaprApiTokenProvider.GetDaprApiTokenAsync()
);
}
-
+
protected virtual JsonSerializerOptions CreateJsonSerializerOptions(AbpSystemTextJsonSerializerOptions systemTextJsonSerializerOptions)
{
return new JsonSerializerOptions(systemTextJsonSerializerOptions.JsonSerializerOptions);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs
index 276e96895d..0434332785 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs
@@ -1,4 +1,7 @@
-using Microsoft.Extensions.Configuration;
+using System;
+using System.Threading.Tasks;
+using Dapr.Client;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Json;
@@ -12,14 +15,8 @@ public class AbpDaprModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
-
- ConfigureDaprOptions(configuration);
- context.Services.TryAddSingleton(
- serviceProvider => serviceProvider
- .GetRequiredService()
- .Create()
- );
+ ConfigureDaprOptions(configuration);
}
private void ConfigureDaprOptions(IConfiguration configuration)
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/DaprApiTokenProvider.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/DaprApiTokenProvider.cs
index 9fbed78204..982b8f26f1 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/DaprApiTokenProvider.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/DaprApiTokenProvider.cs
@@ -1,3 +1,4 @@
+using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
@@ -11,14 +12,14 @@ public class DaprApiTokenProvider : IDaprApiTokenProvider, ISingletonDependency
{
Options = options.Value;
}
-
- public virtual string? GetDaprApiToken()
+
+ public virtual Task GetDaprApiTokenAsync()
{
- return Options.DaprApiToken;
+ return Task.FromResult(Options.DaprApiToken);
}
- public virtual string? GetAppApiToken()
+ public virtual Task GetAppApiTokenAsync()
{
- return Options.AppApiToken;
+ return Task.FromResult(Options.AppApiToken);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs
index fc50a07d41..19a42219ad 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IAbpDaprClientFactory.cs
@@ -1,14 +1,17 @@
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
using Dapr.Client;
namespace Volo.Abp.Dapr;
public interface IAbpDaprClientFactory
{
- DaprClient Create(Action? builderAction = null);
+ Task CreateAsync(Action builderAction = null);
- HttpClient CreateHttpClient(
- string? appId = null,
- string? daprEndpoint = null,
- string? daprApiToken = null
+ Task CreateHttpClientAsync(
+ string appId = null,
+ string daprEndpoint = null,
+ string daprApiToken = null
);
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprApiTokenProvider.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprApiTokenProvider.cs
index 89ea4d516d..d25cf455d9 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprApiTokenProvider.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprApiTokenProvider.cs
@@ -1,8 +1,10 @@
+using System.Threading.Tasks;
+
namespace Volo.Abp.Dapr;
public interface IDaprApiTokenProvider
{
- string? GetDaprApiToken();
-
- string? GetAppApiToken();
-}
\ No newline at end of file
+ Task GetDaprApiTokenAsync();
+
+ Task GetAppApiTokenAsync();
+}
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs
index c37e9f2407..9a8b4c9520 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs
@@ -1,4 +1,6 @@
-namespace Volo.Abp.Dapr;
+using System;
+
+namespace Volo.Abp.Dapr;
public interface IDaprSerializer
{
diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs
index cc3bf7f529..c0924f775b 100644
--- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs
+++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs
@@ -1,4 +1,5 @@
-using System.Text;
+using System;
+using System.Text;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj
index 4adc11cef7..79d39eedf0 100644
--- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj
+++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj
@@ -2,11 +2,9 @@
-
+
net7.0
- enable
- enable
@@ -14,5 +12,5 @@
-
+
diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs
index 7579796871..a51ed8ede7 100644
--- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs
+++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs
@@ -1,15 +1,17 @@
-namespace Volo.Abp.DistributedLocking.Dapr;
+using System;
+
+namespace Volo.Abp.DistributedLocking.Dapr;
public class AbpDistributedLockDaprOptions
{
public string StoreName { get; set; }
-
+
public string? Owner { get; set; }
-
+
public TimeSpan DefaultExpirationTimeout { get; set; }
public AbpDistributedLockDaprOptions()
{
DefaultExpirationTimeout = TimeSpan.FromMinutes(2);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs
index ef99b52227..9bca2def67 100644
--- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs
+++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs
@@ -1,4 +1,7 @@
-using Microsoft.Extensions.Options;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Options;
using Volo.Abp.Dapr;
using Volo.Abp.DependencyInjection;
@@ -10,7 +13,7 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency
protected IAbpDaprClientFactory DaprClientFactory { get; }
protected AbpDistributedLockDaprOptions DistributedLockDaprOptions { get; }
protected IDistributedLockKeyNormalizer DistributedLockKeyNormalizer { get; }
-
+
public DaprAbpDistributedLock(
IAbpDaprClientFactory daprClientFactory,
IOptions distributedLockDaprOptions,
@@ -20,18 +23,18 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency
DistributedLockKeyNormalizer = distributedLockKeyNormalizer;
DistributedLockDaprOptions = distributedLockDaprOptions.Value;
}
-
- public async Task TryAcquireAsync(
+
+ public async Task TryAcquireAsync(
string name,
TimeSpan timeout = default,
CancellationToken cancellationToken = default)
{
name = DistributedLockKeyNormalizer.NormalizeKey(name);
- var daprClient = DaprClientFactory.Create();
+ var daprClient = await DaprClientFactory.CreateAsync();
var lockResponse = await daprClient.Lock(
- DistributedLockDaprOptions.StoreName,
- name,
+ DistributedLockDaprOptions.StoreName,
+ name,
DistributedLockDaprOptions.Owner ?? Guid.NewGuid().ToString(),
(int)DistributedLockDaprOptions.DefaultExpirationTimeout.TotalSeconds,
cancellationToken);
@@ -43,4 +46,4 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency
return new DaprAbpDistributedLockHandle(lockResponse);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs
index b10f0f3672..ccb82fc995 100644
--- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs
+++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs
@@ -1,18 +1,19 @@
-using Dapr.Client;
+using System.Threading.Tasks;
+using Dapr.Client;
namespace Volo.Abp.DistributedLocking.Dapr;
public class DaprAbpDistributedLockHandle : IAbpDistributedLockHandle
{
protected TryLockResponse LockResponse { get; }
-
+
public DaprAbpDistributedLockHandle(TryLockResponse lockResponse)
{
LockResponse = lockResponse;
}
-
+
public async ValueTask DisposeAsync()
{
await LockResponse.DisposeAsync();
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj
index 95cd73dbfd..61f398fecf 100644
--- a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj
+++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj
@@ -2,11 +2,9 @@
-
+
net7.0
- enable
- enable
diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs
index c8d47f6887..7f3253d41e 100644
--- a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs
+++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs
@@ -1,4 +1,8 @@
-using System.Collections.Concurrent;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.Dapr;
@@ -113,7 +117,7 @@ public class DaprDistributedEventBus : DistributedEventBusBase, ISingletonDepend
GetOrCreateHandlerFactories(eventType).Locking(factories => factories.Clear());
}
- protected async override Task PublishToEventBusAsync(Type eventType, object eventData)
+ protected override async Task PublishToEventBusAsync(Type eventType, object eventData)
{
await PublishToDaprAsync(eventType, eventData);
}
@@ -135,12 +139,12 @@ public class DaprDistributedEventBus : DistributedEventBusBase, ISingletonDepend
return handlerFactoryList.ToArray();
}
- public async override Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig)
+ public override async Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig)
{
await PublishToDaprAsync(outgoingEvent.EventName, Serializer.Deserialize(outgoingEvent.EventData, GetEventType(outgoingEvent.EventName)));
}
- public async override Task PublishManyFromOutboxAsync(IEnumerable outgoingEvents, OutboxConfig outboxConfig)
+ public override async Task PublishManyFromOutboxAsync(IEnumerable outgoingEvents, OutboxConfig outboxConfig)
{
var outgoingEventArray = outgoingEvents.ToArray();
@@ -197,7 +201,7 @@ public class DaprDistributedEventBus : DistributedEventBusBase, ISingletonDepend
protected virtual async Task PublishToDaprAsync(string eventName, object eventData)
{
- var client = DaprClientFactory.Create();
+ var client = await DaprClientFactory.CreateAsync();
await client.PublishEventAsync(pubsubName: DaprEventBusOptions.PubSubName, topicName: eventName, data: eventData);
}
diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj
index 610203dae5..0d22e68b97 100644
--- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj
+++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj
@@ -2,11 +2,9 @@
-
+
net7.0
- enable
- enable
diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs
index e13c6dbb04..9ebfb5665d 100644
--- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs
+++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs
@@ -1,4 +1,5 @@
-using Dapr.Client;
+using System;
+using Dapr.Client;
using Microsoft.Extensions.Options;
using Volo.Abp.Dapr;
using Volo.Abp.DependencyInjection;
@@ -14,4 +15,4 @@ public class AbpInvocationHandler : InvocationHandler, ITransientDependency
DaprEndpoint = daprOptions.Value.HttpEndpoint;
}
}
-}
\ No newline at end of file
+}