< Summary

Class:Microsoft.Azure.EventHubs.ServiceFabricProcessor.IEventProcessor
Assembly:Microsoft.Azure.EventHubs.ServiceFabricProcessor
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.ServiceFabricProcessor\src\IEventProcessor.cs
Covered lines:3
Uncovered lines:0
Coverable lines:3
Total lines:65
Line coverage:100% (3 of 3)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
GetLoadMetric(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.ServiceFabricProcessor\src\IEventProcessor.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.using System;
 3
 4namespace Microsoft.Azure.EventHubs.ServiceFabricProcessor
 5{
 6    using System;
 7    using System.Collections.Generic;
 8    using System.Threading;
 9    using System.Threading.Tasks;
 10
 11    /// <summary>
 12    /// Interface for processing events.
 13    /// </summary>
 14    public abstract class IEventProcessor
 15    {
 16        /// <summary>
 17        /// Called on startup.
 18        /// </summary>
 19        /// <param name="cancellationToken"></param>
 20        /// <param name="context"></param>
 21        /// <returns></returns>
 22        abstract public Task OpenAsync(CancellationToken cancellationToken, PartitionContext context);
 23
 24        /// <summary>
 25        /// Called on shutdown.
 26        /// </summary>
 27        /// <param name="context"></param>
 28        /// <param name="reason"></param>
 29        /// <returns></returns>
 30        abstract public Task CloseAsync(PartitionContext context, CloseReason reason);
 31
 32        /// <summary>
 33        /// Called when events are available.
 34        /// </summary>
 35        /// <param name="cancellationToken"></param>
 36        /// <param name="context"></param>
 37        /// <param name="events"></param>
 38        /// <returns></returns>
 39        abstract public Task ProcessEventsAsync(CancellationToken cancellationToken, PartitionContext context, IEnumerab
 40
 41        /// <summary>
 42        /// Called when an error occurs.
 43        /// </summary>
 44        /// <param name="context"></param>
 45        /// <param name="error"></param>
 46        /// <returns></returns>
 47        abstract public Task ProcessErrorAsync(PartitionContext context, Exception error);
 48
 49        /// <summary>
 50        /// Called periodically to get user-supplied load metrics.
 51        /// </summary>
 52        /// <param name="cancellationToken"></param>
 53        /// <param name="context"></param>
 54        /// <returns></returns>
 55        virtual public Dictionary<string, int> GetLoadMetric(CancellationToken cancellationToken, PartitionContext conte
 56        {
 57            // By default all partitions have a metric of named CountOfPartitions with value 1. If Service Fabric is con
 58            // it will balance primaries across nodes simply by the number of primaries on a node. This can be overridde
 59            // more sophisticated metrics like number of events processed or CPU usage.
 860            Dictionary<string, int> defaultMetric = new Dictionary<string, int>();
 861            defaultMetric.Add(Constants.DefaultUserLoadMetricName, 1);
 862            return defaultMetric;
 63        }
 64    }
 65}

Methods/Properties

GetLoadMetric(...)