Documentation ¶
Overview ¶
successfailurecounter provides a wrapper to atomically increment success or failure counters.
This package is **not** thread safe. Multiple increments to the same SuccessFailureCounter from different threads can result in incorrect counter results.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SuccessFailureCounter ¶
type SuccessFailureCounter struct {
// contains filtered or unexported fields
}
SuccessFailureCounter implements a wrapper to increment success or failure counters exactly once.
func New ¶
func New(success, fail *atomic.Uint64) SuccessFailureCounter
New returns a SuccessFailureCounter that can be incremented exactly once.
func (*SuccessFailureCounter) DefaultToFailure ¶
func (sfc *SuccessFailureCounter) DefaultToFailure()
DefaultToFailure increments the failure counter if no counter was updated before.
func (*SuccessFailureCounter) DefaultToSuccess ¶
func (sfc *SuccessFailureCounter) DefaultToSuccess()
DefaultToSuccess increments the success counter if no counter was updated before.
func (*SuccessFailureCounter) ReportFailure ¶
func (sfc *SuccessFailureCounter) ReportFailure()
ReportFailure increments the failure counter or logs an error otherwise.
func (*SuccessFailureCounter) ReportSuccess ¶
func (sfc *SuccessFailureCounter) ReportSuccess()
ReportSuccess increments the success counter or logs an error otherwise.