successfailurecounter

package
v0.0.0-...-0958f0d Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL