apply.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package canal
  2. import (
  3. "go-common/library/time"
  4. )
  5. //type and explanation
  6. const (
  7. TypeApply = int8(iota)
  8. TypeReview
  9. ReviewReject
  10. ReviewSuccess
  11. ReviewFailed
  12. )
  13. //TypeMap struct
  14. var (
  15. TypeMap = map[int8]string{
  16. TypeApply: "申请",
  17. TypeReview: "审核",
  18. ReviewReject: "驳回",
  19. ReviewSuccess: "通过",
  20. ReviewFailed: "失败",
  21. }
  22. )
  23. // TableName case tablename
  24. func (*Apply) TableName() string {
  25. return "canal_apply"
  26. }
  27. //Apply apply model
  28. type Apply struct {
  29. ID int `gorm:"column:id" json:"id"`
  30. Addr string `gorm:"column:addr" json:"addr"`
  31. Remark string `gorm:"column:remark" json:"remark"`
  32. Cluster string `gorm:"column:cluster" json:"project"`
  33. Leader string `gorm:"column:leader" json:"leader"`
  34. Comment string `gorm:"column:comment" json:"comment"`
  35. State int8 `gorm:"column:state" json:"status"`
  36. Operator string `gorm:"column:operator" json:"operator"`
  37. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  38. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  39. ConfID int `gorm:"column:conf_id" json:"conf_id"`
  40. }
  41. //Config struct
  42. type Config struct {
  43. Instance *Instance `json:"instance" toml:"instance"`
  44. }
  45. //Instance struct
  46. type Instance struct {
  47. Caddr string `json:"caddr" toml:"addr"`
  48. User string `json:"user" toml:"user"`
  49. Password string `json:"password" toml:"password"`
  50. MonitorPeriod string `json:"monitor_period" toml:"monitor_period,omitempty"`
  51. ServerID int64 `json:"server_id" toml:"server_id"`
  52. Flavor string `json:"flavor" toml:"flavor"`
  53. HeartbeatPeriod time.Duration `json:"heartbeat_period" toml:"heartbeat_period"`
  54. ReadTimeout time.Duration `json:"read_timeout" toml:"read_timeout"`
  55. DB []*DB `json:"db" toml:"db"`
  56. }
  57. //DB struct
  58. type DB struct {
  59. Schema string `json:"schema" toml:"schema"`
  60. Table []*Table `json:"table" toml:"table"`
  61. Databus *Databus `json:"databus" toml:"databus"`
  62. Infoc *Infoc `json:"infoc" toml:"infoc"`
  63. }
  64. //Table struct
  65. type Table struct {
  66. Name string `json:"name" toml:"name"`
  67. Primarykey []string `json:"primarykey" toml:"primarykey"`
  68. Omitfield []string `json:"omitfield" toml:"omitfield"`
  69. }
  70. //Databus struct
  71. type Databus struct {
  72. Key string `json:"key" toml:"key"`
  73. Secret string `json:"secret" toml:"secret"`
  74. Group string `json:"group" toml:"group"`
  75. Topic string `json:"topic" toml:"topic"`
  76. Action string `json:"action" toml:"action"`
  77. Name string `json:"name" toml:"name"`
  78. Proto string `json:"proto" toml:"proto"`
  79. Addr string `json:"addr" toml:"addr"`
  80. Idle int `json:"idle" toml:"idle"`
  81. Active int `json:"active" toml:"active"`
  82. DialTimeout string `json:"dialTimeout" toml:"dialTimeout"`
  83. ReadTimeout string `json:"readTimeout" toml:"readTimeout"`
  84. WriteTimeout string `json:"writeTimeout" toml:"writeTimeout"`
  85. IdleTimeout string `json:"idleTimeout" toml:"idleTimeout"`
  86. }
  87. //Infoc struct
  88. type Infoc struct {
  89. TaskID string `json:"taskID" toml:"taskID"`
  90. Proto string `json:"proto" toml:"proto"`
  91. Addr string `json:"addr" toml:"addr"`
  92. ReporterAddr string `json:"reporterAddr" toml:"reporterAddr"`
  93. }
  94. //ConfigReq struct is
  95. type ConfigReq struct {
  96. Addr string `form:"addr" validate:"required"`
  97. User string `form:"user"`
  98. Password string `form:"password"`
  99. MonitorPeriod string `form:"monitor_period"`
  100. Databases string `form:"databases" validate:"required"`
  101. Project string `form:"project"`
  102. Leader string `form:"leader"`
  103. Mark string `form:"mark" validate:"required"`
  104. }