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 ¶
- type Log
- func (log *Log) Append(ctx context.Context, proposals [][]byte) ([]blog.Index, error)
- func (log *Log) AppendSingle(ctx context.Context, data []byte) (blog.Index, error)
- func (log *Log) AssertCommands(t assert.TestingT, start rpc.LogPosition, cmds []logencoder.ProtobufCommand) bool
- func (log *Log) DecodedEntries(start rpc.LogPosition) (decoded []logencoder.Entry, next rpc.LogPosition, err error)
- func (log *Log) Discard(ctx context.Context, firstIndex blog.Index) error
- func (log *Log) Entries(start blog.Index) ([]blog.Entry, error)
- func (log *Log) Info(ctx context.Context) (*blog.Info, error)
- func (log *Log) InfoStream(ctx context.Context, infoCh chan<- *blog.Info) error
- func (log *Log) Read(ctx context.Context, nextIndex blog.Index, entriesCh chan<- []blog.Entry) error
- func (log *Log) SetNextAppendError(err error)
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 ¶
New constructs a Log. ctx is a background context that can be closed to shut down readers.
func (*Log) AppendSingle ¶
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) Entries ¶
Entries returns all of the entries presently in the log, starting with the given index.
func (*Log) InfoStream ¶
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 ¶
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.