-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathinfo.go
109 lines (96 loc) · 3.25 KB
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2023 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package mtinfopb
import (
"fmt"
// We manually import this to satisfy a dependency in info.proto.
_ "github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb"
)
// TenantServiceMode describes how tenants can be served to clients.
type TenantServiceMode uint8
// Note: the constant values below are stored in system.tenants.service_mode.
const (
// ServiceModeExternal says that service is allowed using
// separate processes.
// This is the default value for backward-compatibility with
// records created for CockroachCloud Serverless pre-v23.1.
ServiceModeExternal TenantServiceMode = 0
// ServiceModeNode says that no service is allowed.
ServiceModeNone TenantServiceMode = 1
// ServiceModeShared says that service is allowed using shared-process
// multitenancy on KV nodes.
// This mode causes KV nodes to spontaneously start the SQL service
// for the tenant.
ServiceModeShared TenantServiceMode = 2
)
// String implements fmt.Stringer.
func (s TenantServiceMode) String() string {
switch s {
case ServiceModeExternal:
return "external"
case ServiceModeNone:
return "none"
case ServiceModeShared:
return "shared"
default:
return fmt.Sprintf("unimplemented-%d", int(s))
}
}
// TenantServiceModeValues facilitates the string -> TenantServiceMode conversion.
var TenantServiceModeValues = map[string]TenantServiceMode{
"external": ServiceModeExternal,
"none": ServiceModeNone,
"shared": ServiceModeShared,
}
// TenantDataState describes the state of a tenant's logical keyspace.
type TenantDataState uint8
// Note: the constant values below are stored in system.tenants.data_state.
const (
// DataStateReady indicates data is ready and SQL servers can access it.
DataStateReady TenantDataState = 0
// DataStateAdd indicates tenant data is being added. Not available
// for SQL sessions.
DataStateAdd TenantDataState = 1
// DataStateDrop indicates tenant data is being deleted. Not
// available for SQL sessions.
DataStateDrop TenantDataState = 2
)
// String implements fmt.Stringer.
func (s TenantDataState) String() string {
switch s {
case DataStateReady:
return "ready"
case DataStateAdd:
return "add"
case DataStateDrop:
return "drop"
default:
return fmt.Sprintf("unimplemented-%d", int(s))
}
}
// TenantDataStateValues facilitates the string -> TenantDataState conversion.
var TenantDataStateValues = map[string]TenantDataState{
"ready": DataStateReady,
"add": DataStateAdd,
"drop": DataStateDrop,
}
// ExtendedTenantInfo captures both a TenantInfo and the ExtraColumns
// that go alongside it.
type ExtendedTenantInfo struct {
TenantInfo
TenantInfoWithUsage_ExtraColumns
}
// ToExtended converts a TenantInfoWithUsage to an ExtendedTenantInfo.
func (m *TenantInfoWithUsage) ToExtended() *ExtendedTenantInfo {
return &ExtendedTenantInfo{
TenantInfo: m.TenantInfo,
TenantInfoWithUsage_ExtraColumns: m.TenantInfoWithUsage_ExtraColumns,
}
}