Skip to content

Commit

Permalink
Update generated protocol messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alco committed Apr 17, 2024
1 parent 62bb43f commit a35a947
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 2 deletions.
29 changes: 29 additions & 0 deletions clients/typescript/src/_generated/protocol/satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export interface SatInStartReplicationReq {
* observed additional data before disconnect
*/
observedTransactionData: Long[];
/**
* The SQL dialect used by the client
* Defaults to SQLite if not specified
*/
sqlDialect?: SatInStartReplicationReq_Dialect | undefined;
}

export enum SatInStartReplicationReq_Option {
Expand All @@ -130,6 +135,12 @@ export enum SatInStartReplicationReq_Option {
UNRECOGNIZED = -1,
}

export enum SatInStartReplicationReq_Dialect {
SQLITE = 0,
POSTGRES = 1,
UNRECOGNIZED = -1,
}

/** (Producer) The result of the start replication requests */
export interface SatInStartReplicationResp {
$type: "Electric.Satellite.SatInStartReplicationResp";
Expand Down Expand Up @@ -457,9 +468,15 @@ export interface SatOpMigrate_PgColumnType {
size: number[];
}

/** reserved 2; */
export interface SatOpMigrate_Column {
$type: "Electric.Satellite.SatOpMigrate.Column";
name: string;
/**
* deprecated
* leaving it here to avoid breaking TypeScript tests that have hard-coded,
* base64-encoded SatOpMigrate messages.
*/
sqliteType: string;
pgType: SatOpMigrate_PgColumnType | undefined;
}
Expand Down Expand Up @@ -1102,6 +1119,7 @@ function createBaseSatInStartReplicationReq(): SatInStartReplicationReq {
subscriptionIds: [],
schemaVersion: undefined,
observedTransactionData: [],
sqlDialect: undefined,
};
}

Expand All @@ -1128,6 +1146,9 @@ export const SatInStartReplicationReq = {
writer.uint64(v);
}
writer.ldelim();
if (message.sqlDialect !== undefined) {
writer.uint32(56).int32(message.sqlDialect);
}
return writer;
},

Expand Down Expand Up @@ -1193,6 +1214,13 @@ export const SatInStartReplicationReq = {
}

break;
case 7:
if (tag !== 56) {
break;
}

