Best practices for single connection, multiple client, and auto reconnection?


i would like to followup on my issue here:

so i can use only 1 single connection and create client from the connection for each http handler right?
and what if dgraph was restarted? does it auto reconnect? or i have to also restart my web instance if i connect only when i start the server?

Do you mean every http endpoint created by different Dgraph Servers? by offset. Or separate each operation (mutation, query, drop_all, commit, alter and so on) per client? I think the answer is yes to all.

The client will certainly connect when the instance is ready.

I do not think so, but it will subtly connect when there is an DB instance ready. For each request the Client will return an error. If you make a new request, it will make a new connection as soon as it is available.

yes, i mean every handler call, means every request.
should i do grpc connect for every instant of request?
because my concern is, if dont grpc connect, if dgraph is down or restarted, will it reconnect

Not sure if I get the whole concept of your question, but are you having any connection problems?

im not having any right now.
okay in my go code,

i initiate a grpc connection to dgraph,

then in each handler, example:

http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		//initiate client with grpc connection from main

my question is, since my grpc is initiated outside of handler, if i restart dgraph, will it havae connection issue in my web server? that i need to also restart my web server?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.