alert

package
v0.0.0-...-83cf971 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(ctx context.Context, pairs ...string)

Emit an alert message, using emitter attched to the context.

func EmitErr

func EmitErr(ctx context.Context, err error, message string, pairs ...string)

EmitErr emits an alert message, using emitter attched to the context.

func WithEmitter

func WithEmitter(ctx context.Context, emitter Emitter) context.Context

WithEmitter adds alert emitter to the context.

Types

type Emitter

type Emitter interface {
	// Emit an alert, preferably in a synchronous way.
	//
	// pairs should always be an even number.
	Emit(pairs ...string)
}

Emitter is implemented by alert sink.

func NewTestEmitter

func NewTestEmitter(t testing.TB) Emitter

NewTextEmitter returns an emitter that logs entries in a plain text format into given testing object.

func NewTextEmitter

func NewTextEmitter(out io.Writer) Emitter

NewTextEmitter returns an emitter that writes entries in a plain text format. Pairs order is preserved and written as provided to Emit method.

func UsedEmitter

func UsedEmitter(ctx context.Context) Emitter

UsedEmitter returns alert emitter present in the context or a no-op implementation.

func WithPairs

func WithPairs(emitter Emitter, pairs ...string) Emitter

WithPairs returns an alert emitter that will include provided pairs in each emitter message. pairs is expected to have an even number of strings.

Jump to

Keyboard shortcuts

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