forwardtest

package
v1.4.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package forwardtest holds the fakes the forwarder's tests inject: a lease view, a runner that records its calls, and a Redis clock that a test can set apart from the wall clock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Kind        forward.Kind
	User, Group string
	Args        any
}

Call is one recorded Runner call.

type Clock

type Clock struct {
	Err error
	// contains filtered or unexported fields
}

Clock is a Redis clock a test sets.

func NewClock

func NewClock(ms int64) *Clock

NewClock starts at ms.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves the clock.

func (*Clock) RedisTimeMS

func (c *Clock) RedisTimeMS(context.Context) (int64, error)

type LeaseView

type LeaseView struct {
	Owners   map[string]forward.LeaseOwner
	HeldAt   map[string]int64
	Past     bool
	OwnerErr error
	// contains filtered or unexported fields
}

LeaseView is a settable forward.LeaseView.

func (*LeaseView) DeleteOwner

func (l *LeaseView) DeleteOwner(group string)

func (*LeaseView) Forget

func (l *LeaseView) Forget(string)

Forget is a no-op (the fake caches nothing); it lets the fake stand in for a caching view.

func (*LeaseView) Held

func (l *LeaseView) Held(group string) (int64, bool)

func (*LeaseView) Owner

func (l *LeaseView) Owner(_ context.Context, group string) (forward.LeaseOwner, error)

func (*LeaseView) PastDeadline

func (l *LeaseView) PastDeadline() bool

func (*LeaseView) SetOwner

func (l *LeaseView) SetOwner(group string, o forward.LeaseOwner)

SetOwner sets the lease row a group shows; DeleteOwner removes it; SetPast sets the local deadline verdict. They are safe to call while an Owner reads the view.

func (*LeaseView) SetPast

func (l *LeaseView) SetPast(p bool)

type Runner

type Runner struct {
	Reply forward.Result
	Err   error
	// Gate, when set, holds every call (after it is recorded) until it is closed or the call's context ends.
	Gate chan struct{}
	// contains filtered or unexported fields
}

Runner records its calls and answers with Reply (200 and an empty object by default) or Err.

func (*Runner) Calls

func (r *Runner) Calls() []Call

Calls returns a copy of the recorded calls.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, kind forward.Kind, user, group string, args any) (forward.Result, error)

Jump to

Keyboard shortcuts

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