Beispiel #1
0
        public FlowKey CreateKey(Id id)
        {
            Expect.False(IsSingleInstance && id.IsAssigned, $"Flow {this} is single-instance and cannot have an assigned id of {id}");
            Expect.False(IsMultiInstance && id.IsUnassigned, $"Flow {this} is multi-instance and must have an assigned id");

            return(FlowKey.From(this, id));
        }
Beispiel #2
0
        QueryETag ReadETag(Type type, Id id)
        {
            if (TryGetIfNoneMatch(out var ifNoneMatch))
            {
                return(QueryETag.From(ifNoneMatch, _area));
            }

            var key = FlowKey.From(_area.Queries.Get(type), id);

            return(QueryETag.From(key, TimelinePosition.None));
        }
Beispiel #3
0
        public static Task <QueryContent> ReadQueryContent(this IQueryDb db, string etag, Type type, Id id) =>
        db.ReadQueryContent(area =>
        {
            if (!string.IsNullOrWhiteSpace(etag))
            {
                return(QueryETag.From(etag, area));
            }

            var key = FlowKey.From(area.Queries[type], id);

            return(QueryETag.From(key, TimelinePosition.None));
        });
        public static T Bind <T>(this T query, Id instanceId) where T : Query
        {
            var queryType = query.GetType();
            var areaMap   = AreaMap.From(new[] { queryType });

            AreaTypeName.TryFrom(queryType.Name, out var areaType);
            var flowType        = areaMap.GetFlow(areaType);
            var subscriptionKey = FlowKey.From(flowType, instanceId);

            FlowContext.Bind(query, subscriptionKey);
            return(query);
        }
Beispiel #5
0
 public IEnumerable <FlowKey> GetRoutes(Event e, bool scheduled)
 {
     if (!CanRoute(e, scheduled))
     {
         yield break;
     }
     else if (HasRoute)
     {
         foreach (var id in Route.Call(e))
         {
             yield return(FlowKey.From(FlowType, id));
         }
     }
     else
     {
         yield return(FlowKey.From(FlowType));
     }
 }
Beispiel #6
0
        IEnumerable <FlowKey> ReadResumeFlows(JArray json)
        {
            foreach (var typeItem in json)
            {
                if (typeItem is JArray multiInstance)
                {
                    var type = _context.Area.GetFlow(AreaTypeName.From(multiInstance[0].Value <string>()));

                    foreach (var idItem in multiInstance.Skip(1))
                    {
                        yield return(FlowKey.From(type, Id.From(idItem.Value <string>())));
                    }
                }
                else
                {
                    yield return(FlowKey.From(typeItem.Value <string>(), _context.Area));
                }
            }
        }
Beispiel #7
0
        public IEnumerable <FlowKey> GetRoutes(AreaMap area)
        {
            var singleInstanceTypes = RouteTypes.ToHashSet();

            foreach (var typeIds in RouteIds)
            {
                var type = RouteTypes[typeIds.Type];

                singleInstanceTypes.Remove(type);

                var flow = area.GetFlow(type);

                foreach (var id in typeIds.Ids)
                {
                    yield return(FlowKey.From(flow, id));
                }
            }

            foreach (var type in singleInstanceTypes)
            {
                yield return(FlowKey.From(area.GetFlow(type)));
            }
        }
Beispiel #8
0
 public void UnsubscribeFromChanged(string key) =>
 _db.UnsubscribeFromChanged(ConnectionId, FlowKey.From(key, _area));
Beispiel #9
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) =>
 reader.Value == null ? null : FlowKey.From(reader.Value.ToString(), _area);
Beispiel #10
0
 public FlowKey CreateKey(Id id) =>
 FlowKey.From(this, id);