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}"); } } });
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); }
private void RemoveWhenDone(IFlowScope scope, IDisposable connection) { scope.Task.ContinueWith(_ => { _scopesById.Remove(scope.Key.Id); connection.Dispose(); }, State.CancellationToken); }
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); } }
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); }
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); } } });
internal TimelineRequest(IFlowScope flow) { Flow = flow; }
private bool TryGetScope(TimelineRoute route, out IFlowScope scope) { return(_scopesById.TryGetValue(route.Id, out scope)); }