Exemplo n.º 1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            if (!_ontology.Exists(_options.CurrentValue.EggPath))
            {
                _logger?.LogWarning("Could not find ontology log at '{EggPath}'", _options.CurrentValue.EggPath);
            }

            try
            {
                var owner = Crypto.ToHexString(_options.CurrentValue.PublicKey);

                _logs.Init(_options.CurrentValue.EggPath);
                _ontology.Init(_options.CurrentValue.PublicKey);
                _records.Init(Path.Combine(Constants.DefaultRootPath, $"{owner}.egg"));

                await _events.OnInitAsync(_records, cancellationToken);

                DutyCycle();
            }
            catch (Exception e)
            {
                Trace.TraceError($"Failed to restore ontology logs: {e}");
                _logger?.LogError(e, "Failed to restore ontology logs");
            }

            _timer = new Timer(DutyCycle, null, TimeSpan.Zero,
                               TimeSpan.FromSeconds(5));
        }
Exemplo n.º 2
0
        public async Task <T> SaveAsync <T>(T model) where T : ILogSerialized
        {
            _store.Init(_options.Value.EggPath);
            var index = await _store.AddEntryAsync(Wrap(model));

            _changeHandler.OnOntologyChanged((long)index);
            return(model);
        }