|
| 1 | +// Copyright 2025 The Cockroach Authors. |
| 2 | +// |
| 3 | +// Use of this software is governed by the CockroachDB Software License |
| 4 | +// included in the /LICENSE file. |
| 5 | + |
| 6 | +// TODO(#149703): Move this .proto file to the new changefeedpb repo, |
| 7 | +// import it into CockroachDB, and update usages accordingly. |
| 8 | + |
| 9 | +syntax = "proto3"; |
| 10 | +package cockroach.ccl.changefeedccl; |
| 11 | +option go_package = "github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/changefeedpb"; |
| 12 | + |
| 13 | +import "google/protobuf/timestamp.proto"; |
| 14 | + |
| 15 | +// MessageBatch is a batch of messages for use in webhook sinks. |
| 16 | +message MessageBatch { |
| 17 | + repeated Message payload = 1; |
| 18 | +} |
| 19 | + |
| 20 | +// Message is an enum of the different envelope types. This is what will be emitted to the client. |
| 21 | +message Message { |
| 22 | + oneof data { |
| 23 | + // wrapped is a Message in WrappedEnvelope format. |
| 24 | + WrappedEnvelope wrapped = 1; |
| 25 | + |
| 26 | + // bare is a Message in BareEnvelope format. |
| 27 | + BareEnvelope bare = 2; |
| 28 | + |
| 29 | + // enriched is a Message in EnrichedEnvelope format. |
| 30 | + EnrichedEnvelope enriched = 3; |
| 31 | + |
| 32 | + // resolved is a Message in Resolved format for Resolved Timestamps. |
| 33 | + Resolved resolved = 4; |
| 34 | + |
| 35 | + // bareResolved wraps a resolved envelope inside a BareResolved format for Resolved Timestamps in Bare envelopes. |
| 36 | + BareResolved bareResolved = 5; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +// WrappedEnvelope includes both the changed data and contextual metadata about the change. |
| 41 | +message WrappedEnvelope { |
| 42 | + Record after = 1; |
| 43 | + Record before = 2; |
| 44 | + string updated = 4; |
| 45 | + string mvcc_timestamp = 5; |
| 46 | + Key key = 6; |
| 47 | + string topic = 7; |
| 48 | +} |
| 49 | + |
| 50 | +// BareEnvelope contains change data as a flat map along with |
| 51 | +// CockroachDB-specific metadata under the '__crdb__' field. |
| 52 | +message BareEnvelope { |
| 53 | + map<string, Value> values = 1; |
| 54 | + Metadata __crdb__ = 2; |
| 55 | +} |
| 56 | + |
| 57 | +// BareResolved is a minimal envelope that wraps a resolved timestamp in a '__crdb__' field. |
| 58 | +message BareResolved { |
| 59 | + Resolved __crdb__ = 1; |
| 60 | +} |
| 61 | + |
| 62 | +// EnrichedEnvelope includes detailed context about the change event and source. |
| 63 | +message EnrichedEnvelope { |
| 64 | + Record after = 1; |
| 65 | + Record before = 2; |
| 66 | + Op op = 3; |
| 67 | + int64 ts_ns = 4; |
| 68 | + EnrichedSource source = 5; |
| 69 | +} |
| 70 | + |
| 71 | +// Resolved carries resolved timestamp information for a changefeed span. |
| 72 | +message Resolved { |
| 73 | + string resolved = 1; |
| 74 | +} |
| 75 | + |
| 76 | +// EnrichedSource records information about the origin and context |
| 77 | +// of a change event, for operational traceability. |
| 78 | +message EnrichedSource { |
| 79 | + string job_id = 1; |
| 80 | + string changefeed_sink = 2; |
| 81 | + string db_version = 3; |
| 82 | + string cluster_name = 4; |
| 83 | + string cluster_id = 5; |
| 84 | + string source_node_locality = 6; |
| 85 | + string node_name = 7; |
| 86 | + string node_id = 8; |
| 87 | + string mvcc_timestamp = 9; |
| 88 | + int64 ts_ns = 10; |
| 89 | + string ts_hlc = 11; |
| 90 | + string origin = 12; |
| 91 | + string database_name = 13; |
| 92 | + string schema_name = 14; |
| 93 | + string table_name = 15; |
| 94 | + repeated string primary_keys = 16; |
| 95 | +} |
| 96 | + |
| 97 | +// Op enumerates the types of operations represented in a change event. |
| 98 | +enum Op { |
| 99 | + OP_UNSPECIFIED = 0; |
| 100 | + OP_CREATE = 1; |
| 101 | + OP_UPDATE = 2; |
| 102 | + OP_DELETE = 3; |
| 103 | +} |
| 104 | + |
| 105 | +// Metadata contains CockroachDB-specific metadata about a change event. |
| 106 | +// This message is also referred to as '__crdb__'. |
| 107 | +message Metadata { |
| 108 | + string updated = 1; |
| 109 | + string mvcc_timestamp = 2; |
| 110 | + Key key = 3; |
| 111 | + string topic = 4; |
| 112 | +} |
| 113 | + |
| 114 | +// Value represents a value of arbitrary type carried in a change event. |
| 115 | +message Value { |
| 116 | + oneof value { |
| 117 | + string string_value = 1; |
| 118 | + bytes bytes_value = 2; |
| 119 | + int32 int32_value = 3; |
| 120 | + int64 int64_value = 4; |
| 121 | + float float_value = 5; |
| 122 | + double double_value = 6; |
| 123 | + bool bool_value = 7; |
| 124 | + google.protobuf.Timestamp timestamp_value = 8; |
| 125 | + Array array_value = 9; |
| 126 | + Record tuple_value = 10; |
| 127 | + Decimal decimal_value = 11; |
| 128 | + string date_value = 12; |
| 129 | + string interval_value = 13; |
| 130 | + string time_value = 14; |
| 131 | + string uuid_value = 15; |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +// Key contains the primary key values for a row. |
| 136 | +message Key { |
| 137 | + map<string, Value> key = 1; |
| 138 | +} |
| 139 | + |
| 140 | +// Array represents an ordered list of values. |
| 141 | +message Array { |
| 142 | + repeated Value values = 1; |
| 143 | +} |
| 144 | + |
| 145 | +// Decimal contains a fixed-point decimal value represented as a string. |
| 146 | +message Decimal { |
| 147 | + string value = 1; |
| 148 | +} |
| 149 | + |
| 150 | +// Record represents a flat mapping of column names to values for a row. |
| 151 | +message Record { |
| 152 | + map<string, Value> values = 1; |
| 153 | +} |
0 commit comments