mock

package
v0.0.0-...-8c998e4 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Mock types for debugging

Mock superwatcher.StateDataGateway

The idea here is simple - you init either of these types with a uint64, and that value is used as the lastRecordedBlock (i.e. the start point) for the emitter. Calling GetLastRecordedBlock on either of these types will return the same value, unless that value is changed with SetLastRecordedBlock.

  1. fakeRedisMem - an in-memory implementation Users can init this type easily with NewMock(x uint64, ok bool).

    If ok is true, NewMock will return an instance of fakeRedisMem with lastRecordedBlock set to x.

    If ok is false, NewMock will return an instance of fakeRedisMem, whose calls to GetLastRecordedBlock will always return ErrRecordNotFound unless SetLastRecordedBlock is called, to simulate the situation where the service has never run on the host and the Redis key is not found.

    Users can later overwrite the lastRecordedBlock values with *fakeRedisMem.SetLastRecordedBlock.

  2. fakeRedisFile - a file-based persistent implementation Users can init this type with NewMockFile(filename string, x uint64, ok bool)

    Because fakeRedisFile uses a file as its storage, users must give a valid file path string filename of the storage file. The other parameters to NewMockFile (x uint64 and ok bool) will translate to the same behavior as with fakeRedisMem.

    fakeRedisFile behaves and is used in the same way as fakeRedisMem, with the only difference being that this types saves the value to a file (via SetLastRecordedBlock) and retrieves the GetLastRecordedBlock return value from the file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataGatewayFile

func NewDataGatewayFile(filename string, lastRecordedBlock uint64, ok bool) superwatcher.StateDataGateway

NewDataGatewayFile returns a `superwatcher.StateDataGateway` with persistent file storage. If |ok| is false, `GetLastRecordedBlock` returns `ErrRecordNotFound` until the first call to `SetLastRecordedBlock` is made. If |ok| is true, `GetLastRecordedBlock` will keep returning |lastRecordedBlock| until the value is changed with `SetLastRecordedBlock`.

func NewDataGatewayMem

func NewDataGatewayMem(lastRecordedBlock uint64, ok bool) superwatcher.StateDataGateway

NewDataGatewayMem returns a `superwatcher.StateDataGateway`. If |ok| is false, `GetLastRecordedBlock` returns `ErrRecordNotFound` until the first call to `SetLastRecordedBlock` is made. If |ok| is true, `GetLastRecordedBlock` will keep returning |lastRecordedBlock| until the value is changed with `SetLastRecordedBlock`.

func NewPoller

func NewPoller(
	reorgedBlocks []uint64,
) superwatcher.EmitterPoller

Types

This section is empty.

Jump to

Keyboard shortcuts

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