Ver código fonte

Rename CapProductorService to CapPublisher.

master
Savorboard 7 anos atrás
pai
commit
f00404588a
6 arquivos alterados com 23 adições e 23 exclusões
  1. +3
    -3
      samples/Sample.Kafka/Controllers/ValuesController.cs
  2. +3
    -3
      src/DotNetCore.CAP/CAP.Builder.cs
  3. +1
    -1
      src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
  4. +6
    -6
      src/DotNetCore.CAP/ICapPublisher.Default.cs
  5. +6
    -6
      src/DotNetCore.CAP/ICapPublisher.cs
  6. +4
    -4
      test/DotNetCore.CAP.Test/CAP.BuilderTest.cs

+ 3
- 3
samples/Sample.Kafka/Controllers/ValuesController.cs Ver arquivo

@@ -10,9 +10,9 @@ namespace Sample.Kafka.Controllers
[Route("api/[controller]")]
public class ValuesController : Controller, ICapSubscribe
{
private readonly ICapProducerService _producer;
private readonly ICapPublisher _producer;

public ValuesController(ICapProducerService producer)
public ValuesController(ICapPublisher producer)
{
_producer = producer;
}
@@ -35,7 +35,7 @@ namespace Sample.Kafka.Controllers
[Route("~/send")]
public async Task<IActionResult> SendTopic()
{
await _producer.SendAsync("zzwl.topic.finace.callBack", new Person { Name = "Test", Age = 11 });
await _producer.PublishAsync("zzwl.topic.finace.callBack", new Person { Name = "Test", Age = 11 });
return Ok();
}



+ 3
- 3
src/DotNetCore.CAP/CAP.Builder.cs Ver arquivo

@@ -68,13 +68,13 @@ namespace DotNetCore.CAP
}

/// <summary>
/// Add an <see cref="ICapProducerService"/>.
/// Add an <see cref="ICapPublisher"/>.
/// </summary>
/// <typeparam name="T">The type of the service.</typeparam>
public virtual CapBuilder AddProducerService<T>()
where T : class, ICapProducerService
where T : class, ICapPublisher
{
return AddScoped(typeof(ICapProducerService), typeof(T));
return AddScoped(typeof(ICapPublisher), typeof(T));
}
}
}

+ 1
- 1
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs Ver arquivo

@@ -56,7 +56,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddSingleton<IJob, CapJob>();
services.TryAddTransient<DefaultCronJobRegistry>();

services.TryAddScoped<ICapProducerService, DefaultProducerService>();
services.TryAddScoped<ICapPublisher, DefaultCapPublisher>();

return new CapBuilder(services);
}


src/DotNetCore.CAP/ICapProducerService.Default.cs → src/DotNetCore.CAP/ICapPublisher.Default.cs Ver arquivo

@@ -6,22 +6,22 @@ using Microsoft.Extensions.Logging;
namespace DotNetCore.CAP
{
/// <summary>
/// Cap <see cref="ICapProducerService"/> default implement.
/// Cap <see cref="ICapPublisher"/> default implement.
/// </summary>
public class DefaultProducerService : ICapProducerService
public class DefaultCapPublisher : ICapPublisher
{
private readonly ICapMessageStore _store;
private readonly ILogger _logger;

public DefaultProducerService(
public DefaultCapPublisher(
ICapMessageStore store,
ILogger<DefaultProducerService> logger)
ILogger<DefaultCapPublisher> logger)
{
_store = store;
_logger = logger;
}

public Task SendAsync(string topic, string content)
public Task PublishAsync(string topic, string content)
{
if (topic == null) throw new ArgumentNullException(nameof(topic));
if (content == null) throw new ArgumentNullException(nameof(content));
@@ -29,7 +29,7 @@ namespace DotNetCore.CAP
return StoreMessage(topic, content);
}

public Task SendAsync<T>(string topic, T contentObj)
public Task PublishAsync<T>(string topic, T contentObj)
{
if (topic == null) throw new ArgumentNullException(nameof(topic));


src/DotNetCore.CAP/ICapProducerService.cs → src/DotNetCore.CAP/ICapPublisher.cs Ver arquivo

@@ -3,24 +3,24 @@
namespace DotNetCore.CAP
{
/// <summary>
/// Cap producer service for store message to database.
/// A publish service for publish a message to CAP.
/// </summary>
public interface ICapProducerService
public interface ICapPublisher
{
/// <summary>
/// Send a message to cap job.
/// Publish a string message to specified topic.
/// </summary>
/// <param name="topic">the topic name or exchange router key.</param>
/// <param name="content">message body content.</param>
Task SendAsync(string topic, string content);
Task PublishAsync(string topic, string content);

/// <summary>
/// Send a message to cap job.
/// Publis a object message to specified topic.
/// </summary>
/// <typeparam name="T">The type of conetent object.</typeparam>
/// <param name="topic">the topic name or exchange router key.</param>
/// <param name="contentObj">object instance that will be serialized of json.</param>
/// <returns></returns>
Task SendAsync<T>(string topic, T contentObj);
Task PublishAsync<T>(string topic, T contentObj);
}
}

+ 4
- 4
test/DotNetCore.CAP.Test/CAP.BuilderTest.cs Ver arquivo

@@ -41,20 +41,20 @@ namespace DotNetCore.CAP.Test
services.AddCap().AddProducerService<MyProducerService>();

var thingy = services.BuildServiceProvider()
.GetRequiredService<ICapProducerService>() as MyProducerService;
.GetRequiredService<ICapPublisher>() as MyProducerService;

Assert.NotNull(thingy);
}


private class MyProducerService : ICapProducerService
private class MyProducerService : ICapPublisher
{
public Task SendAsync(string topic, string content)
public Task PublishAsync(string topic, string content)
{
throw new NotImplementedException();
}

public Task SendAsync<T>(string topic, T contentObj)
public Task PublishAsync<T>(string topic, T contentObj)
{
throw new NotImplementedException();
}


Carregando…
Cancelar
Salvar