-
Notifications
You must be signed in to change notification settings - Fork 269
/
sink_type.go
108 lines (96 loc) · 3.33 KB
/
sink_type.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
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package sink
import (
"net/url"
"strings"
)
// Type is the type of sink.
type Type int
const (
// RowSink is the type of row sink. It is used to sink row events.
RowSink Type = iota + 1
// TxnSink is the type of txn sink. It is used to sink txn events.
TxnSink
)
// String returns the string representation of the type.
func (t Type) String() string {
switch t {
case RowSink:
return "RowSink"
case TxnSink:
return "TxnSink"
}
panic("unknown sink type")
}
const (
// KafkaScheme indicates the scheme is kafka.
KafkaScheme = "kafka"
// KafkaSSLScheme indicates the scheme is kafka+ssl.
KafkaSSLScheme = "kafka+ssl"
// BlackHoleScheme indicates the scheme is blackhole.
BlackHoleScheme = "blackhole"
// MySQLScheme indicates the scheme is MySQL.
MySQLScheme = "mysql"
// MySQLSSLScheme indicates the scheme is MySQL+ssl.
MySQLSSLScheme = "mysql+ssl"
// TiDBScheme indicates the scheme is TiDB.
TiDBScheme = "tidb"
// TiDBSSLScheme indicates the scheme is TiDB+ssl.
TiDBSSLScheme = "tidb+ssl"
// S3Scheme indicates the scheme is s3.
S3Scheme = "s3"
// FileScheme indicates the scheme is local fs or NFS.
FileScheme = "file"
// GCSScheme indicates the scheme is gcs.
GCSScheme = "gcs"
// GSScheme is an alias for "gcs"
GSScheme = "gs"
// AzblobScheme indicates the scheme is azure blob storage.\
AzblobScheme = "azblob"
// AzureScheme is an alias for "azblob"
AzureScheme = "azure"
// CloudStorageNoopScheme indicates the scheme is noop.
CloudStorageNoopScheme = "noop"
// PulsarScheme indicates the scheme is pulsar
PulsarScheme = "pulsar"
// PulsarSSLScheme indicates the scheme is pulsar+ssl
PulsarSSLScheme = "pulsar+ssl"
)
// IsMQScheme returns true if the scheme belong to mq scheme.
func IsMQScheme(scheme string) bool {
return scheme == KafkaScheme || scheme == KafkaSSLScheme ||
scheme == PulsarScheme || scheme == PulsarSSLScheme
}
// IsMySQLCompatibleScheme returns true if the scheme is compatible with MySQL.
func IsMySQLCompatibleScheme(scheme string) bool {
return scheme == MySQLScheme || scheme == MySQLSSLScheme ||
scheme == TiDBScheme || scheme == TiDBSSLScheme
}
// IsStorageScheme returns true if the scheme belong to storage scheme.
func IsStorageScheme(scheme string) bool {
return scheme == FileScheme || scheme == S3Scheme || scheme == GCSScheme ||
scheme == GSScheme || scheme == AzblobScheme || scheme == AzureScheme || scheme == CloudStorageNoopScheme
}
// IsPulsarScheme returns true if the scheme belong to pulsar scheme.
func IsPulsarScheme(scheme string) bool {
return scheme == PulsarScheme || scheme == PulsarSSLScheme
}
// IsBlackHoleScheme returns true if the scheme belong to blackhole scheme.
func IsBlackHoleScheme(scheme string) bool {
return scheme == BlackHoleScheme
}
// GetScheme returns the scheme of the url.
func GetScheme(url *url.URL) string {
return strings.ToLower(url.Scheme)
}