github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/pkg/util/identity.go (about)

     1  // Copyright 2020 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 util
    15  
    16  // Role is the operator role, mainly used for logging at the moment.
    17  type Role int
    18  
    19  const (
    20  	// RoleController is the server manager.
    21  	RoleController Role = iota
    22  	// RoleOwner is the owner of the cluster.
    23  	RoleOwner
    24  	// RoleProcessor is the processor of the cluster.
    25  	RoleProcessor
    26  	// RoleClient is the client.
    27  	RoleClient
    28  	// RoleRedoLogApplier is the redo log applier.
    29  	RoleRedoLogApplier
    30  	// RoleKafkaConsumer is the kafka consumer.
    31  	RoleKafkaConsumer
    32  	// RoleTester for test.
    33  	RoleTester
    34  	// RoleUnknown is the unknown role.
    35  	RoleUnknown
    36  )
    37  
    38  func (r Role) String() string {
    39  	switch r {
    40  	case RoleController:
    41  		return "server-manager"
    42  	case RoleOwner:
    43  		return "owner"
    44  	case RoleProcessor:
    45  		return "processor"
    46  	case RoleClient:
    47  		return "cdc-client"
    48  	case RoleKafkaConsumer:
    49  		return "kafka-consumer"
    50  	case RoleRedoLogApplier:
    51  		return "redo-applier"
    52  	case RoleTester:
    53  		return "tester"
    54  	case RoleUnknown:
    55  		return "unknown"
    56  	}
    57  	return "unknown"
    58  }