operational

package
v0.0.0-...-6ed8234 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package operational contains types and methods for monitoring the operations of the blobby cluster. It includes a HTTP server for serving raft/prometheus metrics.

Index

Constants

This section is empty.

Variables

View Source
var (
	// LogsApplied is the prometheus metric that counts the number of
	// types of raft logs that have been applied.
	LogsApplied = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: namespace,
		Name:      "logs_applied",
		Help:      "Number of raft logs that have been applied",
	}, []string{"op"})

	// BytesWritten is the prometheus metric that counts the number
	// of bytes written to the file system by clients.
	BytesWritten = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: namespace,
		Name:      "bytes_written",
		Help:      "Number of bytes written to the file system",
	})

	// BytesRead is the prometheus metric that counts the number
	// of bytes read from the file system by clients.
	BytesRead = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: namespace,
		Name:      "bytes_read",
		Help:      "Number of bytes read from the file system",
	})

	// GRPC is a collection of prometheus metrics for the gRPC
	// server.
	GRPC = grpc_prometheus.NewServerMetrics()
)

Functions

func InitialiseGRPC

func InitialiseGRPC(port int, register func(*grpc.Server)) (*grpc.Server, net.Listener, error)

InitialiseGRPC returns a *grpc.Server instance and a net.Listener instance of the given port. The 'register' parameter should be used to perform any operations on the server, like registering contracts etc.

func NewContext

func NewContext() context.Context

NewContext creates a new context.Context implementation that returns done when the program receives an os.Interrupt or syscall.SIGTERM call.

func NewServer

func NewServer(port int, rs RaftStats) *http.Server

NewServer creates a new *http.Server instance that serves prometheus metrics.

func RunAll

func RunAll(fns ...func() error) (err error)

RunAll runs each of the combined functions and creates an appended error of all non-nil errors.

func WithBackoff

func WithBackoff(attempts int, duration time.Duration, fn func() error) func() error

WithBackoff invokes 'fn', if it returns an error it will be retried after the desired duration. If 'fn' still returns an error after the maximum attempt, the error will be returned.

Types

type RaftStats

type RaftStats func() map[string]string

RaftStats is a function that returns a string key-value map containing raft statistics.

Jump to

Keyboard shortcuts

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