public DgraphClient(params GrpcChannel[] channels) { foreach (var chan in channels) { Api.Dgraph.DgraphClient client = new Api.Dgraph.DgraphClient(chan); dgraphs.Add(client); } }
/// <remarks> /// Pre : <c>channel != null</c> <c>connection != null</c> and /// this is the channel used to make the connection. /// </remarks> public GRPCConnection(Channel channel, Api.Dgraph.DgraphClient connection) { Debug.Assert(channel != null); Debug.Assert(connection != null); this.channel = channel; this.connection = connection; }
/// <remarks> /// Pre : <c>channel != null</c> <c>connection != null</c> and /// this is the channel used to make the connection. /// </remarks> public GRPCConnection(Channel channel, Api.Dgraph.DgraphClient connection) { Debug.Assert(channel != null); Debug.Assert(connection != null); this.channel = channel; this.connection = connection; LastKnownStatus = Status.DefaultSuccess; }
/// <summary>Connect on the given address. I don't think this fails?? /// on bad addresses grpc still returns a connection, but will throw /// exception on use. </summary> /// <remarks>Pre : <c>!string.IsNullOrEmpty(address)</c>. </remarks> public virtual bool TryConnect(string address, out IGRPCConnection connection) { Debug.Assert(!string.IsNullOrEmpty(address)); try { Channel channel = new Channel(address, ChannelCredentials.Insecure); Api.Dgraph.DgraphClient client = new Api.Dgraph.DgraphClient(channel); connection = new GRPCConnection(channel, client); return(true); } catch (RpcException) { // FIXME: log this. If I ever get this error, then I might // need to do more here to return that error to the client. // actually use the error type } connection = null; return(false); }