Exemple #1
0
        void RemoveWhenDone(IFlowScope flow) =>
        flow.Task.ContinueWith(task =>
        {
            _flowsByKey.Remove(flow.Key);

            if (task.Status == TaskStatus.RanToCompletion)
            {
                switch (task.Result)
                {
                case FlowResult.Done:
                    break;

                case FlowResult.Ignored:
                    _ignored.Add(flow.Key);
                    break;

                case FlowResult.Stopped:
                    _stopped.Add(flow.Key);
                    break;

                default:
                    throw new NotSupportedException($"Unknown flow result: {task.Result}");
                }
            }
        });
Exemple #2
0
        public bool TryOpenFlowScope(FlowType type, TimelineRoute route, out IFlowScope scope)
        {
            var unroutedScope = new FlowScope(_lifetime, _flowDb, type, route);

            scope = unroutedScope.TryRoute() ? unroutedScope : null;

            return(scope != null);
        }
Exemple #3
0
        private void RemoveWhenDone(IFlowScope scope, IDisposable connection)
        {
            scope.Task.ContinueWith(_ =>
            {
                _scopesById.Remove(scope.Key.Id);

                connection.Dispose();
            },
                                    State.CancellationToken);
        }
Exemple #4
0
 async Task ConnectFlow(IFlowScope flow)
 {
     try
     {
         await flow.Connect(this);
     }
     catch (Exception error)
     {
         Log.Error(error, "Failed to connect flow {Flow}; treating as stopped", flow.Key);
     }
 }
Exemple #5
0
        private bool TryOpenScope(TimelineRoute route, out IFlowScope scope)
        {
            scope = null;

            if (_timeline.TryOpenFlowScope(_flow, route, out scope))
            {
                var connection = scope.Connect(this);

                _scopesById[route.Id] = scope;

                RemoveWhenDone(scope, connection);
            }

            return(scope != null);
        }
Exemple #6
0
        void RemoveWhenDone(IFlowScope flow) =>
        flow.LifetimeTask.ContinueWith(task =>
        {
            _flowsByKey.Remove(flow.Key);

            if (task.Status == TaskStatus.Faulted)
            {
                Log.Error(task.Exception, "[timeline] Flow lifetime ended with an error");
            }
            else
            {
                if (task.Result == FlowResult.Ignored)
                {
                    _ignored.Add(flow.Key);
                }
            }
        });
Exemple #7
0
 internal TimelineRequest(IFlowScope flow)
 {
     Flow = flow;
 }
Exemple #8
0
 private bool TryGetScope(TimelineRoute route, out IFlowScope scope)
 {
     return(_scopesById.TryGetValue(route.Id, out scope));
 }