saga

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package saga provides MySQL-specific implementations of the interfaces in Ax's top-level "saga" package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CRUDRepository

type CRUDRepository struct{}

CRUDRepository is a MySQL-backed implementation of Ax's crud.Repository interface.

func (CRUDRepository) DeleteSagaInstance

func (r CRUDRepository) DeleteSagaInstance(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	i saga.Instance,
) error

DeleteSagaInstance deletes a saga instance.

It returns an error if i.Revision is not the current revision of the instance as it exists within the store, or a problem occurs with the underlying data store.

It returns an error if the instance belongs to a different saga, as identified by pk, the saga's persistence key.

It panics if the repository is not able to enlist in tx because it uses a different underlying storage system.

func (CRUDRepository) LoadSagaInstance

func (r CRUDRepository) LoadSagaInstance(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	id saga.InstanceID,
) (saga.Instance, bool, error)

LoadSagaInstance fetches a saga instance by its ID.

It returns an false if the instance does not exist. It returns an error if a problem occurs with the underlying data store.

It returns an error if the instance is found, but belongs to a different saga, as identified by pk, the saga's persistence key.

It panics if the repository is not able to enlist in tx because it uses a different underlying storage system.

func (CRUDRepository) SaveSagaInstance

func (r CRUDRepository) SaveSagaInstance(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	i saga.Instance,
) error

SaveSagaInstance persists a saga instance.

It returns an error if i.Revision is not the current revision of the instance as it exists within the store, or a problem occurs with the underlying data store.

It returns an error if the instance belongs to a different saga, as identified by pk, the saga's persistence key.

It panics if the repository is not able to enlist in tx because it uses a different underlying storage system.

type KeySetRepository

type KeySetRepository struct{}

KeySetRepository is a MySQL-backed implementation of Ax's keyset.Repository interface.

func (KeySetRepository) DeleteKeys

func (r KeySetRepository) DeleteKeys(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	id saga.InstanceID,
) error

DeleteKeys removes any mapping keys associated with a saga instance.

pk is the saga's persistence key.

func (KeySetRepository) FindByKey

func (KeySetRepository) FindByKey(
	ctx context.Context,
	ptx persistence.Tx,
	pk, mk string,
) (id saga.InstanceID, ok bool, err error)

FindByKey returns the ID of a saga instance that has a specific key in its key set.

pk is the saga's persistence key, mk is the mapping key. ok is false if no saga instance has a key set containing mk.

func (KeySetRepository) SaveKeys

func (r KeySetRepository) SaveKeys(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	ks []string,
	id saga.InstanceID,
) error

SaveKeys associates a set of mapping keys with a saga instance.

Key sets must be disjoint. That is, no two instances of the same saga may share any keys.

pk is the saga's persistence key. ks is the set of mapping keys.

SaveKeys() may panic if ks contains duplicate keys.

type SnapshotRepository

type SnapshotRepository struct{}

SnapshotRepository is a MySQL-backed implementation of Ax's eventsourcing.SnapshotRepository interface.

func (SnapshotRepository) DeleteSagaSnapshots

func (SnapshotRepository) DeleteSagaSnapshots(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	id saga.InstanceID,
) error

DeleteSagaSnapshots deletes any snapshots associated with a saga instance.

This implementation does not verify the saga's persistence key. It simply ignores any snapshots that match the instance ID, but not the persistence key.

func (SnapshotRepository) LoadSagaSnapshot

func (SnapshotRepository) LoadSagaSnapshot(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	id saga.InstanceID,
) (saga.Instance, bool, error)

LoadSagaSnapshot loads the latest available snapshot from the store.

It returns an error if a snapshot of this instance is found, but belongs to a different saga, as identified by pk, the saga's persistence key.

func (SnapshotRepository) SaveSagaSnapshot

func (SnapshotRepository) SaveSagaSnapshot(
	ctx context.Context,
	ptx persistence.Tx,
	pk string,
	i saga.Instance,
) error

SaveSagaSnapshot saves a snapshot to the store.

This implementation does not verify the saga's persistence key against existing snapshots of the same instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