blog

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: 6 Imported by: 0

Documentation

Overview

Package blog contains interfaces to Akutan's data log.

Index

Constants

This section is empty.

Variables

View Source
var Factories = make(map[string]Factory)

Factories is a registry of named AkutanLog constructors.

Functions

func IsClosedError

func IsClosedError(err error) bool

IsClosedError returns true if err has type ClosedError, false otherwise.

func IsTruncatedError

func IsTruncatedError(err error) bool

IsTruncatedError returns true if err has type TruncatedError, false otherwise.

Types

type AkutanLog

type AkutanLog interface {
	// Append adds entries to the log. The data items might end up out of order in
	// the log and at non-consecutive indexes. If all the entries are appended
	// successfully, returns the corresponding indexes (in a slice the same length
	// as 'data') and nil. Otherwise, returns either a context error or a
	// ClosedError.
	Append(ctx context.Context, data [][]byte) ([]Index, error)

	// AppendSingle adds only a single entry to the log. If the entry is appended
	// successfully, returns its index and nil. Otherwise, returns either a context
	// error or a ClosedError.
	AppendSingle(ctx context.Context, data []byte) (Index, error)

	// Discard truncates the prefix of the log. After this is invoked, every entry
	// up to and excluding firstIndex is subject to deletion. If the server commits
	// to discarding the prefix, returns nil. Otherwise, returns either a context
	// error or a ClosedError.
	Discard(ctx context.Context, firstIndex Index) error

	// Read gets a suffix of the log and follows/tails the end of the log. nextIndex
	// is the index of the first entry to send on entriesCh. Read continues until it
	// encounters an error. Then it closes entriesCh and returns either a context
	// error, a TruncatedError, or a ClosedError.
	Read(ctx context.Context, nextIndex Index, entriesCh chan<- []Entry) error

	// Info fetches log metadata. Upon success, it returns the metadata and nil.
	// Otherwise, it returns either a context error or a ClosedError.
	Info(ctx context.Context) (*Info, error)

	// InfoStream subscribes to updates to log metadata. InfoStream continues until
	// it encounters an error. Then it closes infoCh and returns either a context
	// error or a ClosedError.
	InfoStream(ctx context.Context, infoCh chan<- *Info) error
}

A AkutanLog is a client to Akutan's data log.

func New

func New(ctx context.Context, cfg *config.Akutan) (AkutanLog, error)

New returns a new AkutanLog instance. It assumes the factory corresponding to cfg.AkutanLog (default "kafka") has been registered in the Factories map. It takes the same arguments as Factory.

It assumes that cfg.BrokerList is set to a list of host:port pairs.

type ClosedError

type ClosedError struct{}

A ClosedError is returned when attempting to use a AkutanLog after the log's background context has been canceled. This error indicates the AkutanLog instance is no longer useful and the process is likely shutting down.

func (ClosedError) Error

func (err ClosedError) Error() string

Error implements the method defined by 'error'.

type Disconnector

type Disconnector interface {
	// Disconnect closes the connection to the current server, without blocking. The
	// AkutanLog instance remains usable; it will automatically re-connect as needed.
	//
	// This is used by the logping package to measure the latency of different log
	// servers.
	Disconnect()
}

Disconnector is an optional interface that some AkutanLog implementations provide.

type Entry

type Entry = logspec.Entry

An Entry is an atomic unit in the log.

type Factory

type Factory = func(ctx context.Context, cfg *config.Akutan, servers discovery.Locator) (AkutanLog, error)

A Factory creates a AkutanLog instance. The only errors returned are fatal errors in the configuration.

A factory returns immediately. The given context is used for all background activity. Canceling it will close any connections to the log servers, abort current requests, and prevent future requests from opening new connections.

Note, however, that the Kafka factory is not well-behaved at this time.

type Index

type Index = uint64

An Index identifies entries in the log. It starts at 1.

type Info

type Info = logspec.InfoReply_OK

Info describes log metadata.

type TruncatedError

type TruncatedError struct {
	// The needed index that no longer exists.
	Requested Index
}

A TruncatedError is returned from Read when attempting to fetch deleted log entries.

func (TruncatedError) Error

func (err TruncatedError) Error() string

Error implements the method defined by 'error'.

Directories

Path Synopsis
Package kafka implements a Kafka client as a blog.AkutanLog.
Package kafka implements a Kafka client as a blog.AkutanLog.
Package logspecclient implements a client for the akutan/logspec API.
Package logspecclient implements a client for the akutan/logspec API.
Package mockblog contains an in-process, in-memory implementation of a Akutan log client and server.
Package mockblog contains an in-process, in-memory implementation of a Akutan log client and server.

Jump to

Keyboard shortcuts

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