committable

package
v0.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package committable provides an easy to use interface for creating committables.

Index

Constants

This section is empty.

Variables

View Source
var (
	// used to identify the last used idempotency key in the store
	IdempotencyKeyKey = []byte("idempotencyKey")
	// used to identify the last used apphash in the store
	ApphashKey = []byte("apphash")
)

Functions

This section is empty.

Types

type CommittableStore

type CommittableStore interface {
	Set(ctx context.Context, key []byte, value []byte) error
	Get(ctx context.Context, key []byte, sync bool) ([]byte, error)
	Savepoint() (sql.Savepoint, error)
}

type SavepointCommittable

type SavepointCommittable struct {
	// contains filtered or unexported fields
}

SavepointCommittable is a committable that can be used to commit a savepoint.

func (*SavepointCommittable) Begin

func (a *SavepointCommittable) Begin(ctx context.Context, idempotencyKey []byte) error

Begin begins a session for the account store. It will check the stored idempotency key and return an error if it is the same as the one provided.

func (*SavepointCommittable) BeginRecovery

func (a *SavepointCommittable) BeginRecovery(ctx context.Context, idempotencyKey []byte) error

BeginRecovery begins a session for the account store in recovery mode. If the idempotency key is the same as the last used one, it will skip all incoming spends.

func (*SavepointCommittable) Cancel

func (a *SavepointCommittable) Cancel(ctx context.Context) error

Cancel cancels the session for the committables.

func (*SavepointCommittable) Commit

func (a *SavepointCommittable) Commit(ctx context.Context, idempotencyKey []byte) ([]byte, error)

Commit commits the session for the account store.

func (*SavepointCommittable) Register

func (a *SavepointCommittable) Register(value []byte) error

Register registers a value to be used in the commit hash.

func (*SavepointCommittable) SetIDFunc

func (a *SavepointCommittable) SetIDFunc(idFn func() ([]byte, error))

SetIDFunc sets the id function.

func (*SavepointCommittable) Skip

func (a *SavepointCommittable) Skip() bool

Skip returns whether or not the committable is in skip mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL