internal Transaction(DgraphClient client) { this.client = client; context = new TxnContext(); context.LinRead = client.GetLinRead(); }
public void Setup() { var connectionFactory = Substitute.For <IGRPCConnectionFactory>(); transactionFactory = Substitute.For <ITransactionFactory>(); client = new DgraphClient(connectionFactory, transactionFactory); }
public async Task <IDgraphClient> GetDgraphClient() { // FIXME: This is not what you'd want to do in a real app. Normally, there // would be tls to the server. TO ADD - tests of running over https, and // with a Dgraph tls client certificate, and in enterprise mode. AppContext.SetSwitch( "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); var client = new DgraphClient(GrpcChannel.ForAddress("http://127.0.0.1:9080")); if (!printed) { var result = await client.CheckVersion(); if (result.IsSuccess) { Log.Information("Connected to Dgraph version {Version}", result.Value); } else { Log.Information("Failed to get Dgraph version {Error}", result); } printed = true; } return(client); }
static void Main(string[] args) { var client = new DgraphClient(Grpc.Net.Client.GrpcChannel.ForAddress(new Uri("http://127.0.0.1:8000"))); using (var txn = client.NewTransaction()) { var alice = new Person { Name = "Alice" }; var json = JsonConvert.SerializeObject(alice); var transactionResult = txn.Mutate(new RequestBuilder().WithMutations(new MutationBuilder { SetJson = json })).Result; } var schema = "`name: string @index(exact) ."; var result = client.Alter(new Operation { Schema = schema }); }
/// <summary> /// Creates a new gRPC connection to a Dgraph server with the specified channel. /// </summary> /// <param name="channel">A configured gRPC channel.</param> public DgraphConnection(Channel channel) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); _client = new DgraphClient(channel); }
public ITransaction NewTransaction(DgraphClient client) { return(new Transaction(client)); }