external

package
v0.0.0-...-d30abd5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

package external

import "github.com/zeebo/rothko/external"

package external defines some interfaces for external resources.

Usage

func Errorw
func Errorw(msg string, keyvals ...interface{})

Errorw calls Errorw on the default Resources.

func Infow
func Infow(msg string, keyvals ...interface{})

Infow calls Infow on the default resources.

func Observe
func Observe(name string, value float64)

Observe calls Observe on the default Resources.

type Logger
type Logger interface {
	Infow(msg string, keyvals ...interface{})
	Errorw(msg string, keyvals ...interface{})
}

Logger is used when logging is required. It is built to match the uber/zap SugaredLogger type.

type Monitor
type Monitor interface {
	Observe(name string, value float64)
}

Monitor is used to monitor rothko's operation.

type Resources
type Resources struct {
	Logger  Logger
	Monitor Monitor
}

Resources is a collection of all the external resources. It implements all of the methods of the fields but in a nil-safe way.

var Default Resources

Default is the default set of resources. Can be overridden by plugins.

func (Resources) Errorw
func (r Resources) Errorw(msg string, keyvals ...interface{})

Errorw calls Logger.Errorw if Logger is not nil.

func (Resources) Infow
func (r Resources) Infow(msg string, keyvals ...interface{})

Infow calls Logger.Infow if Logger is not nil.

func (Resources) Observe
func (r Resources) Observe(name string, value float64)

Observe calls Monitor.Observe if Logger is not nil.

Documentation

Overview

package external defines some interfaces for external resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorw

func Errorw(msg string, keyvals ...interface{})

Errorw calls Errorw on the default Resources.

func Infow

func Infow(msg string, keyvals ...interface{})

Infow calls Infow on the default resources.

func Observe

func Observe(name string, value float64)

Observe calls Observe on the default Resources.

Types

type Logger

type Logger interface {
	Infow(msg string, keyvals ...interface{})
	Errorw(msg string, keyvals ...interface{})
}

Logger is used when logging is required. It is built to match the uber/zap SugaredLogger type.

type Monitor

type Monitor interface {
	Observe(name string, value float64)
}

Monitor is used to monitor rothko's operation.

type Resources

type Resources struct {
	Logger  Logger
	Monitor Monitor
}

Resources is a collection of all the external resources. It implements all of the methods of the fields but in a nil-safe way.

var Default Resources

Default is the default set of resources. Can be overridden by plugins.

func (Resources) Errorw

func (r Resources) Errorw(msg string, keyvals ...interface{})

Errorw calls Logger.Errorw if Logger is not nil.

func (Resources) Infow

func (r Resources) Infow(msg string, keyvals ...interface{})

Infow calls Logger.Infow if Logger is not nil.

func (Resources) Observe

func (r Resources) Observe(name string, value float64)

Observe calls Monitor.Observe if Logger is not nil.

Jump to

Keyboard shortcuts

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