dapr.go 448 B

12345678910111213141516171819202122232425262728
  1. package dapr_client
  2. var clientInstance *Client
  3. var clientTimeoutSec int64
  4. func InitDAPR(timeoutSec int64) {
  5. clientTimeoutSec = timeoutSec
  6. }
  7. func DestroyDAPR() {
  8. if clientInstance != nil {
  9. destroyClient(clientInstance)
  10. clientInstance = nil
  11. }
  12. }
  13. func GetInstance() *Client {
  14. if clientInstance == nil {
  15. client, err := newClient(clientTimeoutSec)
  16. if err != nil {
  17. return nil
  18. }
  19. clientInstance = client
  20. }
  21. return clientInstance
  22. }