コード例 #1
0
ファイル: TransactionUnit.cs プロジェクト: chi8708/Ray
        public override async Task OnActivateAsync()
        {
            GrainType          = GetType();
            transactionStorage = ServiceProvider.GetService <ITransactionStorage>();
            var inputList = await transactionStorage.GetList <Input>(GrainType.FullName);

            foreach (var input in inputList)
            {
                inputDict.TryAdd(input.TransactionId, input);
            }
            RegisterTimer(async state =>
            {
                foreach (var commit in inputDict.Values.ToList())
                {
                    var actors = GetTransactionActors(commit.Data);
                    try
                    {
                        await AutoCommit(commit, actors);
                    }
                    catch (Exception ex)
                    {
                        await Rollback(commit, actors);
                        Logger.LogCritical(ex, ex.Message);
                    }
                }
            }, null, new TimeSpan(0, 5, 0), new TimeSpan(0, 1, 0));
        }