ht_biz_config.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package config
  2. import "eta/eta_mini_ht_api/common/contants"
  3. // ESOpts es连接属性
  4. type HTOpts struct {
  5. ReportIndex string
  6. MediaIndex string
  7. Encode string
  8. DesCode string
  9. Task string
  10. }
  11. type HTBizConfig struct {
  12. BaseConfig
  13. opts HTOpts
  14. }
  15. func (e *HTBizConfig) GetReportIndex() string {
  16. return e.opts.ReportIndex
  17. }
  18. func (e *HTBizConfig) GetMediaIndex() string {
  19. return e.opts.MediaIndex
  20. }
  21. func (e *HTBizConfig) NeedEncode() bool {
  22. if e.opts.Encode == "true" {
  23. return true
  24. }
  25. return false
  26. }
  27. func (e *HTBizConfig) EnableTask() bool {
  28. if e.opts.Task == "true" {
  29. return true
  30. }
  31. return false
  32. }
  33. func (e *HTBizConfig) GetDesCode() string {
  34. return e.opts.DesCode
  35. }
  36. func (e *HTBizConfig) InitConfig() {
  37. opts := HTOpts{
  38. ReportIndex: e.GetString("es_report_index"),
  39. MediaIndex: e.GetString("es_media_index"),
  40. Encode: e.GetString("response.encode"),
  41. DesCode: e.GetString("response.des_code"),
  42. Task: e.GetString("task"),
  43. }
  44. e.opts = opts
  45. }
  46. func NewHT() Config {
  47. return &HTBizConfig{
  48. BaseConfig: BaseConfig{prefix: contants.HT},
  49. opts: HTOpts{},
  50. }
  51. }
  52. func init() {
  53. Register(contants.HT, NewHT)
  54. }