github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/model/cluster.go (about)

     1  // Copyright 2022 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package model
    15  
    16  // DeployNodeID means the identify of a node
    17  type DeployNodeID string
    18  
    19  // ExecutorID is an alias for executor when NodeType is NodeTypeExecutor.
    20  type ExecutorID = DeployNodeID
    21  
    22  // ExecutorStatus describes the node aliveness status of an executor
    23  type ExecutorStatus int32
    24  
    25  // All ExecutorStatus
    26  const (
    27  	Initing ExecutorStatus = iota
    28  	Running
    29  	Disconnected
    30  	Tombstone
    31  )
    32  
    33  // ExecutorStatusNameMapping maps from executor status to human-readable string
    34  var ExecutorStatusNameMapping = map[ExecutorStatus]string{
    35  	Initing:      "initializing",
    36  	Running:      "running",
    37  	Disconnected: "disconnected",
    38  	Tombstone:    "tombstone",
    39  }
    40  
    41  // String implements fmt.Stringer
    42  func (s ExecutorStatus) String() string {
    43  	val, ok := ExecutorStatusNameMapping[s]
    44  	if !ok {
    45  		return "unknown"
    46  	}
    47  	return val
    48  }
    49  
    50  // ExecutorStatusChangeType describes the types of ExecutorStatusChange.
    51  type ExecutorStatusChangeType string
    52  
    53  const (
    54  	// EventExecutorOnline indicates that an executor has gone online.
    55  	EventExecutorOnline = ExecutorStatusChangeType("online")
    56  	// EventExecutorOffline indicates that an executor has gone offline.
    57  	EventExecutorOffline = ExecutorStatusChangeType("offline")
    58  )
    59  
    60  // ExecutorStatusChange describes an event where an
    61  // executor's status has changed.
    62  type ExecutorStatusChange struct {
    63  	ID   ExecutorID
    64  	Tp   ExecutorStatusChangeType
    65  	Addr string
    66  }