channel

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

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

Go to latest
Published: Nov 28, 2022 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package channel defines the logger.

channel is using a global logger with some default parameters. It is disabled by default and the level can be increased using an environment variable:

CRY_LOG=trace
CRY_LOG=info

Index

Constants

View Source
const EnvLogLevel = "CRY_LOG"

EnvLogLevel is the name of the environment variable to change the logging level.

Variables

View Source
var BlockedPop = string("Pop blocked on channel: ")
View Source
var BlockedPush = string("Push blocked on channel: ")
View Source
var Logger = zerolog.New(logout).Level(defaultLogLevel).
	With().Timestamp().Logger().
	With().Str("role", "cry chan").Logger()

Logger is a globally available logger instance. By default, it only prints error level messages but it can be changed through a environment variable.

View Source
var UnblockedPop = string("Pop unblocked on channel: ")
View Source
var UnblockedPush = string("Push unblocked on channel: ")

Functions

This section is empty.

Types

type Timed

type Timed[T any] struct {
	// contains filtered or unexported fields
}

func WithExpiration

func WithExpiration[T any](bufSize int) Timed[T]

WithExpiration creates a new channel of the given size and type

func (*Timed[T]) Channel

func (c *Timed[T]) Channel() chan T

Channel returns the raw channel used

func (*Timed[T]) Len

func (c *Timed[T]) Len() int

Len gives the current number of elements in the channel

func (*Timed[T]) Pop

func (c *Timed[T]) Pop() T

Pop removes an element from the channel or logs a warning if it fails after the default timeout

func (*Timed[T]) PopWithContext

func (c *Timed[T]) PopWithContext(ctx context.Context) T

PopWithContext removes an element from the channel or logs a warning if it fails after the given context

func (*Timed[T]) PopWithTimeout

func (c *Timed[T]) PopWithTimeout(t time.Duration) T

PopWithTimeout removes an element from the channel or logs a warning if it fails after the given timeout

func (*Timed[T]) Push

func (c *Timed[T]) Push(e T)

Push adds an element in the channel, or logs a warning if it fails after default timeout

func (*Timed[T]) PushWithContext

func (c *Timed[T]) PushWithContext(ctx context.Context, e T)

PushWithContext adds an element in the channel, or logs a warning if it fails after the given context

func (*Timed[T]) PushWithTimeout

func (c *Timed[T]) PushWithTimeout(t time.Duration, e T)

PushWithTimeout adds an element in the channel, or logs a warning if it fails after the given timeout

Jump to

Keyboard shortcuts

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