pkgstore

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicOperation

type AtomicOperation[T any] func(ctx context.Context, store T) error

AtomicOperation is a function that can be executed atomically on a store. This type of method is typically used in conjunction with AtomicStore.

Example:

atomicStore.Exec(ctx, func(ctx context.Context, s Store) error {
    _ = s.DoOperationOne(ctx)
    _ = s.DoOperationTwo(ctx)
    return nil
})

type AtomicStore

type AtomicStore[T any] interface {
	// Exec executes an operation atomically.
	// All operations within the function are executed as a single transaction.
	// Not all databases support transactions, so an external
	// service may be required to ensure this atomicity.
	Exec(ctx context.Context, op AtomicOperation[T]) error
}

AtomicStore is a store designed to execute operations atomically. Its purpose is to encapsulate the logic of transaction management for any type of database.

Jump to

Keyboard shortcuts

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