|
1 | 1 | using KeyLoad.Clustering; |
2 | 2 | using KeyLoad.Server; |
3 | | -using Microsoft.Extensions.Options; |
| 3 | +using Microsoft.Extensions.DependencyInjection; |
4 | 4 |
|
5 | 5 | namespace KeyLoad.CrashHost.Features.ClusterRouting; |
6 | 6 |
|
@@ -52,42 +52,38 @@ internal static Task<ControlledPartitionMovementNativeHosts> CreateWithAuthentic |
52 | 52 | Func<int, IDatabaseAuthenticationExecutionObserver> observerFactory, CancellationToken cancellationToken) |
53 | 53 | { |
54 | 54 | ArgumentNullException.ThrowIfNull(observerFactory); |
55 | | - return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, observerFactory, null, null, null, null, null, cancellationToken); |
| 55 | + return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, observerFactory, null, null, null, null, null, null, cancellationToken); |
56 | 56 | } |
57 | 57 |
|
58 | 58 | internal static Task<ControlledPartitionMovementNativeHosts> CreateWithPhaseObserverAsync( |
59 | 59 | Func<int, IGrainRequestPhaseObserver> observerFactory, CancellationToken cancellationToken) |
60 | 60 | { |
61 | 61 | ArgumentNullException.ThrowIfNull(observerFactory); |
62 | | - return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, null, observerFactory, null, null, null, null, cancellationToken); |
| 62 | + return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, null, observerFactory, null, null, null, null, null, cancellationToken); |
63 | 63 | } |
64 | 64 |
|
65 | 65 | internal static Task<ControlledPartitionMovementNativeHosts> CreateWithMaximumBatchBytesAsync( |
66 | 66 | int maximumBatchBytes, CancellationToken cancellationToken) |
67 | 67 | { |
68 | | - return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, null, null, maximumBatchBytes, null, null, null, cancellationToken); |
69 | | - } |
70 | | - |
71 | | - internal static Task<ControlledPartitionMovementNativeHosts> CreateWithRoutingAsync( |
72 | | - IOptions<GrainRoutingOptions> routingOptions, Func<int, IGrainRequestPhaseObserver> observerFactory, |
73 | | - IGrainRequestPurposeObserver? purposeObserver, |
74 | | - Action<int, ControlledPartitionMovementNativeHost>? beforeStart, CancellationToken cancellationToken) |
75 | | - { |
76 | | - ArgumentNullException.ThrowIfNull(routingOptions); |
77 | | - ArgumentNullException.ThrowIfNull(observerFactory); |
78 | | - return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, null, observerFactory, |
79 | | - null, routingOptions, purposeObserver, beforeStart, cancellationToken); |
| 68 | + return ControlledPartitionMovementNativeHostFactory.CreateAsync(null, null, null, maximumBatchBytes, null, null, null, null, cancellationToken); |
80 | 69 | } |
81 | 70 |
|
82 | 71 | internal void RetainCreationFailure(Exception original) => creationFailure = original; |
83 | 72 |
|
84 | | - internal async Task CreateNodesAsync(CancellationToken startupCancellation) |
| 73 | + internal Task CreateNodesAsync(CancellationToken startupCancellation) |
| 74 | + => CreateNodesAsync(null, startupCancellation); |
| 75 | + |
| 76 | + internal async Task CreateNodesAsync(Action<int, IServiceCollection, NodeOptions>? configureServices, |
| 77 | + CancellationToken startupCancellation) |
85 | 78 | { |
86 | 79 | observers.Prepare(); |
| 80 | + var configureNode = configureServices; |
87 | 81 | for (var index = SourceIndex; index < ControlledPartitionMovementNativeHostEndpoints.OwnerCount; index++) |
88 | 82 | { |
| 83 | + var nodeIndex = index; |
89 | 84 | nodes.Add(await ControlledPartitionMovementNativeHost.CreateAsync(settings.Arguments(index), localhost, |
90 | 85 | observers.Sealed(index), observers.Authentication(index), phaseObserver: observers.Phase(index), purposeObserver: observers.Purpose, |
| 86 | + configureServices: configureNode is null ? null : (services, node) => configureNode(nodeIndex, services, node), |
91 | 87 | startupCancellation: startupCancellation).ConfigureAwait(false)); |
92 | 88 | } |
93 | 89 | } |
|
0 commit comments