Help us shape the future of Go! Take the 2026 Go Developer Survey

memrepo

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package memrepo is an in-memory repository.ServerlessRepository for unit tests of the serverless operator core and leaser. It implements the methods the core uses and records the writes tests assert on. Methods the core never calls are left to the embedded nil interface and panic when reached.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionWrite

type ActionWrite struct {
	Actions          []string
	StreamActions    []string
	EndpointId       uuid.UUID
	DurableSupported bool
}

ActionWrite is one UpdateRegisteredActions call.

type Repo

type Repo struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

Repo is the in-memory repository. Every method is safe for concurrent use.

func New

func New() *Repo

func (*Repo) ActionWrites

func (r *Repo) ActionWrites() []ActionWrite

func (*Repo) AddEndpoint

func (r *Repo) AddEndpoint(ep *sqlcv1.V1ServerlessEndpoint)

AddEndpoint stores a copy of ep, stamps updated_at, and creates or bumps its lease unit.

func (*Repo) ByIdsCalls

func (r *Repo) ByIdsCalls() int

func (*Repo) ClaimCalls

func (r *Repo) ClaimCalls() []int32

func (*Repo) DeletedProcs

func (r *Repo) DeletedProcs() []uuid.UUID

func (*Repo) Endpoint

func (r *Repo) Endpoint(id uuid.UUID) *sqlcv1.V1ServerlessEndpoint

Endpoint returns a copy of a stored endpoint.

func (*Repo) Endpoints

func (*Repo) Heartbeats

func (r *Repo) Heartbeats() []repository.UpsertServerlessProcessOpts

func (*Repo) Lease

func (r *Repo) Lease(unit Unit) *sqlcv1.V1ServerlessLease

Lease returns a copy of a lease row.

func (*Repo) Leases

func (*Repo) ListForTenantCalls

func (r *Repo) ListForTenantCalls() int

ListForTenantCalls counts full loads; ListSinceCalls counts incremental refreshes.

func (*Repo) ListSinceCalls

func (r *Repo) ListSinceCalls() int

func (*Repo) ListVersionsCalls

func (r *Repo) ListVersionsCalls() int

ListVersionsCalls counts anti-entropy version pages; ByIdsCalls counts fetches of changed rows by id; ReadRows counts every endpoint row returned in full.

func (*Repo) Processes

func (*Repo) ReadRows

func (r *Repo) ReadRows() int

func (*Repo) ReleaseAlls

func (r *Repo) ReleaseAlls() int

func (*Repo) RemoveEndpoint

func (r *Repo) RemoveEndpoint(id uuid.UUID)

RemoveEndpoint hard-deletes an endpoint and decrements its unit's count. RemoveEndpoint deletes the endpoint the way the API does: the row is marked deleted and versioned by the deletion, so only ListUpdatedSince returns it, and the lease unit's count drops. PurgeDeleted removes the row.

func (*Repo) SetEntitled

func (r *Repo) SetEntitled(tenantId uuid.UUID, entitled bool)

SetEntitled switches the tenant's serverless entitlement; tenants start entitled.

func (*Repo) SetFailWrites

func (r *Repo) SetFailWrites(err error)

SetFailWrites makes every write fail with err until called with nil.

func (*Repo) SetLease

func (r *Repo) SetLease(unit Unit, owner *uuid.UUID, endpointCount int32)

SetLease creates or overwrites a lease row.

func (*Repo) SetProcess

func (r *Repo) SetProcess(id uuid.UUID, unitCount, endpointCount int32, expired bool)

SetProcess creates or overwrites a process row.

func (*Repo) ShedCalls

func (r *Repo) ShedCalls() [][]Unit

func (*Repo) StatusWrites

func (r *Repo) StatusWrites() []StatusWrite

func (*Repo) Tenants

func (*Repo) UpdateEndpoint

func (r *Repo) UpdateEndpoint(id uuid.UUID, fn func(ep *sqlcv1.V1ServerlessEndpoint))

UpdateEndpoint mutates a stored endpoint and bumps updated_at.

type StatusWrite

type StatusWrite struct {
	Error      *string
	EndpointId uuid.UUID
	Healthy    bool
}

StatusWrite is one UpdateStatus call.

type Unit

Unit aliases the lease unit.

Jump to

Keyboard shortcuts

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