コード例 #1
0
 public MQPublisher(IServiceProvider serviceProvider, EventPublishOptions options)
 {
     this._options         = options;
     this._serviceProvider = serviceProvider;
     this._logger          = this._serviceProvider.GetRequiredService <ILogger <MQPublisher> >();
     this._publisher       = this._serviceProvider.GetRequiredServiceByName <IEventPublisher>(options.MQProvider);
 }
コード例 #2
0
        /// <summary>
        /// Activate Grain
        /// </summary>
        /// <returns></returns>
        public override async Task OnActivateAsync()
        {
            try
            {
                this._eventBufferBlock      = new DataflowBufferBlock <EventTransactionModel <TStateKey> >(this.TriggerEventStorage);
                this._internalConfiguration = this.ServiceProvider.GetRequiredService <IInternalConfiguration>();
                this._mqPublisher           = this.ServiceProvider.GetRequiredService <IMQPublisher>();
                this._eventSourcing         = await this.ServiceProvider.GetEventSourcing <TState, TStateKey>(this).Init(this.StateId);

                this.State = await this._eventSourcing.ReadSnapshotAsync();

                this.PublishOptions = this._internalConfiguration.GetEventPublishOptions(this);
                await base.OnActivateAsync();
            }
            catch (Exception ex)
            {
                this.Logger.LogError(ex, $"{StateId} Activate Grain failure");
                throw ex;
            }
        }
コード例 #3
0
 public void WithEventPublishOptions(string name, EventPublishOptions options)
 {
     this.configuration._eventPublishOptions.Add(name, options);
 }