binlog.go 932 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package binlog
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. )
  6. // BinlogFormatStruct
  7. // @Description: 数据库的binlog格式
  8. type BinlogFormatStruct struct {
  9. VariableName string `orm:"column(Variable_name)"`
  10. Value string `orm:"column(Value)"`
  11. }
  12. // GetBinlogFormat
  13. // @Description: 获取数据库的binlog格式
  14. // @return item
  15. // @return err
  16. func GetBinlogFormat() (item *BinlogFormatStruct, err error) {
  17. o := global.DbMap[utils.DbNameIndex]
  18. sql := `SHOW VARIABLES LIKE 'binlog_format'`
  19. err = o.Raw(sql).First(&item).Error
  20. return
  21. }
  22. type BinlogFileStruct struct {
  23. File string `orm:"column(File)"`
  24. Position uint32 `orm:"column(Position)"`
  25. }
  26. // GetShowMaster
  27. // @Description: 获取master的状态
  28. // @return item
  29. // @return err
  30. func GetShowMaster() (item *BinlogFileStruct, err error) {
  31. o := global.DbMap[utils.DbNameIndex]
  32. sql := `show master status`
  33. err = o.Raw(sql).First(&item).Error
  34. return
  35. }