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
- Variables
- type Error
- type Timed
- func (c *Timed[T]) Channel() chan T
- func (c *Timed[T]) Len() int
- func (c *Timed[T]) NonBlockingReceive() (e T, err error)
- func (c *Timed[T]) NonBlockingReceiveWithContext(ctx context.Context) (T, error)
- func (c *Timed[T]) NonBlockingReceiveWithTimeout(t time.Duration) (e T, err error)
- func (c *Timed[T]) NonBlockingSend(e T) error
- func (c *Timed[T]) NonBlockingSendWithContext(ctx context.Context, e T) error
- func (c *Timed[T]) NonBlockingSendWithTimeout(t time.Duration, e T) error
- func (c *Timed[T]) Receive() T
- func (c *Timed[T]) ReceiveWithContext(ctx context.Context) T
- func (c *Timed[T]) ReceiveWithTimeout(t time.Duration) T
- func (c *Timed[T]) Send(e T)
- func (c *Timed[T]) SendWithContext(ctx context.Context, e T)
- func (c *Timed[T]) SendWithTimeout(t time.Duration, e T)
Constants ¶
const ( ErrFailedToSend = Error("Could not send data on channel.") ErrFailedToReceive = Error("Could not receive data from channel.") )
const EnvLogLevel = "CRY_LOG"
EnvLogLevel is the name of the environment variable to change the logging level.
Variables ¶
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.
Functions ¶
This section is empty.
Types ¶
type Timed ¶
type Timed[T any] struct { // contains filtered or unexported fields }
func WithExpiration ¶
WithExpiration creates a new channel of the given size and type
func (*Timed[T]) NonBlockingReceive ¶
NonBlockingReceive removes an element from the channel or returns an error if it fails after the default timeout
func (*Timed[T]) NonBlockingReceiveWithContext ¶
NonBlockingReceiveWithContext removes an element from the channel or returns an error if it fails in the given context.
func (*Timed[T]) NonBlockingReceiveWithTimeout ¶
NonBlockingReceiveWithTimeout removes an element from the channel or returns an error if it fails after the given timeout
func (*Timed[T]) NonBlockingSend ¶
NonBlockingSend adds an element in the channel, or returns an error if it fails after the default timeout.
func (*Timed[T]) NonBlockingSendWithContext ¶
NonBlockingSendWithContext adds an element in the channel, or returns an error if it fails in the given context.
func (*Timed[T]) NonBlockingSendWithTimeout ¶
NonBlockingSendWithTimeout adds an element in the channel, or returns an error if it fails after the given timeout.
func (*Timed[T]) Receive ¶
func (c *Timed[T]) Receive() T
Receive removes an element from the channel or logs a warning if it fails after the default timeout. Note: this is a blocking call as it waits on a channel.
func (*Timed[T]) ReceiveWithContext ¶
ReceiveWithContext removes an element from the channel or logs a warning if it fails in the given context. Note: this is a blocking call as it waits on a channel.
func (*Timed[T]) ReceiveWithTimeout ¶
ReceiveWithTimeout removes an element from the channel or logs a warning if it fails after the given timeout. Note: this is a blocking call as it waits on a channel.
func (*Timed[T]) Send ¶
func (c *Timed[T]) Send(e T)
Send adds an element in the channel, or logs a warning if it fails after default timeout. Note: this is a blocking call as it waits on a channel.
func (*Timed[T]) SendWithContext ¶
SendWithContext adds an element in the channel, or logs a warning if it fails in the given context. Note: this is a blocking call as it waits on a channel.
func (*Timed[T]) SendWithTimeout ¶
SendWithTimeout adds an element in the channel, or logs a warning if it fails after the given timeout. Note: this is a blocking call as it waits on a channel.