示例#1
0
        public async Task <FluentResults.Result> Delete(string json)
        {
            AssertNotDisposed();

            var mut = new Api.Mutation();

            mut.DeleteJson = Google.Protobuf.ByteString.CopyFromUtf8(json);
            return((await Mutate(mut)).ToResult());
        }
示例#2
0
        public async Task <FluentResults.Result <IDictionary <string, string> > > Mutate(string json)
        {
            AssertNotDisposed();

            var mut = new Api.Mutation();

            mut.SetJson = Google.Protobuf.ByteString.CopyFromUtf8(json);
            return(await Mutate(mut));
        }
示例#3
0
        public FluentResults.Result Delete(string json)
        {
            AssertNotDisposed();

            var mut = new Api.Mutation();

            mut.DeleteJson = Google.Protobuf.ByteString.CopyFromUtf8(json);
            return(Mutate(mut).ConvertTo());
        }
示例#4
0
        internal FluentResults.Result <IDictionary <string, string> > Mutate(Api.Mutation mutation)
        {
            AssertNotDisposed();

            if (transactionState != TransactionState.OK)
            {
                return(Results.Fail <IDictionary <string, string> >(new TransactionFinished(transactionState.ToString())));
            }

            if (mutation.Del.Count == 0 &&
                mutation.DeleteJson.Length == 0 &&
                mutation.Set.Count == 0 &&
                mutation.SetJson.Length == 0)
            {
                return(Results.Ok <IDictionary <string, string> >(new Dictionary <string, string>()));
            }

            hasMutated = true;

            try {
                mutation.StartTs = context.StartTs;
                var assigned = client.Mutate(mutation);

                if (mutation.CommitNow)
                {
                    transactionState = TransactionState.Committed;
                }

                var err = MergeContext(assigned.Context);
                if (err.IsFailed)
                {
                    return(err.ConvertToResultWithValueType <IDictionary <string, string> >());
                }

                return(Results.Ok <IDictionary <string, string> >(assigned.Uids));
            } catch (RpcException rpcEx) {
                // From Dgraph code txn.go
                //
                // Since a mutation error occurred, the txn should no longer be used
                // (some mutations could have applied but not others, but we don't know
                // which ones).  Discarding the transaction enforces that the user
                // cannot use the txn further.
                Discard();                                 // Ignore error - user should see the original error.

                transactionState = TransactionState.Error; // overwrite the aborted value
                return(Results.Fail <IDictionary <string, string> >(new FluentResults.ExceptionalError(rpcEx)));
            }
        }
示例#5
0
        internal Assigned Mutate(Api.Mutation mut)
        {
            AssertNotDisposed();

            return(connections.Values.ElementAt(rnd.Next(connections.Count)).Mutate(mut));
        }
示例#6
0
        public async Task <Assigned> Mutate(Api.Mutation mut)
        {
            AssertNotDisposed();

            return(await connections[GetNextConnection()].Mutate(mut));
        }
示例#7
0
        public async Task <Assigned> Mutate(Api.Mutation mut)
        {
            AssertNotDisposed();

            return(await connection.MutateAsync(mut));
        }
示例#8
0
        public Assigned Mutate(Api.Mutation mut)
        {
            AssertNotDisposed();

            return(connection.Mutate(mut));
        }
示例#9
0
        public async Task <FluentResults.Result <IDictionary <string, string> > > ApiMutate(Api.Mutation mutation)
        {
            AssertNotDisposed();

            return(await Mutate(mutation));
        }