instance.go 760 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dps
  2. import (
  3. "git.sxidc.com/service-supports/dps-sdk/client"
  4. )
  5. var dpsClient client.Client
  6. func InitInstance(address string, clientVersion string, databaseID string) error {
  7. c, err := NewClient(address, clientVersion, databaseID)
  8. if err != nil {
  9. return err
  10. }
  11. dpsClient = c
  12. return nil
  13. }
  14. func DestroyInstance(clientVersion string, databaseID string) error {
  15. err := DestroyClient(clientVersion, databaseID)
  16. if err != nil {
  17. return err
  18. }
  19. return nil
  20. }
  21. func AutoMigrate(items ...client.AutoMigrateItem) error {
  22. if items == nil || len(items) == 0 {
  23. return nil
  24. }
  25. return dpsClient.AutoMigrate(&client.AutoMigrateRequest{Items: items})
  26. }
  27. func Transaction(txFunc client.TransactionFunc) error {
  28. return dpsClient.Transaction(txFunc)
  29. }