You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

client_impl.go 939 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package client
  2. import (
  3. "gorm.io/driver/mysql"
  4. "gorm.io/gorm"
  5. "gorm.io/gorm/logger"
  6. "gorm.io/gorm/schema"
  7. "time"
  8. )
  9. type client struct {
  10. url string
  11. dataSource string
  12. DbEngin *gorm.DB
  13. }
  14. func (c *client) Task(options TaskOptions) (Task, error) {
  15. task, _ := newTask(c, &options)
  16. return task, nil
  17. }
  18. func (c *client) Notice(options NoticeOptions) (Notice, error) {
  19. notice, _ := newNotice(c, &options)
  20. return notice, nil
  21. }
  22. func newClient(options Options) (Client, error) {
  23. //init dbEngine
  24. dbEngin, _ := gorm.Open(mysql.Open(options.DataSource), &gorm.Config{
  25. NamingStrategy: schema.NamingStrategy{
  26. SingularTable: true,
  27. },
  28. Logger: logger.Default.LogMode(logger.Warn),
  29. })
  30. sqlDB, _ := dbEngin.DB()
  31. sqlDB.SetMaxIdleConns(10)
  32. sqlDB.SetMaxOpenConns(50)
  33. sqlDB.SetConnMaxLifetime(time.Hour)
  34. c := &client{
  35. url: options.Url,
  36. dataSource: options.DataSource,
  37. DbEngin: dbEngin,
  38. }
  39. return c, nil
  40. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.