cluster.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Package trace contains all the types provided for tracing within the radix
  2. // package. With tracing a user is able to pull out fine-grained runtime events
  3. // as they happen, which is useful for gathering metrics, logging, performance
  4. // analysis, etc...
  5. //
  6. // BIG LOUD DISCLAIMER DO NOT IGNORE THIS: while the main radix package is
  7. // stable and will always remain backwards compatible, trace is still under
  8. // active development and may undergo changes to its types and other features.
  9. // The methods in the main radix package which invoke trace types are guaranteed
  10. // to remain stable.
  11. package trace
  12. ////////////////////////////////////////////////////////////////////////////////
  13. type ClusterTrace struct {
  14. // StateChange is called when the cluster becomes down or becomes available again.
  15. StateChange func(ClusterStateChange)
  16. // TopoChanged is called when the cluster's topology changed.
  17. TopoChanged func(ClusterTopoChanged)
  18. // Redirected is called when radix.Do responded 'MOVED' or 'ASKED'.
  19. Redirected func(ClusterRedirected)
  20. }
  21. type ClusterStateChange struct {
  22. IsDown bool
  23. }
  24. type ClusterNodeInfo struct {
  25. Addr string
  26. Slots [][2]uint16
  27. IsPrimary bool
  28. }
  29. type ClusterTopoChanged struct {
  30. Added []ClusterNodeInfo
  31. Removed []ClusterNodeInfo
  32. Changed []ClusterNodeInfo
  33. }
  34. type ClusterRedirected struct {
  35. Addr string
  36. Key string
  37. Moved, Ask bool
  38. RedirectCount int
  39. // If true, then the MOVED/ASK error which was received will not be honored,
  40. // and the call to Do will be returning the MOVED/ASK error.
  41. Final bool
  42. }