database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrationFS

func MigrationFS() fs.FS

MigrationFS exposes the canonical SQL migrations without global registration.

Types

type AcceptOutputTruncationParams added in v0.3.0

type AcceptOutputTruncationParams struct {
	Sequence sql.NullInt64
	Reason   string
	RunID    string
}

type AcknowledgeOutputRunParams added in v0.3.0

type AcknowledgeOutputRunParams struct {
	AcknowledgedSequence int64
	Bytes                int64
	Frames               int64
	EndAcknowledged      bool
	RunID                string
}

type AdvanceOutputRunParams added in v0.3.0

type AdvanceOutputRunParams struct {
	Bytes int64
	RunID string
}

type CommaSeparatedList

type CommaSeparatedList []string

CommaSeparatedList allows lists of strings to be stored in a single database column as a comma-separated string, with each string base64-encoded to handle special characters and commas within the strings themselves.

func (*CommaSeparatedList) Scan

func (b *CommaSeparatedList) Scan(src any) error

func (CommaSeparatedList) Value

func (b CommaSeparatedList) Value() (driver.Value, error)

type CreateBoundedDebugletParams added in v0.3.0

type CreateBoundedDebugletParams struct {
	Uuid                  uuid.UUID
	StartTime             UTCTime
	Args                  CommaSeparatedList
	Wasm                  []byte
	TransactionID         string
	FloorBw               int64
	CeilBw                int64
	TimeoutMs             int64
	Addresses             CommaSeparatedList
	RequireIcmp           bool
	ListenUdp             bool
	ListenTcp             bool
	ListenScion           bool
	DispatcherIncarnation string
	SessionID             string
	EgressGrant           []byte
	MaxQueuedRuns         int64
	MaxQueuedBytes        int64
	QueueBytes            int64
}

type CreateDebugletParams

type CreateDebugletParams struct {
	Uuid                  uuid.UUID
	StartTime             UTCTime
	Args                  CommaSeparatedList
	Wasm                  []byte
	TransactionID         string
	FloorBw               int64
	CeilBw                int64
	TimeoutMs             int64
	Addresses             CommaSeparatedList
	RequireIcmp           bool
	ListenUdp             bool
	ListenTcp             bool
	ListenScion           bool
	DispatcherIncarnation string
	SessionID             string
}

type CreateOutputFrameParams added in v0.3.0

type CreateOutputFrameParams struct {
	RunID       string
	Sequence    int64
	TimestampNs int64
	Output      []byte
}

type CreateOutputRunParams added in v0.3.0

type CreateOutputRunParams struct {
	RunID                 string
	DispatcherIncarnation string
	SessionID             string
	OutputVersion         int64
}

type CreateTeslaChainParams

