Ver código fonte

refactor.

undefined
Savorboard 7 anos atrás
pai
commit
9edc31b044
2 arquivos alterados com 11 adições e 13 exclusões
  1. +4
    -2
      src/DotNetCore.CAP/Abstractions/CapPublisherBase.cs
  2. +7
    -11
      src/DotNetCore.CAP/IBootstrapper.Default.cs

+ 4
- 2
src/DotNetCore.CAP/Abstractions/CapPublisherBase.cs Ver arquivo

@@ -112,7 +112,7 @@ namespace DotNetCore.CAP.Abstractions
"If you are using the EntityFramework, you do not need to use this overloaded.");
}

private async Task PublishWithTransAsync(string name, string content)
private Task PublishWithTransAsync(string name, string content)
{
var message = new CapPublishedMessage
{
@@ -121,11 +121,13 @@ namespace DotNetCore.CAP.Abstractions
StatusName = StatusName.Scheduled
};

await ExecuteAsync(DbConnection, DbTransaction, message);
ExecuteAsync(DbConnection, DbTransaction, message);

ClosedCap();

PublishQueuer.PulseEvent.Set();

return Task.CompletedTask;
}

private void PublishWithTrans(string name, string content)


+ 7
- 11
src/DotNetCore.CAP/IBootstrapper.Default.cs Ver arquivo

@@ -4,12 +4,12 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace DotNetCore.CAP
{
/// <inheritdoc />
/// <summary>
/// Default implement of <see cref="IBootstrapper" />.
/// Default implement of <see cref="T:DotNetCore.CAP.IBootstrapper" />.
/// </summary>
internal class DefaultBootstrapper : IBootstrapper
{
@@ -21,16 +21,14 @@ namespace DotNetCore.CAP

public DefaultBootstrapper(
ILogger<DefaultBootstrapper> logger,
IOptions<CapOptions> options,
IStorage storage,
IApplicationLifetime appLifetime,
IEnumerable<IProcessingServer> servers)
IEnumerable<IProcessingServer> processors)
{
_logger = logger;
_appLifetime = appLifetime;
Options = options.Value;
Storage = storage;
Servers = servers;
Processors = processors;

_cts = new CancellationTokenSource();
_ctsRegistration = appLifetime.ApplicationStopping.Register(() =>
@@ -47,11 +45,9 @@ namespace DotNetCore.CAP
});
}

protected CapOptions Options { get; }

protected IStorage Storage { get; }

protected IEnumerable<IProcessingServer> Servers { get; }
protected IEnumerable<IProcessingServer> Processors { get; }

public Task BootstrapAsync()
{
@@ -68,7 +64,7 @@ namespace DotNetCore.CAP

if (_cts.IsCancellationRequested) return;

foreach (var item in Servers)
foreach (var item in Processors)
try
{
item.Start();
@@ -86,7 +82,7 @@ namespace DotNetCore.CAP
{
_appLifetime.ApplicationStopping.Register(() =>
{
foreach (var item in Servers)
foreach (var item in Processors)
item.Dispose();
});
return Task.CompletedTask;


Carregando…
Cancelar
Salvar