Documentation
¶
Index ¶
- Constants
- Variables
- func WithDeploymentID(deploymentID string) func(opts *IdempotenceImplOptions)
- func WithSuccessfulTTL(successfulTTL time.Duration) func(opts *IdempotenceImplOptions)
- func WithTimeout(timeout time.Duration) func(opts *IdempotenceImplOptions)
- type Idempotence
- type IdempotenceImpl
- type IdempotenceImplOptions
Constants ¶
View Source
const ( DefaultTimeout = 5 * time.Second // 5 seconds DefaultSuccessfulTTL = 24 * time.Hour // 24 hours StatusProcessing = "processing" StatusProcessed = "processed" )
Variables ¶
View Source
var ErrConflict = errors.New("conflict")
Functions ¶
func WithDeploymentID ¶ added in v0.13.0
func WithDeploymentID(deploymentID string) func(opts *IdempotenceImplOptions)
func WithSuccessfulTTL ¶
func WithSuccessfulTTL(successfulTTL time.Duration) func(opts *IdempotenceImplOptions)
func WithTimeout ¶
func WithTimeout(timeout time.Duration) func(opts *IdempotenceImplOptions)
Types ¶
type Idempotence ¶
type Idempotence interface {
Exec(ctx context.Context, key string, exec func(context.Context) error) error
// Processed reports whether key was marked processed (by MarkProcessed or
// a successful Exec) within the SuccessfulTTL window.
Processed(ctx context.Context, key string) (bool, error)
// MarkProcessed marks key processed for the SuccessfulTTL window.
MarkProcessed(ctx context.Context, key string) error
}
Idempotence deduplicates work by key. Exec is the packaged form: it claims the key, runs the callback, and marks the key processed — for work that completes within one call. Processed and MarkProcessed expose the check and mark phases separately, for callers whose work spans a boundary Exec can't wrap (e.g. the effects finish on another goroutine); such callers get no in-flight conflict detection — concurrent duplicates both run, so their effects must tolerate duplication.
func New ¶
func New(redisClient redis.Cmdable, opts ...func(opts *IdempotenceImplOptions)) Idempotence
type IdempotenceImpl ¶
type IdempotenceImpl struct {
// contains filtered or unexported fields
}
func (*IdempotenceImpl) MarkProcessed ¶ added in v1.1.0
func (i *IdempotenceImpl) MarkProcessed(ctx context.Context, key string) error
Click to show internal directories.
Click to hide internal directories.