-
Notifications
You must be signed in to change notification settings - Fork 2k
/
MemoryStreamBuilder.cs
45 lines (39 loc) · 2.17 KB
/
MemoryStreamBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using Microsoft.Extensions.DependencyInjection;
using Orleans.ApplicationParts;
using Orleans.Configuration;
using Orleans.Providers;
namespace Orleans.Hosting
{
public interface IMemoryStreamConfigurator : INamedServiceConfigurator { }
public static class MemoryStreamConfiguratorExtensions
{
public static void ConfigurePartitioning(this IMemoryStreamConfigurator configurator, int numOfQueues = HashRingStreamQueueMapperOptions.DEFAULT_NUM_QUEUES)
{
configurator.Configure<HashRingStreamQueueMapperOptions>(ob => ob.Configure(options => options.TotalQueueCount = numOfQueues));
}
}
public interface ISiloMemoryStreamConfigurator : IMemoryStreamConfigurator, ISiloRecoverableStreamConfigurator { }
public class SiloMemoryStreamConfigurator<TSerializer> : SiloRecoverableStreamConfigurator, ISiloMemoryStreamConfigurator
where TSerializer : class, IMemoryMessageBodySerializer
{
public SiloMemoryStreamConfigurator(
string name, Action<Action<IServiceCollection>> configureServicesDelegate, Action<Action<IApplicationPartManager>> configureAppPartsDelegate)
: base(name, configureServicesDelegate, MemoryAdapterFactory<TSerializer>.Create)
{
this.ConfigureDelegate(services => services.ConfigureNamedOptionForLogging<HashRingStreamQueueMapperOptions>(name));
configureAppPartsDelegate(parts => parts.AddFrameworkPart(typeof(MemoryAdapterFactory<>).Assembly));
}
}
public interface IClusterClientMemoryStreamConfigurator : IMemoryStreamConfigurator, IClusterClientPersistentStreamConfigurator { }
public class ClusterClientMemoryStreamConfigurator<TSerializer> : ClusterClientPersistentStreamConfigurator, IClusterClientMemoryStreamConfigurator
where TSerializer : class, IMemoryMessageBodySerializer
{
public ClusterClientMemoryStreamConfigurator(string name, IClientBuilder builder)
: base(name, builder, MemoryAdapterFactory<TSerializer>.Create)
{
builder
.ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(MemoryAdapterFactory<>).Assembly));
}
}
}