mockblog

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

Documentation

Overview

Package mockblog contains an in-process, in-memory implementation of a Akutan log client and server. This is a high-level mock intended for unit testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

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

Log is an in-process, in-memory implementation of blog.AkutanLog. It logically includes both the client and the server.

func New

func New(ctx context.Context) *Log

New constructs a Log. ctx is a background context that can be closed to shut down readers.

func (*Log) Append

func (log *Log) Append(ctx context.Context, proposals [][]byte) ([]blog.Index, error)

Append implements the method declared in blog.AkutanLog.

func (*Log) AppendSingle

func (log *Log) AppendSingle(ctx context.Context, data []byte) (blog.Index, error)

AppendSingle implements the method declared in blog.AkutanLog.

func (*Log) AssertCommands

func (log *Log) AssertCommands(t assert.TestingT,
	start rpc.LogPosition, cmds []logencoder.ProtobufCommand) bool

AssertCommands causes the given test to fail if the entries in the log from the given starting position to not match the given commands. It returns true if the commands matched, false otherwise.

func (*Log) DecodedEntries

func (log *Log) DecodedEntries(start rpc.LogPosition,
) (decoded []logencoder.Entry, next rpc.LogPosition, err error)

DecodedEntries returns all of the entries presently in the log, starting with the given position, already decoded into Akutan log commands.

func (*Log) Discard

func (log *Log) Discard(ctx context.Context, firstIndex blog.Index) error

Discard implements the method declared in blog.AkutanLog.

func (*Log) Entries

func (log *Log) Entries(start blog.Index) ([]blog.Entry, error)

Entries returns all of the entries presently in the log, starting with the given index.

func (*Log) Info

func (log *Log) Info(ctx context.Context) (*blog.Info, error)

Info implements the method declared in blog.AkutanLog.

func (*Log) InfoStream

func (log *Log) InfoStream(ctx context.Context, infoCh chan<- *blog.Info) error

InfoStream implements the method declared in blog.AkutanLog.

func (*Log) Read

func (log *Log) Read(ctx context.Context, nextIndex blog.Index, entriesCh chan<- []blog.Entry) error

Read implements the method declared in blog.AkutanLog.

func (*Log) SetNextAppendError

func (log *Log) SetNextAppendError(err error)

SetNextAppendError causes the next call to AppendSingle or Append to return the given error, without appending anything. Only the next call is affected; subsequent appends will proceed as normal.

Jump to

Keyboard shortcuts

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