Ejemplo n.º 1
0
        public FileBasedFabric(
            ITransitionRunner transitionRunner,
            INumericIdGenerator numericIdGenerator,
            IFileBasedFabricSerializerFactoryAdvisor serializerFactoryAdvisor,
            INumericIdGenerator idGenerator)
        {
            _transitionRunner = transitionRunner;

            Directory            = Path.GetFullPath(Path.Combine(System.IO.Directory.GetCurrentDirectory(), "data"));
            TransitionsDirectory = Path.Combine(Directory, "transitions");
            RoutinesDirectory    = Path.Combine(Directory, "routines");
            EventsDirectory      = Path.Combine(Directory, "events");

            var serializerFactory = serializerFactoryAdvisor.Advise();

            _serializationFormat = serializerFactory.Format;
            Serializer           = serializerFactory.Create();

            Connector = new FileBasedFabricConnector(
                numericIdGenerator,
                TransitionsDirectory,
                RoutinesDirectory,
                EventsDirectory,
                AddEventListener,
                Serializer,
                _serializationFormat);
        }
Ejemplo n.º 2
0
 public Task ReadRoutineStateAsync(IValueContainer target, CancellationToken ct)
 {
     if (FileBasedFabricConnector.TryReadRoutineData(
             _fabric.RoutinesDirectory, EventData.Routine.RoutineId,
             out var dataEnvelope, out var eTag) && dataEnvelope.State != null)
     {
         _fabric.Serializer.Populate(dataEnvelope.State, target);
     }
     return(Task.FromResult(true));
 }
Ejemplo n.º 3
0
            public Task <RoutineDescriptor> GetRoutineDescriptorAsync(CancellationToken ct)
            {
                var routineDesc = EventData.Routine;

                if (FileBasedFabricConnector.TryGetRoutineETag(
                        _fabric.RoutinesDirectory, routineDesc.RoutineId, out var eTag))
                {
                    routineDesc.ETag = eTag;
                }
                return(Task.FromResult(routineDesc));
            }
Ejemplo n.º 4
0
            public Task <List <ContinuationDescriptor> > GetContinuationsAsync(CancellationToken ct)
            {
                var result = new List <ContinuationDescriptor>(1);

                if (_routineEventData.Continuation != null)
                {
                    result.Add(_routineEventData.Continuation);
                }
                else if (FileBasedFabricConnector.TryReadRoutineData(
                             _fabric.RoutinesDirectory, EventData.Routine.RoutineId,
                             out var dataEnvelope, out var eTag) && dataEnvelope.Continuation != null)
                {
                    result.Add(dataEnvelope.Continuation);
                }

                return(Task.FromResult(result));
            }