utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package utils provides various utilities and helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampFloat64

func ClampFloat64(value, min, max float64) float64

ClampFloat64 limits the provided value according to the given range. Origin: https://docs.unity3d.com/ScriptReference/Mathf.Clamp.html.

Types

type ApplicationTerminator

type ApplicationTerminator interface {
	// Terminate is a special method registering the fatal error of memory management.
	// It's mandatory for the application to terminate itself within or after this call.
	Terminate(fatalErr error)
}

ApplicationTerminator shuts down the application by MemLimiter command. It is used in the cases when it's better to restart the application rather than continue working. It must be implemented by library users, because every application has its own graceful termination protocol.

func NewFatalErrChanApplicationTerminator

func NewFatalErrChanApplicationTerminator(fatalErrChan chan<- error) ApplicationTerminator

NewFatalErrChanApplicationTerminator creates an instance of the ApplicationTerminator that put fatal errors to special channels, so the channel reader can handle it in another thread.

func NewUngracefulApplicationTerminator

func NewUngracefulApplicationTerminator(logger logr.Logger) ApplicationTerminator

NewUngracefulApplicationTerminator creates trivial implementation of the ApplicationTerminator, which immediately calls os.Exit(1). Can be used only with simple and stateless services.

type ApplicationTerminatorMock

type ApplicationTerminatorMock struct {
	mock.Mock
}

func (*ApplicationTerminatorMock) Terminate

func (m *ApplicationTerminatorMock) Terminate(fatalErr error)

type Counter

type Counter interface {
	go_metrics.Counter
}

Counter - thread-safe metrics counter.

func NewCounter

func NewCounter(parent Counter) Counter

NewCounter creates counter referring to parent counter. If parent is nil, the root in hierarchy is created.

Directories

Path Synopsis
Package breaker contains useful thread-safe abstraction the helps to control lifetime of actors, background tasks, pools etc.
Package breaker contains useful thread-safe abstraction the helps to control lifetime of actors, background tasks, pools etc.
config
bytes
Package bytes helps to represent human-readable size values in JSON.
Package bytes helps to represent human-readable size values in JSON.
duration
Package duration helps to represent human-readable duration values in JSON.
Package duration helps to represent human-readable duration values in JSON.
prepare
Package prepare provides a function to validate configuration recursively.
Package prepare provides a function to validate configuration recursively.

Jump to

Keyboard shortcuts

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