Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add a way to run callbacks after a transaction commits

Aperta
#205 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Start with opsqueue/src/db/mod.rs, where Connection::transaction() is defined, and read the linked discussion in issues #182 and #193 for context. The issue proposes storing callbacks on transactions, running them after a successful outermost commit, and propagating them from nested transactions. Done means callbacks run only after commit and nested transactions pass them upward; the issue leaves key design details open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Related: https://github.com/channable/opsqueue/issues/182#issuecomment-5698854050, https://github.com/channable/opsqueue/issues/193

We currently have three things that need to happen after a transaction commits:

Ideally we would like to define these actions close to where they most sense on a semantic level (e.g. within insert_submission). However, once transactions come into play this becomes problematic, because these side-effects should only be executed if and when the transaction commits. Since the callee doesn't control, nor has insight in, if and when that commit would happen we have no choice but to defer that execution to the caller. We currently either ignore the problem (for Prometheus metrics), or handle the defer manually (e.g. by returning a bool, and making the caller check that after commit). Both are not ideal.

To remedy this I propose we offer users of opsqueue::db::Connection::transaction() something like the following API:

conn.transaction(move |mut tx| { async move {
    ...
    // Register a callback to run on commit.
    tx.on_commit(|| notify_on_insert.notify());
    ...
} .boxed()}).await?;

To implement that we would have to:

  • Store a list of on_commit callbacks somewhere on the transaction (TBD where exactly).
  • Within opsqueue::db::Connection::transaction() we check if the transaction committed. If so, and we are not in a nested transaction we execute all the callbacks. If we are in a nested transaction we propagate the callbacks upwards.
Lingua principale
Rust
Stelle
97
Fork
2
Merge medio
1g 18h
PR unite (30g)
4

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di channable/opsqueue

Tutte le issue di channable/opsqueue

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.