github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/libnetwork/discoverapi/discoverapi.go (about)

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