errcat

package module
v0.0.0-...-d356a15 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClient

func WithClient(client errcatapi.Client) optionD

WithClient defines the client that should be used for sending metrics to the errcat server. This allows finer control over the client than WithServerAddr.

func WithEnvironment

func WithEnvironment(env string) optionD

WithEnvironment defines the environment the daemon should indicate the calls are being made in.

func WithServerAddr

func WithServerAddr(addr url.URL) optionD

WithServerAddr will create a client for communicating to the errcat server using the supplied server address.

func WithService

func WithService(service string) optionD

WithService defines the service the daemon should indicate the calls are initiated from.

Types

type CallFn

type CallFn func() error

type Caller

type Caller struct {
	// contains filtered or unexported fields
}

func New

func New(dependency, name string) Caller

func (Caller) Call

func (c Caller) Call(cb CallFn) error

Call executes the callback function.

func (Caller) WithBreaker

func (c Caller) WithBreaker(b *breaker.Breaker) Caller

WithBreaker attaches a circuit breaker to the caller.

func (Caller) WithFallback

func (c Caller) WithFallback(f *fallback.Fallback) Caller

WithFallback defines the fallback behavior for the caller.

func (Caller) WithRetrier

func (c Caller) WithRetrier(r *retrier.Retrier) Caller

WithRetrier indicates the caller should be retried in the event of a failure.

func (Caller) WithTimeout

func (c Caller) WithTimeout(timeout time.Duration) Caller

WithTimeout enforces a timeout on the caller. This method should only be used in those cases where the wrapped dependency does not already provide timeout functionality. This is because this method does not stop the callback from running if it exceeds the timeout; it only ensures that the Call returns in the allotted time, whereas the dependency functionality may provide better cleanup.

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the background processor that will collect all calls and send them to the errcat server.

func NewD

func NewD(opts ...optionD) *Daemon

func (*Daemon) Call

func (d *Daemon) Call(key string, cb CallFn) (err error)

Call executes the supplied function using the caller looked up with the key.

func (*Daemon) RegisterCaller

func (d *Daemon) RegisterCaller(c Caller) (string, error)

RegisterCaller attaches a caller to the daemon so that it does not need to be re-instantiated.

func (*Daemon) Start

func (d *Daemon) Start()

func (*Daemon) Stop

func (d *Daemon) Stop()

Directories

Path Synopsis
cmd
protos
api
api/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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