github.com/portworx/kvdb@v0.0.0-20241107215734-a185a966f535/api/bootstrap/bootstrap.go (about)

     1  package api
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // BootstrapEntry identifies a node with its IP and ID which is part of a kvdb cluster
     8  type BootstrapEntry struct {
     9  	// IP of the kvdb node
    10  	IP string
    11  	// ID of the kvdb node
    12  	ID string
    13  	// Index of the kvdb node
    14  	Index int
    15  	// State indicates the state of the Node in the bootstrap state machine
    16  	State NodeState
    17  	// Type indicates the type of kvdb node
    18  	Type NodeType
    19  	// Ts is the last updated timestamp of this bootstrap entry
    20  	Ts time.Time
    21  	// Version DEPRECATED This will always be "v2" for backward compatibility. New code should use EntryVersion.
    22  	Version string
    23  	// EntryVersion is the bootstrap entry version
    24  	EntryVersion int
    25  	// used only for tests
    26  	// PeerPort is the peer port for kvdb node
    27  	PeerPort string `json:"peerport,omitempty"`
    28  	// ClientPort is the client port for kvdb node
    29  	ClientPort string `json:"clientport,omitempty"`
    30  	// Domain is the domain name advertised in the peer urls for this kvdb node
    31  	// The DomainName is only used for kvdb's peer urls.
    32  	// This enables us to change the actual peer IP being used by the nodes while keeping the domain
    33  	// name the same. The client url is always based of an IP.
    34  	Domain DomainName
    35  	// DataDirType is the type of data directory being used by internal kvdb on
    36  	// this node
    37  	DataDirType Type
    38  	// Filesystem UUID of the disk used by the kvdb node for it's db
    39  	DiskUUID string
    40  	// IsStorageless is set to true if the node is storageless
    41  	IsStorageless bool
    42  	// Zone is the zone of the node
    43  	Zone string
    44  }
    45  
    46  // NodeState is the state of a kvdb bootstrap node
    47  type NodeState int
    48  
    49  const (
    50  	// BootstrapNodeStateNone indicates the init/none state
    51  	BootstrapNodeStateNone NodeState = iota
    52  	// BootstrapNodeStateInProgress bootstrap is in progress
    53  	BootstrapNodeStateInProgress
    54  	// BootstrapNodeStateOperational kvdb node is operational
    55  	BootstrapNodeStateOperational
    56  	// BootstrapNodeStateSuspectDown node is down
    57  	BootstrapNodeStateSuspectDown
    58  )
    59  
    60  // NodeType is a type that identifies the bootstrap node type
    61  type NodeType int
    62  
    63  const (
    64  	// BootstrapNodeTypeNone in default none type
    65  	BootstrapNodeTypeNone NodeType = iota
    66  	// BootstrapNodeTypeLeader node is a kvdb cluster leader
    67  	BootstrapNodeTypeLeader
    68  	// BootstrapNodeTypeMember node is a kvdb cluster member
    69  	BootstrapNodeTypeMember
    70  )
    71  
    72  // Type of datadir
    73  type Type string
    74  
    75  // DomainName identifies the DNS name internal kvdb node will use in the peer urls
    76  type DomainName string
    77  
    78  const (
    79  	// MetadataDevice when using a metadata device for internal kvdb data
    80  	MetadataDevice Type = "MetadataDevice"
    81  	// KvdbDevice when using a dedicated kvdb device for internal kvdb data
    82  	KvdbDevice Type = "KvdbDevice"
    83  	// BtrfsSubvolume when using btrfs subvolume from PX data drives for internal kvdb data
    84  	BtrfsSubvolume Type = "BtrfsSubvolume"
    85  )