logping

package
v0.0.0-...-6719cd2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package logping measures the latency of Akutan's log by appending to it and reading from it. The purpose of this package is to provide continuous run-time metrics (not just benchmarks) about the log's health and performance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetReplayPosition

type GetReplayPosition func(context.Context) (rpc.LogPosition, error)

GetReplayPosition returns the latest known log position (index and version). This is where reading the log will begin. It continues retrying until it succeeds; the only error it returns is a context error.

type LogAppender

type LogAppender interface {
	AppendSingle(ctx context.Context, data []byte) (blog.Index, error)
}

LogAppender defines a subset of the blog.AkutanLog interface for appending. The Pinger uses a different AkutanLog for reads.

type Options

type Options struct {
	// If set, the Pinger will append PingCommand entries to the log using this.
	// Otherwise, it will open its own AkutanLog with blog.New.
	Appender LogAppender
	// Once one ping command is read from the log, how long to wait before writing
	// the next one to the log. The zero value defaults to 1s.
	PingInterval time.Duration
	// After this many pings, the Pinger will disconnect from the server it's
	// reading from and immediately re-connect to some log server. This is used to
	// measure latency to different servers, in case some are faster than others.
	//
	// This feature is not available with every AkutanLog instance (it requires an
	// optional Disconnect method). If the AkutanLog instance doesn't support it or
	// this is zero, the Pinger will never artificially disconnect.
	PingsUntilDisconnect uint64
	// contains filtered or unexported fields
}

Options define optional arguments to New. The zero value of Options is usable.

type Pinger

type Pinger struct {
	// contains filtered or unexported fields
}

A Pinger measures the log's latency. It must be constructed with New.

func New

func New(
	backgroundCtx context.Context,
	cfg *config.Akutan, getReplayPosition GetReplayPosition,
	options Options,
) (*Pinger, error)

New constructs a new Pinger. The Pinger will not do anything until Run is called. The given context is for the background activity of the Pinger, not just for the call to New. The cfg is used to construct AkutanLog instances.

func (*Pinger) LastApplied

func (pinger *Pinger) LastApplied() blog.Index

LastApplied returns the last applied log index. This method is thread safe.

func (*Pinger) Run

func (pinger *Pinger) Run()

Run is a long-running goroutine that measures log latency. Run returns once the context given to New is canceled. Run may only be called once per Pinger.

Jump to

Keyboard shortcuts

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