github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/pkg/sink/sink_type.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 sink 15 16 import ( 17 "net/url" 18 "strings" 19 ) 20 21 // Type is the type of sink. 22 type Type int 23 24 const ( 25 // RowSink is the type of row sink. It is used to sink row events. 26 RowSink Type = iota + 1 27 // TxnSink is the type of txn sink. It is used to sink txn events. 28 TxnSink 29 ) 30 31 // String returns the string representation of the type. 32 func (t Type) String() string { 33 switch t { 34 case RowSink: 35 return "RowSink" 36 case TxnSink: 37 return "TxnSink" 38 } 39 panic("unknown sink type") 40 } 41 42 const ( 43 // KafkaScheme indicates the scheme is kafka. 44 KafkaScheme = "kafka" 45 // KafkaSSLScheme indicates the scheme is kafka+ssl. 46 KafkaSSLScheme = "kafka+ssl" 47 // BlackHoleScheme indicates the scheme is blackhole. 48 BlackHoleScheme = "blackhole" 49 // MySQLScheme indicates the scheme is MySQL. 50 MySQLScheme = "mysql" 51 // MySQLSSLScheme indicates the scheme is MySQL+ssl. 52 MySQLSSLScheme = "mysql+ssl" 53 // TiDBScheme indicates the scheme is TiDB. 54 TiDBScheme = "tidb" 55 // TiDBSSLScheme indicates the scheme is TiDB+ssl. 56 TiDBSSLScheme = "tidb+ssl" 57 // S3Scheme indicates the scheme is s3. 58 S3Scheme = "s3" 59 // FileScheme indicates the scheme is local fs or NFS. 60 FileScheme = "file" 61 // GCSScheme indicates the scheme is gcs. 62 GCSScheme = "gcs" 63 // GSScheme is an alias for "gcs" 64 GSScheme = "gs" 65 // AzblobScheme indicates the scheme is azure blob storage.\ 66 AzblobScheme = "azblob" 67 // AzureScheme is an alias for "azblob" 68 AzureScheme = "azure" 69 // CloudStorageNoopScheme indicates the scheme is noop. 70 CloudStorageNoopScheme = "noop" 71 // PulsarScheme indicates the scheme is pulsar 72 PulsarScheme = "pulsar" 73 // PulsarSSLScheme indicates the scheme is pulsar+ssl 74 PulsarSSLScheme = "pulsar+ssl" 75 ) 76 77 // IsMQScheme returns true if the scheme belong to mq scheme. 78 func IsMQScheme(scheme string) bool { 79 return scheme == KafkaScheme || scheme == KafkaSSLScheme || 80 scheme == PulsarScheme || scheme == PulsarSSLScheme 81 } 82 83 // IsMySQLCompatibleScheme returns true if the scheme is compatible with MySQL. 84 func IsMySQLCompatibleScheme(scheme string) bool { 85 return scheme == MySQLScheme || scheme == MySQLSSLScheme || 86 scheme == TiDBScheme || scheme == TiDBSSLScheme 87 } 88 89 // IsStorageScheme returns true if the scheme belong to storage scheme. 90 func IsStorageScheme(scheme string) bool { 91 return scheme == FileScheme || scheme == S3Scheme || scheme == GCSScheme || 92 scheme == GSScheme || scheme == AzblobScheme || scheme == AzureScheme || scheme == CloudStorageNoopScheme 93 } 94 95 // IsPulsarScheme returns true if the scheme belong to pulsar scheme. 96 func IsPulsarScheme(scheme string) bool { 97 return scheme == PulsarScheme || scheme == PulsarSSLScheme 98 } 99 100 // IsBlackHoleScheme returns true if the scheme belong to blackhole scheme. 101 func IsBlackHoleScheme(scheme string) bool { 102 return scheme == BlackHoleScheme 103 } 104 105 // GetScheme returns the scheme of the url. 106 func GetScheme(url *url.URL) string { 107 return strings.ToLower(url.Scheme) 108 }