discoverapi.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package discoverapi
  2. // Discover is an interface to be implemented by the component interested in receiving discover events
  3. // like new node joining the cluster or datastore updates
  4. type Discover interface {
  5. // DiscoverNew is a notification for a new discovery event, Example:a new node joining a cluster
  6. DiscoverNew(dType DiscoveryType, data interface{}) error
  7. // DiscoverDelete is a notification for a discovery delete event, Example:a node leaving a cluster
  8. DiscoverDelete(dType DiscoveryType, data interface{}) error
  9. }
  10. // DiscoveryType represents the type of discovery element the DiscoverNew function is invoked on
  11. type DiscoveryType int
  12. const (
  13. // NodeDiscovery represents Node join/leave events provided by discovery
  14. NodeDiscovery = iota + 1
  15. // EncryptionKeysConfig represents the initial key(s) for performing datapath encryption
  16. EncryptionKeysConfig
  17. // EncryptionKeysUpdate represents an update to the datapath encryption key(s)
  18. EncryptionKeysUpdate
  19. )
  20. // NodeDiscoveryData represents the structure backing the node discovery data json string
  21. type NodeDiscoveryData struct {
  22. Address string
  23. BindAddress string
  24. Self bool
  25. }
  26. // DatastoreConfigData is the data for the datastore update event message
  27. type DatastoreConfigData struct {
  28. Scope string
  29. Provider string
  30. Address string
  31. Config interface{}
  32. }
  33. // DriverEncryptionConfig contains the initial datapath encryption key(s)
  34. // Key in first position is the primary key, the one to be used in tx.
  35. // Original key and tag types are []byte and uint64
  36. type DriverEncryptionConfig struct {
  37. Keys [][]byte
  38. Tags []uint64
  39. }
  40. // DriverEncryptionUpdate carries an update to the encryption key(s) as:
  41. // a new key and/or set a primary key and/or a removal of an existing key.
  42. // Original key and tag types are []byte and uint64
  43. type DriverEncryptionUpdate struct {
  44. Key []byte
  45. Tag uint64
  46. Primary []byte
  47. PrimaryTag uint64
  48. Prune []byte
  49. PruneTag uint64
  50. }