2021-10-28 23:05:07 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
|
|
|
|
|
namespace Selector.Cache
|
|
|
|
|
{
|
|
|
|
|
public interface IPublisherFactory {
|
2022-06-28 07:30:27 +01:00
|
|
|
|
public Task<IPlayerConsumer> Get(IPlayerWatcher watcher = null);
|
2021-10-28 23:05:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PublisherFactory: IPublisherFactory {
|
|
|
|
|
|
|
|
|
|
private readonly ILoggerFactory LoggerFactory;
|
|
|
|
|
private readonly ISubscriber Subscriber;
|
|
|
|
|
|
|
|
|
|
public PublisherFactory(
|
|
|
|
|
ISubscriber subscriber,
|
|
|
|
|
ILoggerFactory loggerFactory
|
|
|
|
|
) {
|
|
|
|
|
Subscriber = subscriber;
|
|
|
|
|
LoggerFactory = loggerFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-28 07:30:27 +01:00
|
|
|
|
public Task<IPlayerConsumer> Get(IPlayerWatcher watcher = null)
|
2021-10-28 23:05:07 +01:00
|
|
|
|
{
|
2022-06-28 07:30:27 +01:00
|
|
|
|
return Task.FromResult<IPlayerConsumer>(new Publisher(
|
2021-10-28 23:05:07 +01:00
|
|
|
|
watcher,
|
|
|
|
|
Subscriber,
|
|
|
|
|
LoggerFactory.CreateLogger<Publisher>()
|
2022-02-25 18:32:43 +00:00
|
|
|
|
));
|
2021-10-28 23:05:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|