notify.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package model
  2. import (
  3. "net/url"
  4. "time"
  5. )
  6. // Watcher define watcher object.
  7. type Watcher struct {
  8. ID int64
  9. Cluster string
  10. Topic string
  11. Group string
  12. Offset string
  13. Callback string
  14. Callbacks []*Callback
  15. Filter bool
  16. Filters []*Filter
  17. Concurrent int // concurrent goroutine for sub.
  18. Mtime time.Time
  19. }
  20. // Pub define pub.
  21. type Pub struct {
  22. ID int64
  23. Cluster string
  24. Topic string
  25. Group string
  26. Operation int8
  27. AppSecret string
  28. }
  29. // Callback define callback event
  30. type Callback struct {
  31. URL *NotifyURL
  32. Priority int8
  33. Finished bool
  34. }
  35. // NotifyURL callback url with parsed info
  36. type NotifyURL struct {
  37. RawURL string
  38. Schema string
  39. Host string
  40. Path string
  41. Query url.Values
  42. }
  43. // filter condition
  44. const (
  45. ConditionEq = 0
  46. ConditionPre = 1
  47. )
  48. // Filter define filter object.
  49. type Filter struct {
  50. Field string
  51. Condition int8 // 0 :eq 1:neq
  52. Value string
  53. }
  54. // Message define canal message.
  55. type Message struct {
  56. Table string `json:"table,omitempty"`
  57. Action string `json:"action,omitempty"`
  58. }
  59. // ArgPub pub arg.
  60. type ArgPub struct {
  61. AppKey string `form:"appkey" validate:"min=1"`
  62. AppSecret string `form:"appsecret" validate:"min=1"`
  63. Group string `form:"group" validate:"min=1"`
  64. Topic string `form:"topic" validate:"min=1"`
  65. Key string `form:"key" validate:"min=1"`
  66. Msg string `form:"msg" validate:"min=1"`
  67. }
  68. // FailBackup fail backup msg.
  69. type FailBackup struct {
  70. ID int64
  71. Cluster string
  72. Topic string
  73. Group string
  74. Offset int64
  75. Msg string
  76. Index int64
  77. }
  78. // Notify callback schema
  79. const (
  80. LiverpcSchema = "liverpc"
  81. HTTPSchema = "http"
  82. )