github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/common/types.go (about) 1 /* 2 Copyright (C) 2022-2023 ApeCloud Co., Ltd 3 4 This file is part of KubeBlocks project 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Affero General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package common 21 22 // PodRoleNamePair defines a pod name and role name pair. 23 type PodRoleNamePair struct { 24 PodName string `json:"podName,omitempty"` 25 RoleName string `json:"roleName,omitempty"` 26 } 27 28 // GlobalRoleSnapshot defines a global(leader) perspective of all pods role. 29 // KB provides two role probe methods: per-pod level role probe and retrieving all node roles from the leader node. 30 // The latter is referred to as the global role snapshot. This data structure is used to represent a snapshot of global role information. 31 // The snapshot contains two types of information: the mapping relationship between all node names and role names, 32 // and the version of the snapshot. The purpose of the snapshot version is to ensure that only role information 33 // that is more up-to-date than the current role information on the Pod Label will be updated. This resolves the issue of 34 // role information disorder in scenarios such as KB upgrades or exceptions causing restarts, 35 // network partitioning leading to split-brain situations, node crashes, and similar occurrences. 36 type GlobalRoleSnapshot struct { 37 Version string `json:"term,omitempty"` 38 PodRoleNamePairs []PodRoleNamePair `json:"PodRoleNamePairs,omitempty"` 39 } 40 41 // BuiltinHandler defines builtin role probe handler name. 42 type BuiltinHandler string 43 44 const ( 45 MySQLHandler BuiltinHandler = "mysql" 46 PostgresHandler BuiltinHandler = "postgres" 47 MongoDBHandler BuiltinHandler = "mongodb" 48 RedisHandler BuiltinHandler = "redis" 49 ETCDHandler BuiltinHandler = "etcd" 50 KafkaHandler BuiltinHandler = "kafka" 51 WeSQLHandler BuiltinHandler = "wesql" 52 )