type CreateTeslaChainParams struct {
	Generation      int64
	Anchor          []byte
	EpochBase       time.Time
	DelayNs         int64
	ChainLength     int64
	CreatedAt       time.Time
	DisclosureDelay sql.NullInt64
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Debuglet

type Debuglet struct {
	ID                    int64
	Uuid                  uuid.UUID
	StartTime             UTCTime
	Args                  CommaSeparatedList
	Wasm                  []byte
	TransactionID         string
	FloorBw               int64
	CeilBw                int64
	TimeoutMs             int64
	Addresses             CommaSeparatedList
	RequireIcmp           bool
	ListenUdp             bool
	ListenTcp             bool
	ListenScion           bool
	StartedAt             UTCTime
	DispatcherIncarnation string
	SessionID             string
	EgressGrant           []byte
}

type DebugletExit

type DebugletExit struct {
	DebugletID            string
	DispatcherIncarnation string
	SessionID             string
	ExitCode              int64
	ErrorMessage          sql.NullString
	RecordedAt            UTCTime
	Attempts              int64
	LastAttemptAt         UTCTime
	LastError             string
	Rejected              bool
}

type DebugletLog

type DebugletLog struct {
	ID         int64
	DebugletID int64
	Timestamp  time.Time
	Output     []byte
}

type DeleteAcknowledgedOutputParams added in v0.3.0

type DeleteAcknowledgedOutputParams struct {
	RunID    string
	Sequence int64
}

type FinishOutputRunParams added in v0.3.0

type FinishOutputRunParams struct {
	Status string
	Reason string
	RunID  string
}

type GetDebugletIdentityRow

type GetDebugletIdentityRow struct {
	Uuid                  uuid.UUID
	DispatcherIncarnation string
	SessionID             string
	TransactionID         string
	StartTime             UTCTime
	StartedAt             UTCTime
}

type GetOwnedDebugletByUUIDParams

type GetOwnedDebugletByUUIDParams struct {
	Uuid                  uuid.UUID
	DispatcherIncarnation string
	SessionID             string
}

type ListDebugletExitsForBindingParams

type ListDebugletExitsForBindingParams struct {
	DispatcherIncarnation string
	SessionID             string
	Limit                 int64
}

type ListDebugletsParams

type ListDebugletsParams struct {
	Limit  int64
	Offset int64
}

type ListOutputFramesParams added in v0.3.0

type ListOutputFramesParams struct {
	RunID    string
	Sequence int64
	Limit    int64
}

type ListPendingOutputRunsParams added in v0.3.0

type ListPendingOutputRunsParams struct {
	RunID string
	Limit int64
}

type NoteDebugletExitFailureParams

type NoteDebugletExitFailureParams struct {
	Attempts              int64
	LastAttemptAt         UTCTime
	LastError             string
	Rejected              bool
	DebugletID            string
	DispatcherIncarnation string
	SessionID             string
}

type OperatorDisposition added in v0.3.0

type OperatorDisposition struct {
	RunID        string
	RecordedAtNs int64
	Reason       string
}

type OutputFrame added in v0.3.0

type OutputFrame struct {
	RunID       string
	Sequence    int64
	TimestampNs int64
	Output      []byte
}

type OutputRun added in v0.3.0

type OutputRun struct {
	RunID                 string
	DispatcherIncarnation string
	SessionID             string
	OutputVersion         int64
	LastSequence          int64
	AcknowledgedSequence  int64
	EmittedBytes          int64
	QueuedBytes           int64
	QueuedFrames          int64
	Status                string
	Reason                string
	EndAcknowledged       bool
	ReceiptSequence       sql.NullInt64
	ReceiptReason         string
}

type OutputUsage added in v0.3.0

type OutputUsage struct {
	Singleton    int64
	ChargedBytes int64
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AbandonOutputRun added in v0.3.0

func (q *Queries) AbandonOutputRun(ctx context.Context, runID string) error

func (*Queries) AcceptOutputTruncation added in v0.3.0

func (q *Queries) AcceptOutputTruncation(ctx context.Context, arg AcceptOutputTruncationParams) error

func (*Queries) AcknowledgeOutputRun added in v0.3.0

func (q *Queries) AcknowledgeOutputRun(ctx context.Context, arg AcknowledgeOutputRunParams) error

func (*Queries) AddOutputUsage added in v0.3.0

func (q *Queries) AddOutputUsage(ctx context.Context, chargedBytes int64) error

func (*Queries) AdvanceOutputRun added in v0.3.0

func (q *Queries) AdvanceOutputRun(ctx context.Context, arg AdvanceOutputRunParams) error

func (*Queries) CountDebugletExits

func (q *Queries) CountDebugletExits(ctx context.Context) (int64, error)

func (*Queries) CountOutputRuns added in v0.3.0

func (q *Queries) CountOutputRuns(ctx context.Context) (int64, error)

A run whose end the dispatcher acknowledged holds no further spool capacity.

func (*Queries) CreateBoundedDebuglet added in v0.3.0

func (q *Queries) CreateBoundedDebuglet(ctx context.Context, arg CreateBoundedDebugletParams) (int64, error)

The durable rows are the reservations. Keeping the quota predicate inside this INSERT makes concurrent admission and crash recovery use the same accounting, without a separate counter that can drift from retained work. Existing UUIDs still reach the UNIQUE constraint even when the queue is full.

func (*Queries) CreateDebuglet

func (q *Queries) CreateDebuglet(ctx context.Context, arg CreateDebugletParams) error

func (*Queries) CreateOutputFrame added in v0.3.0

func (q *Queries) CreateOutputFrame(ctx context.Context, arg CreateOutputFrameParams) error

func (*Queries) CreateOutputRun added in v0.3.0

func (q *Queries) CreateOutputRun(ctx context.Context, arg CreateOutputRunParams) error

func (*Queries) CreateTeslaChain

func (q *Queries) CreateTeslaChain(ctx context.Context, arg CreateTeslaChainParams) error

func (*Queries) DeleteAcknowledgedOutput added in v0.3.0

func (q *Queries) DeleteAcknowledgedOutput(ctx context.Context, arg DeleteAcknowledgedOutputParams) error

func (*Queries) DeleteDebuglet

func (q *Queries) DeleteDebuglet(ctx context.Context, argUuid uuid.UUID) error

func (*Queries) FinishOutputRun added in v0.3.0

func (q *Queries) FinishOutputRun(ctx context.Context, arg FinishOutputRunParams) error

func (*Queries) GetDebugletByUUID

func (q *Queries) GetDebugletByUUID(ctx context.Context, argUuid uuid.UUID) (Debuglet, error)

func (*Queries) GetDebugletExit

func (q *Queries) GetDebugletExit(ctx context.Context, debugletID string) (DebugletExit, error)

func (*Queries) GetDebugletIdentity

func (q *Queries) GetDebugletIdentity(ctx context.Context, argUuid uuid.UUID) (GetDebugletIdentityRow, error)

Identity, original binding and start marker only: inspection never reads the stored WASM blob or arguments.

func (*Queries) GetDebugletStarted

func (q *Queries) GetDebugletStarted(ctx context.Context, argUuid uuid.UUID) (UTCTime, error)

func (*Queries) GetOutputRun added in v0.3.0

func (q *Queries) GetOutputRun(ctx context.Context, runID string) (OutputRun, error)

func (*Queries) GetOutputUsage added in v0.3.0

func (q *Queries) GetOutputUsage(ctx context.Context) (int64, error)

func (*Queries) GetOwnedDebugletByUUID

func (q *Queries) GetOwnedDebugletByUUID(ctx context.Context, arg GetOwnedDebugletByUUIDParams) (Debuglet, error)

func (*Queries) GetTeslaChain added in v0.3.0

func (q *Queries) GetTeslaChain(ctx context.Context, generation int64) (TeslaChain, error)

func (*Queries) InterruptOpenOutputRuns added in v0.3.0

func (q *Queries) InterruptOpenOutputRuns(ctx context.Context) error

func (*Queries) ListDebugletExits

func (q *Queries) ListDebugletExits(ctx context.Context, limit int64) ([]DebugletExit, error)

func (*Queries) ListDebugletExitsForBinding

func (q *Queries) ListDebugletExitsForBinding(ctx context.Context, arg ListDebugletExitsForBindingParams) ([]DebugletExit, error)

Only a session's own deliverable results, so results no session can deliver cannot crowd out the ones that can be.

func (*Queries) ListDebuglets

func (q *Queries) ListDebuglets(ctx context.Context, arg ListDebugletsParams) ([]Debuglet, error)

func (*Queries) ListOutputFrames added in v0.3.0

func (q *Queries) ListOutputFrames(ctx context.Context, arg ListOutputFramesParams) ([]OutputFrame, error)

func (*Queries) ListPendingOutputRuns added in v0.3.0

func (q *Queries) ListPendingOutputRuns(ctx context.Context, arg ListPendingOutputRunsParams) ([]OutputRun, error)

func (*Queries) ListTeslaChains

func (q *Queries) ListTeslaChains(ctx context.Context) ([]TeslaChain, error)

func (*Queries) NextTeslaChainGeneration

func (q *Queries) NextTeslaChainGeneration(ctx context.Context) (int64, error)

func (*Queries) NoteDebugletExitFailure

func (q *Queries) NoteDebugletExitFailure(ctx context.Context, arg NoteDebugletExitFailureParams) (int64, error)

func (*Queries) RecordDebugletExit

func (q *Queries) RecordDebugletExit(ctx context.Context, arg RecordDebugletExitParams) error

The first write wins: a duplicate report never rewrites the chosen result.

func (*Queries) ReleaseDebugletExit

func (q *Queries) ReleaseDebugletExit(ctx context.Context, arg ReleaseDebugletExitParams) (int64, error)

func (*Queries) SumAcknowledgedOutput added in v0.3.0

func (q *Queries) SumAcknowledgedOutput(ctx context.Context, arg SumAcknowledgedOutputParams) (SumAcknowledgedOutputRow, error)

func (*Queries) UpdateDebugletStarted

func (q *Queries) UpdateDebugletStarted(ctx context.Context, arg UpdateDebugletStartedParams) (Debuglet, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type RecordDebugletExitParams

type RecordDebugletExitParams struct {
	DebugletID            string
	DispatcherIncarnation string
	SessionID             string
	ExitCode              int64
	ErrorMessage          sql.NullString
	RecordedAt            UTCTime
}

type ReleaseDebugletExitParams

type ReleaseDebugletExitParams struct {
	DebugletID            string
	DispatcherIncarnation string
	SessionID             string
}

type SumAcknowledgedOutputParams added in v0.3.0

type SumAcknowledgedOutputParams struct {
	RunID    string
	Sequence int64
}

type SumAcknowledgedOutputRow added in v0.3.0

type SumAcknowledgedOutputRow struct {
	ByteCount  int64
	FrameCount int64
}

type TeslaChain

type TeslaChain struct {
	Generation      int64
	Anchor          []byte
	EpochBase       time.Time
	DelayNs         int64
	ChainLength     int64
	CreatedAt       time.Time
	DisclosureDelay sql.NullInt64
}

type UTCTime

type UTCTime struct {
	time.Time
}

UTCTime is a wrapper around time.Time that ensures the time is always stored and retrieved in UTC.

func NewUTCTime

func NewUTCTime(t time.Time) UTCTime

func (*UTCTime) Scan

func (t *UTCTime) Scan(src any) error

func (UTCTime) Value

func (t UTCTime) Value() (driver.Value, error)

type UpdateDebugletStartedParams

type UpdateDebugletStartedParams struct {
	StartedAt UTCTime
	Uuid      uuid.UUID
}

Jump to

Keyboard shortcuts

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