config_attrs.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package model
  2. // SQLAttrs get attrs from db
  3. type SQLAttrs struct {
  4. AppID string
  5. DBName string
  6. ESName string
  7. DtbName string
  8. TablePrefix string
  9. TableFormat string
  10. IndexAliasPrefix string //写和读数据时,指向的索引。是别名索引
  11. IndexVersion string //创建索引时,指向的索引。这里是实体索引版本号
  12. IndexFormat string
  13. IndexType string
  14. IndexID string
  15. IndexMapping string
  16. DataIndexSuffix string
  17. DataExtraInfo string
  18. ReviewNum int64
  19. ReviewTime int64
  20. Sleep float64
  21. Size int
  22. Business string
  23. DataFields string
  24. SQLByID string
  25. SQLByMTime string
  26. SQLByIDMTime string
  27. DatabusInfo string
  28. DatabusIndexID string
  29. }
  30. // Attrs parse AppAttrs
  31. type Attrs struct {
  32. Business string
  33. AppID string
  34. DBName string
  35. ESName string
  36. DtbName string
  37. Table *AttrTable
  38. Index *AttrIndex
  39. DataSQL *AttrDataSQL
  40. DataExtras []AttrDataExtra //appID需要关联其他库的数据
  41. Databus *AttrDatabus
  42. Other *AttrOther
  43. }
  44. // AttrTable .
  45. type AttrTable struct {
  46. TablePrefix string
  47. TableFormat string
  48. TableSplit string
  49. TableFrom int
  50. TableTo int
  51. TableZero string
  52. TableFixed bool
  53. }
  54. // AttrIndex .
  55. type AttrIndex struct {
  56. IndexAliasPrefix string //写和读数据时,指向的索引。是别名索引
  57. IndexEntityPrefix string //创建索引时,指向的索引。是实体索引名
  58. IndexFormat string
  59. IndexSplit string
  60. IndexFrom int
  61. IndexTo int
  62. IndexType string
  63. IndexID string
  64. IndexMapping string
  65. IndexZero string
  66. IndexFixed bool
  67. }
  68. // AttrDataSQL .
  69. type AttrDataSQL struct {
  70. DataIndexSuffix string //索引数据归属
  71. DataFields string
  72. DataFieldsV2 map[string]AttrDataFields //存放json转换得到的data_fields字段信息, 替换老的DataFields
  73. DataIndexFields []string //来自DataFields左数第一位
  74. DataIndexRemoveFields []string //ES需要移除的字段
  75. DataIndexFormatFields map[string]string //ES每个字段的格式化,如int64,time,int等
  76. DataDtbFields map[string][]string //databus的字段对应的es字段, TODO 改成 map[string]map[string]bool 或 map[string][]string,应对一个数据库字段用在多个es字段
  77. DataExtraInfo string
  78. SQLFields string //来自DataFields左数第二位,含表名和字段的alias以及mysql函数等其他表达式
  79. SQLByID string //因为有left join的缘故,顾提供完整sql(抛除字段部分,下同)
  80. SQLByMTime string
  81. SQLByIDMTime string
  82. }
  83. // AttrDataFields .
  84. type AttrDataFields struct {
  85. ESField string `json:"es"`
  86. Field string `json:"field"`
  87. SQL string `json:"sql"`
  88. Expect string `json:"expect"`
  89. Stored string `json:"stored"`
  90. InDtb string `json:"in_dtb"`
  91. }
  92. // AttrDataExtra .
  93. type AttrDataExtra struct {
  94. Type string `json:"type"`
  95. Tag string `json:"tag"`
  96. Condition map[string]string `json:"condition"`
  97. SliceField string `json:"slice_field"` // 逗号分隔,支持多个字段
  98. DBName string `json:"dbname"`
  99. Table string `json:"table"`
  100. TableFormat string `json:"table_format"`
  101. InField string `json:"in_field"`
  102. FieldsStr string `json:"fields_str"`
  103. Fields []string `json:"fields"`
  104. RemoveFields []string `json:"remove_fields"`
  105. SQL string `json:"sql"`
  106. }
  107. // AttrDatabus .
  108. type AttrDatabus struct {
  109. DatabusInfo string
  110. Ticker int // 定时时间(毫秒)
  111. AggCount int // 聚合数量
  112. Databus string // databus Map key
  113. PrimaryID string // 主表索引id
  114. RelatedID string // 关联表索引id
  115. }
  116. // AttrOther .
  117. type AttrOther struct {
  118. ReviewNum int64
  119. ReviewTime int64
  120. Sleep float64
  121. Size int
  122. }