Exemplo n.º 1
0
 public ReliableEventHubReceiverConnectionFactory(
     ITestableEventHubClient client,
     IReliableStateManager state,
     Func <SaveCheckpoint, CreateHandler> handlers,
     Func <long, Task <string> > partitions,
     EventPosition initialPosition = default,
     uint?initialEpoch             = default) : this(
         client : client,
         state : state,
         handlers : handlers,
         partitions : partitions,
         initialPosition : initialPosition ?? EventPosition.FromEnd(),
         initialEpoch : initialEpoch ?? 0,
         loop : Loops.Infinite())
 {
 }
Exemplo n.º 2
0
 internal ReliableEventHubReceiverConnectionFactory(
     ITestableEventHubClient client,
     IReliableStateManager state,
     Func <SaveCheckpoint, CreateHandler> handlers,
     Func <long, Task <string> > partitions,
     EventPosition initialPosition,
     uint initialEpoch,
     IEnumerable <Unit> loop)
 {
     _client         = client;
     _state          = state;
     _handlers       = handlers;
     _partitions     = partitions;
     InitialPosition = initialPosition;
     InitialEpoch    = initialEpoch;
     Loop            = loop;
 }
 internal ServiceFabricEventHubsBuilder(ITestableEventHubClient client, StatefulService service)
 {
     Client  = client;
     Service = service;
 }
 internal static ServiceFabricEventHubsBuilder UseServiceFabricState(this ITestableEventHubClient client, StatefulService service) =>
 new ServiceFabricEventHubsBuilder(client, service);
        public static async Task <string> GetPartitionId(long partitionKey, Uri serviceName, FabricClient fabricClient, ITestableEventHubClient eventHubClient)
        {
            var serviceFabricPartitions = await fabricClient.QueryManager.GetPartitionListAsync(serviceName);

            var eventHubInformation = await eventHubClient.GetRuntimeInformationAsync();

            if (serviceFabricPartitions.Count != eventHubInformation.PartitionCount)
            {
                var msg = $"EventListener partitions ({serviceFabricPartitions.Count}) did not match the Event Hubs partitions ({eventHubInformation.PartitionCount}).";
                throw new ArgumentOutOfRangeException(msg);
            }

            if (partitionKey < 0 || partitionKey > eventHubInformation.PartitionIds.Length)
            {
                var msg = $"EventListener partition key ({partitionKey}) did not fit within the Event Hubs partitions range ({eventHubInformation.PartitionIds.First()} -- {eventHubInformation.PartitionIds.Last()}).";
                throw new IndexOutOfRangeException(msg);
            }

            var partitionId = eventHubInformation.PartitionIds[partitionKey];

            return(partitionId);
        }