dao.go 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/passport/conf"
  5. "go-common/library/database/hbase.v2"
  6. )
  7. // Dao struct answer history of Dao
  8. type Dao struct {
  9. c *conf.Config
  10. hbase *hbase.Client
  11. loginLogHBase *hbase.Client
  12. pwdLogHBase *hbase.Client
  13. }
  14. // New new a Dao and return.
  15. func New(c *conf.Config) (d *Dao) {
  16. var loginLogHBase *hbase.Client
  17. if c.Switch.LoginLogHBase {
  18. loginLogHBase = hbase.NewClient(c.HBase.LoginLog.Config)
  19. }
  20. d = &Dao{
  21. c: c,
  22. hbase: hbase.NewClient(c.HBase.FaceApply.Config),
  23. loginLogHBase: loginLogHBase,
  24. pwdLogHBase: hbase.NewClient(c.HBase.PwdLog.Config),
  25. }
  26. return
  27. }
  28. // Close close connections.
  29. func (d *Dao) Close() {
  30. if d.hbase != nil {
  31. d.hbase.Close()
  32. }
  33. if d.loginLogHBase != nil {
  34. d.loginLogHBase.Close()
  35. }
  36. if d.pwdLogHBase != nil {
  37. d.pwdLogHBase.Close()
  38. }
  39. }
  40. // Ping ping health.
  41. func (d *Dao) Ping(c context.Context) (err error) {
  42. return
  43. }