Error handling grpc

Hi everybody

I’m developing a web server that has a part grpc server. So far everything is working fine. I’m able to recover from a panic if it happens.

Because I don’t want to establish a db-connection every time a request comes in, i have one db-connection for the server-instance. What if the db-connection closes? The panics in the grpc-functions will recover itself but the db-connection won’t be established again.

What are good patterns to handle this?

We need more information to understand the problem:

If what happens?

What do you mean by a “db-connection?” Is it a *sql.DB or a *sql.Conn or something else? What do you mean by “for the server-instance?” Do you mean you have a global variable?

Thanks for your reply. The question was not well formulated:

I guess my question is how to handle db-connections on errors but the sql.DB struct already handles this I found out…

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