Beispiel #1
0
        public string AddDb(ParameterEntity pe)
        {
            var key = pe.Hash();

            if (HasRegistered(key))
            {
                return(key);
            }

            receiverMap.Add(key, new Subject <ResultEntity>());
            if (!SearchDb(key))
            {
                logger?.LogInformation($"{key}.sqlite not found. Ptolemy.Hydra will create");
            }
            var db = new WriteOnlySqliteRepository(GetDbPath(pe));

            db.UpdateParameter(pe);

            // add upsert observer
            receiverMap[key].Synchronize().Buffer(bufferSize).Subscribe(list => {
                if (token.IsCancellationRequested)
                {
                    logger?.LogError("Cancel was requested. Ptolemy.Hydra give up write entity to {key}.sqlite");
                }

                db.BulkUpsert(list);
                logger?.LogInformation($"{list.Count} entities upsert to {key}.sqlite");
            }, token);

            return(key);
        }
Beispiel #2
0
 public void CloseDb(ParameterEntity pe) => CloseDb(pe.Hash());
Beispiel #3
0
 private string GetDbPath(ParameterEntity pe) => GetDbPath(pe.Hash());