service

package
v0.7.44 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 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 service is the toy stateful service behind mission #74's exercise (goapplib issue 75). Its ingest builds a compact result through a much larger scratch allocation, the way agni's engine parses and lays out a design, and it keeps the result between requests. The wasm main serves it from a Web Worker through wasmhost; the tests serve it natively.

Plain JSON over net/http rather than Connect: the mission is about state, memory and concurrency, and exercise/wasmhost already covers Connect over workerFetch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IngestRequest

type IngestRequest struct {
	PeakMB   int `json:"peakMB"`
	ResultMB int `json:"resultMB"`
}

IngestRequest sizes an ingest: PeakMB of scratch on the way to a ResultMB result.

type Service

type Service struct {
	Cache wasmhost.Cache
	// contains filtered or unexported fields
}

Service holds the result of the last ingest. Cache, when set, is where /open looks for a result before ingesting, and where it keeps one after.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves the service's four routes.

type State

type State struct {
	// IngestCount is how many ingests this process has run. A state restored from the cache
	// rather than rebuilt leaves it at 0.
	IngestCount int    `json:"ingestCount"`
	ResultBytes int    `json:"resultBytes"`
	Checksum    string `json:"checksum"`
	// LastJob is how the last /longjob ended: "", "completed" or "cancelled".
	LastJob string `json:"lastJob"`
	// Restored says the result came from the cache rather than an ingest.
	Restored bool `json:"restored"`
	// CacheError is the last cache failure other than a miss, for the exercise to show.
	CacheError string `json:"cacheError,omitempty"`
}

State is what GET /state reports.

Jump to

Keyboard shortcuts

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