message.sqlDialect = reader.int32() as any;
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
Expand All @@ -1213,6 +1241,7 @@ export const SatInStartReplicationReq = {
message.subscriptionIds = object.subscriptionIds?.map((e) => e) || [];
message.schemaVersion = object.schemaVersion ?? undefined;
message.observedTransactionData = object.observedTransactionData?.map((e) => Long.fromValue(e)) || [];
message.sqlDialect = object.sqlDialect ?? undefined;
return message;
},
};
Expand Down
168 changes: 166 additions & 2 deletions components/electric/lib/electric/satellite/protobuf_messages.ex
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,80 @@
)
)
end,
defmodule Electric.Satellite.SatInStartReplicationReq.Dialect do
@moduledoc false
(
defstruct []

(
@spec default() :: :SQLITE
def default() do
:SQLITE
end
)

@spec encode(atom() | String.t()) :: integer() | atom()
[
(
def encode(:SQLITE) do
0
end

def encode("SQLITE") do
0
end
),
(
def encode(:POSTGRES) do
1
end

def encode("POSTGRES") do
1
end
)
]

def encode(x) do
x
end

@spec decode(integer()) :: atom() | integer()
[
def decode(0) do
:SQLITE
end,
def decode(1) do
:POSTGRES
end
]

def decode(x) do
x
end

@spec constants() :: [{integer(), atom()}]
def constants() do
[{0, :SQLITE}, {1, :POSTGRES}]
end

@spec has_constant?(any()) :: boolean()
(
[
def has_constant?(:SQLITE) do
true
end,
def has_constant?(:POSTGRES) do
true
end
]

def has_constant?(_) do
false
end
)
)
end,
defmodule Electric.Satellite.SatInStartReplicationReq.Option do
@moduledoc false
(
Expand Down Expand Up @@ -3245,7 +3319,8 @@
options: [],
subscription_ids: [],
schema_version: nil,
observed_transaction_data: []
observed_transaction_data: [],
sql_dialect: nil

(
(
Expand All @@ -3262,6 +3337,7 @@
def encode!(msg) do
[]
|> encode_schema_version(msg)
|> encode_sql_dialect(msg)
|> encode_lsn(msg)
|> encode_options(msg)
|> encode_subscription_ids(msg)
Expand Down Expand Up @@ -3374,6 +3450,27 @@
reraise Protox.EncodingError.new(:observed_transaction_data, "invalid field value"),
__STACKTRACE__
end
end,
defp encode_sql_dialect(acc, msg) do
try do
case msg.sql_dialect do
nil ->
[acc]

child_field_value ->
[
acc,
"8",
child_field_value
|> Electric.Satellite.SatInStartReplicationReq.Dialect.encode()
|> Protox.Encode.encode_enum()
]
end
rescue
ArgumentError ->
reraise Protox.EncodingError.new(:sql_dialect, "invalid field value"),
__STACKTRACE__
end
end
]

Expand Down Expand Up @@ -3468,6 +3565,15 @@
{value, rest} = Protox.Decode.parse_uint64(bytes)
{[observed_transaction_data: msg.observed_transaction_data ++ [value]], rest}

{7, _, bytes} ->
{value, rest} =
Protox.Decode.parse_enum(
bytes,
Electric.Satellite.SatInStartReplicationReq.Dialect
)

{[sql_dialect: value], rest}

{tag, wire_type, rest} ->
{_, rest} = Protox.Decode.parse_unknown(tag, wire_type, rest)
{[], rest}
Expand Down Expand Up @@ -3529,7 +3635,10 @@
2 => {:options, :packed, {:enum, Electric.Satellite.SatInStartReplicationReq.Option}},
4 => {:subscription_ids, :unpacked, :string},
5 => {:schema_version, {:oneof, :_schema_version}, :string},
6 => {:observed_transaction_data, :packed, :uint64}
6 => {:observed_transaction_data, :packed, :uint64},
7 =>
{:sql_dialect, {:oneof, :_sql_dialect},
{:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}}
}
end

Expand All @@ -3543,6 +3652,9 @@
observed_transaction_data: {6, :packed, :uint64},
options: {2, :packed, {:enum, Electric.Satellite.SatInStartReplicationReq.Option}},
schema_version: {5, {:oneof, :_schema_version}, :string},
sql_dialect:
{7, {:oneof, :_sql_dialect},
{:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}},
subscription_ids: {4, :unpacked, :string}
}
end
Expand Down Expand Up @@ -3596,6 +3708,15 @@
name: :observed_transaction_data,
tag: 6,
type: :uint64
},
%{
__struct__: Protox.Field,
json_name: "sqlDialect",
kind: {:oneof, :_sql_dialect},
label: :proto3_optional,
name: :sql_dialect,
tag: 7,
type: {:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}
}
]
end
Expand Down Expand Up @@ -3780,6 +3901,46 @@
}}
end
),
(
def field_def(:sql_dialect) do
{:ok,
%{
__struct__: Protox.Field,
json_name: "sqlDialect",
kind: {:oneof, :_sql_dialect},
label: :proto3_optional,
name: :sql_dialect,
tag: 7,
type: {:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}
}}
end

def field_def("sqlDialect") do
{:ok,
%{
__struct__: Protox.Field,
json_name: "sqlDialect",
kind: {:oneof, :_sql_dialect},
label: :proto3_optional,
name: :sql_dialect,
tag: 7,
type: {:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}
}}
end

def field_def("sql_dialect") do
{:ok,
%{
__struct__: Protox.Field,
json_name: "sqlDialect",
kind: {:oneof, :_sql_dialect},
label: :proto3_optional,
name: :sql_dialect,
tag: 7,
type: {:enum, Electric.Satellite.SatInStartReplicationReq.Dialect}
}}
end
),
def field_def(_) do
{:error, :no_such_field}
end
Expand Down Expand Up @@ -3819,6 +3980,9 @@
def default(:observed_transaction_data) do
{:error, :no_default_value}
end,
def default(:sql_dialect) do
{:error, :no_default_value}
end,
def default(_) do
{:error, :no_such_field}
end
Expand Down

0 comments on commit a35a947

Please sign in to comment.