Example #1
0
        internal Transaction(DgraphClient client)
        {
            this.client = client;

            context         = new TxnContext();
            context.LinRead = client.GetLinRead();
        }
Example #2
0
            private void MergeContext(TxnContext src)
            {
                TxnContext result = new TxnContext(_context);

                LinRead lr = MergeLinReads(_context.LinRead, src.LinRead);

                result.LinRead = lr;

                lock (_client._lock)
                {
                    lr = MergeLinReads(_client._linRead, lr);
                    _client._linRead = lr;
                }

                if (_context.StartTs == 0)
                {
                    result.StartTs = src.StartTs;
                }
                else if (_context.StartTs != src.StartTs)
                {
                    _context = result;
                    throw new DgraphException("StartTs mismatch");
                }

                result.Keys.Add(src.Keys);

                _context = result;
            }
Example #3
0
        internal Transaction(IDgraphClientInternal client)
        {
            Client = client;

            TransactionState = TransactionState.OK;

            Context = new TxnContext();
        }
Example #4
0
 protected ReadOnlyTransaction(IDgraphClientInternal client, Boolean readOnly, Boolean bestEffort)
 {
     Client           = client;
     ReadOnly         = readOnly;
     BestEffort       = bestEffort;
     TransactionState = TransactionState.OK;
     Context          = new TxnContext();
 }
Example #5
0
 internal Transaction(DgraphNetClient client)
 {
     _client  = client;
     _context = new TxnContext
     {
         LinRead = _client.GetLinReadCopy()
     };
 }
Example #6
0
        private void MergeContext(TxnContext source)
        {
            if (source != null)
            {
                if (context.StartTs == 0)
                {
                    context.StartTs = source.StartTs;
                }

                if (context.StartTs != source.StartTs)
                {
                    throw new Exception("A StartTs mismatch occured");
                }

                context.Keys.AddRange(source.Keys);
                context.Preds.AddRange(source.Preds);
            }
        }
Example #7
0
            private bool BeforeDiscard()
            {
                if (_finished)
                {
                    return(false);
                }
                _finished = true;

                if (!_mutated)
                {
                    return(false);
                }

                _context = new TxnContext(_context)
                {
                    Aborted = true
                };

                return(true);
            }
Example #8
0
        private FluentResults.Result MergeContext(TxnContext srcContext)
        {
            if (srcContext == null)
            {
                return(Results.Ok());
            }

            if (Context.StartTs == 0)
            {
                Context.StartTs = srcContext.StartTs;
            }

            if (Context.StartTs != srcContext.StartTs)
            {
                return(Results.Fail(new StartTsMismatch()));
            }

            Context.Keys.Add(srcContext.Keys);
            Context.Preds.Add(srcContext.Preds);

            return(Results.Ok());
        }
Example #9
0
        private FluentResults.Result MergeContext(TxnContext srcContext)
        {
            if (context == null)
            {
                return(Results.Ok());
            }

            MergeLinReads(context.LinRead, srcContext.LinRead);
            client.MergeLinRead(srcContext.LinRead);

            if (context.StartTs == 0)
            {
                context.StartTs = srcContext.StartTs;
            }

            if (context.StartTs != srcContext.StartTs)
            {
                return(Results.Fail(new StartTsMismatch()));
            }

            context.Keys.Add(srcContext.Keys);

            return(Results.Ok());
        }
Example #10
0
        internal void Discard(TxnContext context)
        {
            AssertNotDisposed();

            connections.Values.ElementAt(rnd.Next(connections.Count)).Discard(context);
        }
Example #11
0
        public async Task Discard(TxnContext context)
        {
            AssertNotDisposed();

            await connections[GetNextConnection()].Discard(context);
        }
Example #12
0
        public async Task Commit(TxnContext context)
        {
            AssertNotDisposed();

            await connections[GetNextConnection()].Commit(context);
        }
Example #13
0
 public Transaction(Dgraph.DgraphClient client, TxnContext context, bool readOnly)
 {
     this.client   = client;
     this.context  = context;
     this.readOnly = readOnly;
 }
Example #14
0
        public async Task Discard(TxnContext context)
        {
            AssertNotDisposed();

            await connection.CommitOrAbortAsync(context);
        }
Example #15
0
        public void Discard(TxnContext context)
        {
            AssertNotDisposed();

            connection.CommitOrAbort(context);
        }