Skip to content

Commit c982c4d

Browse files
committed
Fix: Ensure benchmark sinks not production in BenchmarkSink
1 parent 24722be commit c982c4d

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

lib/sequin/consumers/benchmark_sink.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,14 @@ defmodule Sequin.Consumers.BenchmarkSink do
2222
struct
2323
|> cast(params, [:partition_count])
2424
|> validate_number(:partition_count, greater_than: 0)
25+
|> ensure_not_production()
26+
end
27+
28+
defp ensure_not_production(changeset) do
29+
if Application.get_env(:sequin, :env) == :prod do
30+
add_error(changeset, :type, "benchmark consumers are not allowed in production")
31+
else
32+
changeset
33+
end
2534
end
2635
end

lib/sequin/consumers/sink_consumer.ex

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ defmodule Sequin.Consumers.SinkConsumer do
207207
|> cast_embed(:source, required: true)
208208
|> cast_embed(:source_tables)
209209
|> put_defaults()
210-
|> validate_type()
211210
|> validate_message_grouping()
212211
|> validate_enrichment()
213212
|> validate_required([:name, :status, :replication_slot_id, :batch_size])
@@ -227,16 +226,6 @@ defmodule Sequin.Consumers.SinkConsumer do
227226
|> Sequin.Changeset.annotations_check_constraint()
228227
end
229228

230-
defp validate_type(changeset) do
231-
sink = get_field(changeset, :sink)
232-
233-
if sink && sink.type == :benchmark && Application.get_env(:sequin, :env) == :prod do
234-
add_error(changeset, :type, "invalid type: #{inspect(sink.type)}")
235-
else
236-
changeset
237-
end
238-
end
239-
240229
defp validate_message_grouping(changeset) do
241230
message_grouping = get_field(changeset, :message_grouping)
242231
source_tables = get_field(changeset, :source_tables) || []

0 commit comments

Comments
 (0)