Beispiel #1
0
        public void CanUseServerPrefix()
        {
            using (var store = NewDocumentStore())
            {
                store.DatabaseCommands.Put(
                    "Raven/Hilo/Users", null,
                    new RavenJObject
                {
                    { "Max", 32 }
                },
                    new RavenJObject());

                store.DatabaseCommands.Put(
                    "Raven/ServerPrefixForHilo", null,
                    new RavenJObject
                {
                    { "ServerPrefix", "2," }
                },
                    new RavenJObject());

                var hiLoKeyGenerator = new HiLoKeyGenerator("Users", 32);

                var generateDocumentKey = hiLoKeyGenerator.GenerateDocumentKey(store.DatabaseCommands, new DocumentConvention(), new User());
                Assert.Equal("Users/2,33", generateDocumentKey);
            }
        }
Beispiel #2
0
        private int GenerateChangeSequence()
        {
            string id = changeSequenceHiLoKeyGenerator.GenerateDocumentKey(
                documentStore.DatabaseCommands, documentStore.Conventions, null);
            string identityPartsSeparator = documentStore.Conventions.IdentityPartsSeparator;
            int    lastIndexOf            = id.LastIndexOf(identityPartsSeparator, StringComparison.Ordinal);

            return(int.Parse(id.Substring(lastIndexOf + 1)));
        }
Beispiel #3
0
        private void GenerateId(EventStream eventStream, AggregateRoot aggregate)
        {
            string typeTagName = documentStore.Conventions.GetTypeTagName(aggregate.GetType());
            string id          = eventStreamsHiLoKeyGenerator.GenerateDocumentKey(
                documentStore.DatabaseCommands, documentStore.Conventions, eventStream);
            string identityPartsSeparator = documentStore.Conventions.IdentityPartsSeparator;
            int    lastIndexOf            = id.LastIndexOf(identityPartsSeparator, StringComparison.Ordinal);

            eventStream.Id = string.Format(
                "EventStreams{2}{0}{2}{1}", typeTagName, id.Substring(lastIndexOf + 1), identityPartsSeparator);
        }
Beispiel #4
0
 private long GetNextSequenceNumber()
 {
     return(long.Parse(_hiLoGen.GenerateDocumentKey(_store.DatabaseCommands, HiLoConvention, null)));
 }
Beispiel #5
0
 private long GetNextSequenceNumber()
 {
     return(long.Parse(_hiLoGen.GenerateDocumentKey(HiLoConvention, null)));
 }