Skip to content

Include custom carbonite prefix in multi step name - #143

Merged
maltoe merged 1 commit into
mainfrom
include-prefix-in-multi-op-name
Sep 10, 2025
Merged

maltoe merged 1 commit into
mainfrom
include-prefix-in-multi-op-name

Conversation

@maltoe

@maltoe maltoe commented Sep 10, 2025

Copy link
Copy Markdown
Collaborator

This patch changes behaviour of Carbonite.Multi.insert_transaction/3 to include the given :carbonite_prefix option in the multi name. This allows for multi-stream setups on the same DB transaction, e.g.

Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")

This patch changes behaviour of `Carbonite.Multi.insert_transaction/3` to
include the given `:carbonite_prefix` option in the multi name. This allows
for multi-stream setups on the same DB transaction, e.g.

```
Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")
```

@agatheblues agatheblues left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@maltoe
maltoe merged commit 21f23f3 into main Sep 10, 2025
10 checks passed
@maltoe
maltoe deleted the include-prefix-in-multi-op-name branch September 10, 2025 08:09
Hedde added a commit to Hedde/carbonite that referenced this pull request Apr 16, 2026
This patch extends the behaviour introduced in bitcrowd#143 to the remaining
`Carbonite.Multi` functions: `fetch_changes/2` and `override_mode/2` now
also include the `:carbonite_prefix` option in their multi step name.

Without this, calls to these functions for different prefixes within
the same `Ecto.Multi` raise because of a duplicate step name, which
defeats the multi-stream setups that bitcrowd#143 was meant to enable, e.g.

```
Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.fetch_changes()
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")
|> Carbonite.Multi.fetch_changes(carbonite_prefix: "my_other_audits")
```
maltoe pushed a commit that referenced this pull request Apr 19, 2026
This patch extends the behaviour introduced in #143 to the remaining
`Carbonite.Multi` functions: `fetch_changes/2` and `override_mode/2` now
also include the `:carbonite_prefix` option in their multi step name.

Without this, calls to these functions for different prefixes within
the same `Ecto.Multi` raise because of a duplicate step name, which
defeats the multi-stream setups that #143 was meant to enable, e.g.

```
Multi.new()
|> Carbonite.Multi.insert_transaction(%{type: "foo"})
|> Carbonite.Multi.fetch_changes()
|> Carbonite.Multi.insert_transaction(%{type: "foo"}, carbonite_prefix: "my_other_audits")
|> Carbonite.Multi.fetch_changes(carbonite_prefix: "my_other_audits")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants