/// <inheritdoc /> protected override IActorRef CreateConsumerActor() { var partitionsAssignedHandler = GetAsyncCallback <IEnumerable <TopicPartition> >(PartitionsAssigned); var partitionsRevokedHandler = GetAsyncCallback <IEnumerable <TopicPartitionOffset> >(PartitionsRevoked); IPartitionEventHandler internalHandler = new PartitionEventHandlers.AsyncCallbacks(partitionsAssignedHandler, partitionsRevokedHandler); // If custom partition events handler specified - add it to the chain var eventHandler = _subscription is IAutoSubscription autoSubscription && autoSubscription.PartitionEventsHandler.HasValue ? new PartitionEventHandlers.Chain(autoSubscription.PartitionEventsHandler.Value, internalHandler) : internalHandler; IStatisticsHandler statisticsHandler = _subscription.StatisticsHandler.HasValue ? _subscription.StatisticsHandler.Value : new StatisticsHandlers.Empty(); // This allows to override partition events handling by subclasses eventHandler = AddToPartitionAssignmentHandler(eventHandler); if (!(Materializer is ActorMaterializer actorMaterializer)) { throw new ArgumentException($"Expected {typeof(ActorMaterializer)} but got {Materializer.GetType()}"); } var extendedActorSystem = actorMaterializer.System.AsInstanceOf <ExtendedActorSystem>(); var actor = extendedActorSystem.SystemActorOf(KafkaConsumerActorMetadata.GetProps(SourceActor.Ref, _settings, eventHandler, statisticsHandler), $"kafka-consumer-{_actorNumber}"); return(actor); }
public MainWindow(ISearchHandler searchHandler, IStatisticsHandler statisticsHandler, IServiceProvider serviceProvider) { InitializeComponent(); _searchHandler = searchHandler; _statisticsHandler = statisticsHandler; _serviceProvider = serviceProvider; }
/// <summary> /// KafkaConsumerActor /// </summary> /// <param name="owner">Owner actor to send critical failures to</param> /// <param name="settings">Consumer settings</param> /// <param name="statisticsHandler">Statistics handler</param> /// <param name="partitionEventHandler">Partion events handler</param> public KafkaConsumerActor(IActorRef owner, ConsumerSettings <K, V> settings, IPartitionEventHandler partitionEventHandler, IStatisticsHandler statisticsHandler) { _owner = owner; _settings = settings; _statisticsHandler = statisticsHandler; _partitionEventHandler = partitionEventHandler; var restrictedConsumerTimeoutMs = Math.Round(_settings.PartitionHandlerWarning.TotalMilliseconds * 0.95); _restrictedConsumer = new RestrictedConsumer <K, V>(_consumer, TimeSpan.FromMilliseconds(restrictedConsumerTimeoutMs)); _warningDuration = _settings.PartitionHandlerWarning; _pollMessage = new Internal.Poll <K, V>(this, periodic: true); _delayedPollMessage = new Internal.Poll <K, V>(this, periodic: false); _log = Context.GetLogger(); }
public StatisticsProcessor(IStatisticsData statisticsData, IStatisticsHandler statisticsHandler) : this() { this.statisticsData = statisticsData; this.statisticsHandler = statisticsHandler; }
public SearchTermStatisticsWindow(IStatisticsHandler statisticsHandler) { InitializeComponent(); _statisticsHandler = statisticsHandler; SetContext(); }
/// <summary> /// Gets actor props /// </summary> internal static Props GetProps <K, V>(IActorRef owner, ConsumerSettings <K, V> settings, Decider decider, IPartitionEventHandler handler, IStatisticsHandler statisticsHandler) => Props.Create(() => new KafkaConsumerActor <K, V>(owner, settings, decider, handler, statisticsHandler)).WithDispatcher(settings.DispatcherId);
/// <summary> /// /// </summary> /// <param name="ConsumerBuilder<K"></param> /// <param name="builder"></param> /// <param name="handler"></param> /// <typeparam name="K"></typeparam> /// <typeparam name="V"></typeparam> /// <returns></returns> public static void HandleStatistics <K, V>(this ConsumerBuilder <K, V> builder, IStatisticsHandler handler) { builder.SetStatisticsHandler((_, json) => { var statistics = JsonConvert.DeserializeObject <Statistics>(json); handler.Publish(statistics); }); }
/// <inheritdoc /> public ISubscription WithStatisticsHandler(IStatisticsHandler statisticsHandler) { StatisticsHandler = new Option <IStatisticsHandler>(statisticsHandler); return(this); }
/// <summary> /// Gets actor props /// </summary> internal static Props GetProps <K, V>(ConsumerSettings <K, V> settings, IPartitionEventHandler handler, IStatisticsHandler statisticsHandler) => Props.Create(() => new KafkaConsumerActor <K, V>(ActorRefs.Nobody, settings, handler, statisticsHandler)).WithDispatcher(settings.DispatcherId);
public CharacterStatistecsWindow(IStatisticsHandler statisticsHandler) { InitializeComponent(); _statisticsHandler = statisticsHandler; SetContext(); }