Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 7aabfe0

Browse files
committed
C: add transaction API
1 parent 8a04e7f commit 7aabfe0

3 files changed

Lines changed: 237 additions & 87 deletions

File tree

‎c/include/reftable.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,26 @@ int reftable_new_stack(struct reftable_stack **dest, const char *dir,
440440
/* returns the update_index at which a next table should be written. */
441441
uint64_t reftable_stack_next_update_index(struct reftable_stack *st);
442442

443+
/* holds a transaction to add tables at the top of a stack. */
444+
struct reftable_addition;
445+
446+
/*
447+
returns a new transaction to add reftables to the given stack. As a side
448+
effect, the ref database is locked.
449+
*/
450+
int reftable_stack_new_addition(struct reftable_addition **dest, struct reftable_stack *st);
451+
452+
/* Adds a reftable to transaction. */
453+
int reftable_addition_add(struct reftable_addition *add,
454+
int (*write_table)(struct reftable_writer *wr, void *arg),
455+
void *arg);
456+
457+
/* Commits the transaction, releasing the lock. */
458+
int reftable_addition_commit(struct reftable_addition *add);
459+
460+
/* Release all non-committed data from the transaction; releases the lock if held. */
461+
void reftable_addition_close(struct reftable_addition *add);
462+
443463
/* add a new table to the stack. The write_table function must call
444464
reftable_writer_set_limits, add refs and return an error value. */
445465
int reftable_stack_add(struct reftable_stack *st,

0 commit comments

Comments
 (0)