public Guid[] Get(ReservedIdsSource input)
 {
     return _db.HandleTransientErrors(db =>
     {
         var data=db.QueryValue(q => q.From<ReservedIdRow>()
         .Where(d=>d.Id==ReservedIdRow.GetId(input))
         .Select(d=>d.Data)
         );
         return data?.Split(',').Select(Guid.Parse).ToArray()??Array.Empty<Guid>();
     });
 }
        public ReserveIdStorageTests()
        {
            _host = Substitute.For<IConfigureHost>();

            _host.WithReserveIdStorage(Arg.Do<IStoreReservedMessagesIds>(v => _sut = v));
            _cfg = new StoragesConfiguration(_host, Setup.GetConnection());
            _cfg.EnableReserveIdStorage(ifExists: TableExistsAction.DropIt);

            _src=new ReservedIdsSource()
            {
                Count = 2,
                HandlerType = GetType(),
                MessageId = Guid.Empty
            };
        }
 public void Add(ReservedIdsSource id, Guid[] ids)
 {
     _db.HandleTransientErrors(db =>
     {
         try
         {
             db.Insert(new ReservedIdRow()
             {
                 Id = ReservedIdRow.GetId(id),
                 Data = ids.Select(d => d.ToString()).StringJoin()
             });
         }
         catch (DbException ex) when (db.IsUniqueViolation(ex))
         {
             //ignore duplicates
         }
     });
 }
示例#4
0
 public static string GetId(ReservedIdsSource src) => src.MessageId + src.HandlerType.FullName;