Hey guys, I’ve a question related to some of the G...
# help
j
Hey guys, I’ve a question related to some of the Go sample code for instantiating a connection to cerbos. I have a gin based API that will use cerbos under the hood and I’m not sure if the go sdk client can be a singleton or not
Copy code
crb, err := cerbos.New(c.CerbosAPI, cerbos.WithPlaintext())
I’m wondering if I can instantiate this in main and treat the
*cerbos.GRPCClient
pointer as a singleton (add it to my handler struct) or would it be better to instantiate it prior to each call to
IsAllowed
or whatever ( which makes testing a bit tricker)?
o
Hi @Joe Cantwell, Creating a single instance with the
cerbos.New
and re-using it more than once is OK, and recommended.
1
gratitude thank you 1