-
Notifications
You must be signed in to change notification settings - Fork 2k
/
StreamHostingExtensions.cs
108 lines (96 loc) · 4.92 KB
/
StreamHostingExtensions.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans.Hosting;
using Orleans.Streams;
using Orleans.Configuration;
namespace Orleans.Hosting
{
public static class StreamHostingExtensions
{
/// <summary>
/// Configure silo to use persistent streams.
/// </summary>
public static ISiloHostBuilder AddPersistentStreams(this ISiloHostBuilder builder, string name,
Func<IServiceProvider, string, IQueueAdapterFactory> adapterFactory,
Action<ISiloPersistentStreamConfigurator> configureStream)
{
//the constructor wire up DI with all default components of the streams , so need to be called regardless of configureStream null or not
var streamConfigurator = new SiloPersistentStreamConfigurator(name, configureDelegate => builder.ConfigureServices(configureDelegate), adapterFactory);
configureStream?.Invoke(streamConfigurator);
return builder;
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloHostBuilder AddSimpleMessageStreamProvider(
this ISiloHostBuilder builder,
string name,
Action<ISimpleMessageStreamConfigurator> configureStream)
{
//the constructor wire up DI with all default components of the streams , so need to be called regardless of configureStream null or not
var streamConfigurator = new SimpleMessageStreamConfigurator(name, configureDelegate => builder.ConfigureServices(configureDelegate));
configureStream?.Invoke(streamConfigurator);
return builder;
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloHostBuilder AddSimpleMessageStreamProvider(this ISiloHostBuilder builder, string name,
Action<SimpleMessageStreamProviderOptions> configureOptions)
{
return AddSimpleMessageStreamProvider(builder, name, b => b
.Configure<SimpleMessageStreamProviderOptions>(ob => ob.Configure(configureOptions)));
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloHostBuilder AddSimpleMessageStreamProvider(this ISiloHostBuilder builder, string name,
Action<OptionsBuilder<SimpleMessageStreamProviderOptions>> configureOptions = null)
{
return AddSimpleMessageStreamProvider(builder, name, b => b.Configure(configureOptions));
}
/// <summary>
/// Configure silo to use persistent streams.
/// </summary>
public static ISiloBuilder AddPersistentStreams(this ISiloBuilder builder, string name,
Func<IServiceProvider, string, IQueueAdapterFactory> adapterFactory,
Action<ISiloPersistentStreamConfigurator> configureStream)
{
//the constructor wire up DI with all default components of the streams , so need to be called regardless of configureStream null or not
var streamConfigurator = new SiloPersistentStreamConfigurator(name, configureDelegate => builder.ConfigureServices(configureDelegate), adapterFactory);
configureStream?.Invoke(streamConfigurator);
return builder;
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloBuilder AddSimpleMessageStreamProvider(
this ISiloBuilder builder,
string name,
Action<ISimpleMessageStreamConfigurator> configureStream)
{
//the constructor wire up DI with all default components of the streams , so need to be called regardless of configureStream null or not
var streamConfigurator = new SimpleMessageStreamConfigurator(name, configureDelegate => builder.ConfigureServices(configureDelegate));
configureStream?.Invoke(streamConfigurator);
return builder;
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloBuilder AddSimpleMessageStreamProvider(this ISiloBuilder builder, string name,
Action<SimpleMessageStreamProviderOptions> configureOptions)
{
return AddSimpleMessageStreamProvider(builder, name, b => b
.Configure<SimpleMessageStreamProviderOptions>(ob => ob.Configure(configureOptions)));
}
/// <summary>
/// Configure silo to use SimpleMessageProvider
/// </summary>
public static ISiloBuilder AddSimpleMessageStreamProvider(this ISiloBuilder builder, string name,
Action<OptionsBuilder<SimpleMessageStreamProviderOptions>> configureOptions = null)
{
return AddSimpleMessageStreamProvider(builder, name, b => b.Configure(configureOptions));
}
}
}