bustest

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

type Fake struct {

	// Friends is which names of the roster are friends (the set `friends`);
	// the rest are machines. A test sets it before the first send.
	Friends []string
	// Fail, when set, is the error every command answers: a store that is down.
	Fail error
	// Lose, when set, is the answer of the next write of a message (AddAll
	// with streams, or AddOnce that writes): it commits, then its response is
	// lost. It is cleared by the write it answers.
	Lose error

	// FailForward, when set, is the answer of every receipt stamp (Forward):
	// a store that refuses the receipts hash alone.
	FailForward error
	// Trips counts the commands sent.
	Trips int
	// Sleep, when set, is what a BlockRead that finds nothing waits its block
	// out on: the test's clock, never real time.
	Sleep func(d time.Duration)
	// contains filtered or unexported fields
}

Fake is the Store in memory: the streams, the groups with their pending entries, the roster and a clock that moves one second per Roster call, so no test reads the real clock. It refuses what Redis refuses (a read of a group that is not there) and keeps the same idle-free claim order. A test makes its own with NewFake; nothing is shared.

func NewFake

func NewFake(start time.Time, names ...string) *Fake

NewFake is an empty store at the instant start whose roster is names.

func (*Fake) Ack

func (f *Fake) Ack(_ context.Context, stream, group string, entries ...string) (int64, error)

func (*Fake) AddAll

func (f *Fake) AddAll(_ context.Context, streams []string, fields map[string]string, marks ...bus.Mark) error

func (*Fake) AddOnce

func (f *Fake) AddOnce(_ context.Context, key, record string, keep time.Duration, streams []string, fields map[string]string, marks ...bus.Mark) (string, bool, error)

func (*Fake) Advance

func (f *Fake) Advance(d time.Duration)

Advance moves the clock by d: what a reader's idle time grows by.

func (*Fake) BlockRead

func (f *Fake) BlockRead(ctx context.Context, stream, after string, block time.Duration, count int) ([]bus.Entry, error)

BlockRead is the entries past the cursor, up to count, touching no group, so what it hands out stays a later recv's; a block that finds none waits its duration out on Sleep (SPEC-BUS.md, the verbs: wait).

func (*Fake) Claim

func (f *Fake) Claim(_ context.Context, stream, group, _ string, minIdle time.Duration, count int) ([]bus.Entry, error)

func (*Fake) EnsureGroup

func (f *Fake) EnsureGroup(_ context.Context, stream, group string) error

func (*Fake) Forward

func (f *Fake) Forward(_ context.Context, key, state string, ids ...string) ([]string, error)

func (*Fake) Get

func (f *Fake) Get(_ context.Context, stream string, entries []string) ([]bus.Entry, error)

func (*Fake) Group

func (f *Fake) Group(_ context.Context, stream, group string) (string, bool, error)

func (*Fake) Len

func (f *Fake) Len(stream string) int

Len is how many entries the stream holds.

func (*Fake) Marks

func (f *Fake) Marks(_ context.Context, keys ...string) ([]map[string]string, error)

func (*Fake) Members

func (f *Fake) Members(context.Context) ([]string, []string, time.Time, error)

func (*Fake) Pending

func (f *Fake) Pending(_ context.Context, stream, group string, count int) ([]string, error)

func (*Fake) Range

func (f *Fake) Range(_ context.Context, stream, from, to string, count int) ([]bus.Entry, error)

func (*Fake) Read

func (f *Fake) Read(_ context.Context, stream, group, _ string, _ time.Duration, count int) ([]bus.Entry, error)

func (*Fake) Release

func (f *Fake) Release(_ context.Context, stream, group string, entries ...string) error

func (*Fake) Roster

func (f *Fake) Roster(context.Context) ([]string, time.Time, error)

func (*Fake) Sent

func (f *Fake) Sent(_ context.Context, key string) (string, bool, error)

func (*Fake) Tail

func (f *Fake) Tail(ctx context.Context, stream string) (string, bool, error)

Tail is the stream's last entry id, as the wait arms at it; a stream with no entries answers "0-0" and not there (SPEC-BUS.md, the verbs: wait).

func (*Fake) Unmark

func (f *Fake) Unmark(_ context.Context, key string, fields ...string) (int64, error)

Jump to

Keyboard shortcuts

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