github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ccl/changefeedccl/changefeedbase/options.go (about) 1 // Copyright 2020 The Cockroach Authors. 2 // 3 // Licensed as a CockroachDB Enterprise file under the Cockroach Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt 8 9 package changefeedbase 10 11 import "github.com/cockroachdb/cockroach/pkg/sql" 12 13 // EnvelopeType configures the information in the changefeed events for a row. 14 type EnvelopeType string 15 16 // FormatType configures the encoding format. 17 type FormatType string 18 19 // SchemaChangeEventClass defines a set of schema change event types which 20 // trigger the action defined by the SchemaChangeEventPolicy. 21 type SchemaChangeEventClass string 22 23 // SchemaChangePolicy defines the behavior of a changefeed when a schema 24 // change event which is a member of the changefeed's schema change events. 25 type SchemaChangePolicy string 26 27 // Constants for the options. 28 const ( 29 OptConfluentSchemaRegistry = `confluent_schema_registry` 30 OptCursor = `cursor` 31 OptEnvelope = `envelope` 32 OptFormat = `format` 33 OptKeyInValue = `key_in_value` 34 OptResolvedTimestamps = `resolved` 35 OptUpdatedTimestamps = `updated` 36 OptDiff = `diff` 37 OptCompression = `compression` 38 OptSchemaChangeEvents = `schema_change_events` 39 OptSchemaChangePolicy = `schema_change_policy` 40 OptProtectDataFromGCOnPause = `protect_data_from_gc_on_pause` 41 42 // OptSchemaChangeEventClassColumnChange corresponds to all schema change 43 // events which add or remove any column. 44 OptSchemaChangeEventClassColumnChange SchemaChangeEventClass = `column_changes` 45 // OptSchemaChangeEventClassDefault corresponds to all schema change 46 // events which add a column with a default value or remove any column. 47 OptSchemaChangeEventClassDefault SchemaChangeEventClass = `default` 48 49 // OptSchemaChangePolicyBackfill indicates that when a schema change event 50 // occurs, a full table backfill should occur. 51 OptSchemaChangePolicyBackfill SchemaChangePolicy = `backfill` 52 // OptSchemaChangePolicyNoBackfill indicates that when a schema change event occurs 53 // no backfill should occur and the changefeed should continue. 54 OptSchemaChangePolicyNoBackfill SchemaChangePolicy = `nobackfill` 55 // OptSchemaChangePolicyStop indicates that when a schema change event occurs 56 // the changefeed should resolve all data up to when it occurred and then 57 // exit with an error indicating the HLC timestamp of the change from which 58 // the user could continue. 59 OptSchemaChangePolicyStop SchemaChangePolicy = `stop` 60 61 // OptInitialScan enables an initial scan. This is the default when no 62 // cursor is specified, leading to an initial scan at the statement time of 63 // the creation of the changeffed. If used in conjunction with a cursor, 64 // an initial scan will be performed at the cursor timestamp. 65 OptInitialScan = `initial_scan` 66 // OptInitialScan enables an initial scan. This is the default when a 67 // cursor is specified. This option is useful to create a changefeed which 68 // subscribes only to new messages. 69 OptNoInitialScan = `no_initial_scan` 70 71 OptEnvelopeKeyOnly EnvelopeType = `key_only` 72 OptEnvelopeRow EnvelopeType = `row` 73 OptEnvelopeDeprecatedRow EnvelopeType = `deprecated_row` 74 OptEnvelopeWrapped EnvelopeType = `wrapped` 75 76 OptFormatJSON FormatType = `json` 77 OptFormatAvro FormatType = `experimental_avro` 78 79 SinkParamCACert = `ca_cert` 80 SinkParamClientCert = `client_cert` 81 SinkParamClientKey = `client_key` 82 SinkParamFileSize = `file_size` 83 SinkParamSchemaTopic = `schema_topic` 84 SinkParamTLSEnabled = `tls_enabled` 85 SinkParamTopicPrefix = `topic_prefix` 86 SinkSchemeBuffer = `` 87 SinkSchemeExperimentalSQL = `experimental-sql` 88 SinkSchemeKafka = `kafka` 89 SinkParamSASLEnabled = `sasl_enabled` 90 SinkParamSASLHandshake = `sasl_handshake` 91 SinkParamSASLUser = `sasl_user` 92 SinkParamSASLPassword = `sasl_password` 93 ) 94 95 // ChangefeedOptionExpectValues is used to parse changefeed options using 96 // PlanHookState.TypeAsStringOpts(). 97 var ChangefeedOptionExpectValues = map[string]sql.KVStringOptValidate{ 98 OptConfluentSchemaRegistry: sql.KVStringOptRequireValue, 99 OptCursor: sql.KVStringOptRequireValue, 100 OptEnvelope: sql.KVStringOptRequireValue, 101 OptFormat: sql.KVStringOptRequireValue, 102 OptKeyInValue: sql.KVStringOptRequireNoValue, 103 OptResolvedTimestamps: sql.KVStringOptAny, 104 OptUpdatedTimestamps: sql.KVStringOptRequireNoValue, 105 OptDiff: sql.KVStringOptRequireNoValue, 106 OptCompression: sql.KVStringOptRequireValue, 107 OptSchemaChangeEvents: sql.KVStringOptRequireValue, 108 OptSchemaChangePolicy: sql.KVStringOptRequireValue, 109 OptInitialScan: sql.KVStringOptRequireNoValue, 110 OptNoInitialScan: sql.KVStringOptRequireNoValue, 111 OptProtectDataFromGCOnPause: sql.KVStringOptRequireNoValue, 112 }