Documentation

Overview

    Package txndefer implements a filter that calls best-effort callbacks on successful transaction commits.

    Useful when an activity inside a transaction has some best-effort follow up that should be done once the transaction has successfully landed.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Defer

    func Defer(ctx context.Context, cb func(context.Context))

      Defer schedules `cb` for execution when the current transaction successfully lands.

      Intended for a best-effort non-transactional follow up to a successful transaction. Note that in presence of failures there's no guarantee the callback will be called. For example, the callback won't ever be called if the process crashes right after landing the transaction. Or if the transaction really landed, but RunInTransaction finished with "deadline exceeded" (or some similar) error.

      Callbacks are executed sequentially in the reverse order they were deferred. They receive the non-transactional version of the context initially passed to RunInTransaction so that they inherit the deadline of the entire transaction.

      Panics if the given context is not transactional or there's no txndefer filter installed.

      func FilterRDS

      func FilterRDS(ctx context.Context) context.Context

        FilterRDS installs the datastore filter into the context.

        Example
        Output:
        
        2
        1
        

        Types

        This section is empty.

        Source Files