overlord.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package model
  2. // OverlordReq .
  3. type OverlordReq struct {
  4. Name string `json:"name" form:"name"`
  5. Zone string `json:"zone" form:"zone"`
  6. Type string `json:"type" form:"type"`
  7. Alias string `json:"alias" form:"alias"`
  8. Addr string `json:"addr" form:"addr"`
  9. AppID string `json:"appid" form:"appid"`
  10. PN int `form:"pn" default:"1"`
  11. PS int `form:"ps" default:"20"`
  12. Cookie string `json:"-"`
  13. }
  14. // OverlordResp .
  15. type OverlordResp struct {
  16. Names []string `json:"names,omitempty"`
  17. Addrs []string `json:"addrs,omitempty"`
  18. Cluster *OverlordCluster `json:"cluster,omitempty"`
  19. Clusters []*OverlordCluster `json:"clusters,omitempty"`
  20. Total int64 `json:"total"`
  21. Nodes []*OverlordNode `json:"nodes,omitempty"`
  22. Apps []*OverlordApp `json:"apps,omitempty"`
  23. AppIDs []string `json:"appids,omitempty"`
  24. }
  25. // TableName gorm table name.
  26. func (*OverlordCluster) TableName() string {
  27. return "overlord_cluster"
  28. }
  29. // OverlordCluster .
  30. type OverlordCluster struct {
  31. ID int64 `json:"id" gorm:"column:id"`
  32. Name string `json:"name" gorm:"column:name"` // 集群名字
  33. Type string `json:"type" gorm:"column:type"` // 缓存类型. (memcache,redis,redis-cluster)
  34. Zone string `json:"zone" gorm:"column:zone"` // 机房
  35. HashMethod string `json:"hash_method" gorm:"column:hash_method"` // 哈希方法 默认sha1
  36. HashDistribution string `json:"hash_distribution" gorm:"column:hash_distribution"` // key分布策略 默认为ketama一致性hash
  37. HashTag string `json:"hash_tag" gorm:"column:hashtag"` // key hash 标识
  38. ListenProto string `json:"listen_proto" gorm:"column:listen_proto"`
  39. ListenAddr string `json:"listen_addr" gorm:"column:listen_addr"`
  40. DailTimeout int32 `json:"dail_timeout" gorm:"column:dial"` // dial 超时
  41. ReadTimeout int32 `json:"read_timeout" gorm:"column:read"` // read 超时
  42. WriteTimeout int32 `json:"write_timeout" gorm:"column:write"` // write 超时
  43. NodeConn int8 `json:"node_conn" gorm:"column:nodeconn"` // 集群内节点连接数
  44. PingFailLimit int32 `json:"ping_fail_limit" gorm:"column:ping_fail_limit"` // 节点失败检测次数
  45. PingAutoEject bool `json:"ping_auto_eject" gorm:"column:auto_eject"` // 是否自动剔除节点
  46. Nodes []*OverlordNode `json:"nodes" gorm:"-"`
  47. }
  48. // TableName gorm table name.
  49. func (*OverlordNode) TableName() string {
  50. return "overlord_node"
  51. }
  52. // OverlordNode .
  53. type OverlordNode struct {
  54. Cid int64 `json:"cid" gorm:"column:cid"`
  55. Alias string `json:"alias" gorm:"column:alias"`
  56. Addr string `json:"addr" gorm:"column:addr"`
  57. Weight int8 `json:"weight" gorm:"column:weight"`
  58. }
  59. // TableName gorm table name.
  60. func (*OverlordApp) TableName() string {
  61. return "overlord_appid"
  62. }
  63. // OverlordApp .
  64. type OverlordApp struct {
  65. ID int64 `json:"-" gorm:"column:id"`
  66. TreeID int64 `json:"treeid" gorm:"column:tree_id"`
  67. AppID string `json:"appid" gorm:"column:app_id"`
  68. Cid int64 `json:"cid" gorm:"column:cid"`
  69. Cluster *OverlordCluster `json:"cluster,omitempty"`
  70. }
  71. // OverlordApiserver resp result of clusters.
  72. type OverlordApiserver struct {
  73. Group string `json:"group"`
  74. Clusters []struct {
  75. Name string `json:"name"`
  76. Type string `json:"cache_type"`
  77. // HashMethod string `json:"hash_method"`
  78. // HashDistribution string `json:"hash_distribution"`
  79. // HashTag string `json:"hash_tag"`
  80. // DailTimeout int32 `json:"dail_timeout"`
  81. // ReadTimeout int32 `json:"read_timeout"`
  82. // WriteTimeout int32 `json:"write_timeout"`
  83. // NodeConn int8 `json:"node_connections"`
  84. // PingFailLimit int32 `json:"ping_fail_limit"`
  85. // PingAutoEject bool `json:"ping_auto_eject"`
  86. FrontEndPort int `json:"front_end_port"`
  87. Instances []struct {
  88. IP string `json:"ip"`
  89. Port int `json:"port"`
  90. Weight int8 `json:"weight"`
  91. Alias string `json:"alias"`
  92. State string `json:"state"`
  93. Role string `json:"role"`
  94. } `json:"instances"`
  95. } `json:"clusters"`
  96. }
  97. // OverlordToml resp result of clusters.
  98. type OverlordToml struct {
  99. Name string `toml:"name"`
  100. Type string `toml:"cache_type"`
  101. HashMethod string `toml:"hash_method"`
  102. HashDistribution string `toml:"hash_distribution"`
  103. HashTag string `toml:"hash_tag"`
  104. DailTimeout int32 `toml:"dail_timeout"`
  105. ReadTimeout int32 `toml:"read_timeout"`
  106. WriteTimeout int32 `toml:"write_timeout"`
  107. NodeConn int8 `toml:"node_connections"`
  108. PingFailLimit int32 `toml:"ping_fail_limit"`
  109. PingAutoEject bool `toml:"ping_auto_eject"`
  110. ListenProto string `toml:"listen_proto"`
  111. ListenAddr string `toml:"listen_addr"`
  112. Servers []string `toml:"servers"`
  113. }