Documentation ¶
Index ¶
- Variables
- func Execute[O any, B any, D Doer[O, B], F DoFunc[O, B, D]](ctx context.Context, db B, doer D, fn F) (err error)
- func Ping(limit int, count PingCount, ping func(context.Context) error) (cnt int, err error)
- func RunTicker(ctx context.Context, interval time.Duration, tickCount int, ...)
- type DoFunc
- type Doer
- type DoerBase
- func (do *DoerBase[_, B]) BeginTxn(context.Context, B) (Txn, error)
- func (do *DoerBase[_, _]) MaxPing() int
- func (do *DoerBase[_, _]) MaxRetry() int
- func (do *DoerBase[_, _]) Mutate(setters ...DoerFieldSetter)
- func (do *DoerBase[T, _]) Options() T
- func (do *DoerBase[_, _]) Rethrow() bool
- func (do *DoerBase[_, _]) Timeout() time.Duration
- func (do *DoerBase[_, _]) Title() string
- type DoerFieldSetter
- type DoerFields
- type PingCount
- type Txn
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilArgument = errors.New("nil argument") ErrNotImplemented = errors.New("not implemented") )
Functions ¶
func Execute ¶ added in v0.0.6
func Execute[ O any, B any, D Doer[O, B], F DoFunc[O, B, D], ](ctx context.Context, db B, doer D, fn F) (err error)
Execute executes a transaction with the given Doer and function.
func Ping ¶ added in v0.0.6
Ping is a function that performs a repeatable ping operation with retry logic. Parameters: - limit: The maximum number of retry attempts. If set to <= 0, a default of 3 is used. - count: A function of type PingCount to report the number of attempts and delay. - ping: A function that takes a context and returns an error. It performs the actual ping operation. Returns: - cnt: The total number of attempts made. - err: Any error encountered
Types ¶
type Doer ¶
type Doer[TOptions any, TBeginner any] interface { Mutate(setters ...DoerFieldSetter) BeginTxn(context.Context, TBeginner) (Txn, error) Title() string Rethrow() bool Timeout() time.Duration MaxPing() int MaxRetry() int Options() TOptions }
Doer defines the interface for database transaction operations.
type DoerBase ¶
DoerBase provides a base implementation for the Doer interface.
func (*DoerBase[_, _]) Mutate ¶ added in v0.0.8
func (do *DoerBase[_, _]) Mutate(setters ...DoerFieldSetter)
Mutate applies field setters to modify DoerBase's fields.
type DoerFieldSetter ¶ added in v0.0.8
type DoerFieldSetter func(*DoerFields)
DoerFieldSetter defines a function signature for setting DoerFields.
func WithMaxPing ¶ added in v0.0.8
func WithMaxPing(value int) DoerFieldSetter
WithMaxPing creates a field setter for the maximum ping count.
func WithMaxRetry ¶ added in v0.0.8
func WithMaxRetry(value int) DoerFieldSetter
WithMaxRetry creates a field setter for the maximum retry count.
func WithOptions ¶ added in v0.0.8
func WithOptions(value any) DoerFieldSetter
WithOptions creates a field setter for options.
func WithRethrow ¶ added in v0.0.8
func WithRethrow(value bool) DoerFieldSetter
WithRethrow creates a field setter for the rethrow flag.
func WithTimeout ¶ added in v0.0.8
func WithTimeout(value time.Duration) DoerFieldSetter
WithTimeout creates a field setter for the timeout duration.
func WithTitle ¶ added in v0.0.8
func WithTitle(value string) DoerFieldSetter
WithTitle creates a field setter for the title.
type DoerFields ¶ added in v0.0.8
type DoerFields struct {
// contains filtered or unexported fields
}
DoerFields provides data fields for DoerBase struct.