formatter

package
v0.6.125 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 12 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 formatter is an independent service capability. It does not import hello: bindings adapt its activity payloads, and its reactor owns a local copy of the event fields it needs.

Index

Constants

This section is empty.

Variables

View Source
var API []byte

API describes the process-local statistics served by HTTP.

View Source
var ErrName = errors.New("formatter: name must not be empty")

Functions

This section is empty.

Types

type Config

type Config struct {
	Prefix config.Live[string] `json:"prefix" schemapb:"default=Welcome"`
	Suffix config.Live[string] `json:"suffix" schemapb:"default=!"`
}

type Formatter

type Formatter struct {
	deps.Component
	// contains filtered or unexported fields
}

Formatter records process-local example statistics. Deduplication retains the last 4096 keys; a real business store persists them transactionally.

func New

func New(parent deps.Scope, cfg *Config) *Formatter

func (*Formatter) Format

func (f *Formatter) Format(_ context.Context, in Input) (Output, error)

func (*Formatter) HTTP

func (f *Formatter) HTTP() http.Handler

HTTP exposes the example's counters, including the bound greeting's text.

func (*Formatter) Observe

func (f *Formatter) Observe(ctx context.Context, in Greeting) error

func (*Formatter) Record

func (f *Formatter) Record(ctx context.Context, in Greeting) (Receipt, error)

func (*Formatter) Snapshot

func (f *Formatter) Snapshot() Stats

type Greeting

type Greeting struct {
	Name string `json:"name"`
	Text string `json:"text"`
}

Greeting is this service's additive view of hello.Greeted, with no source import.

type Input

type Input struct {
	Name string `json:"name"`
}

type Output

type Output struct {
	Text string `json:"text"`
}

type Receipt

type Receipt struct {
	Count uint64 `json:"count"`
	Key   string `json:"key"`
}

type Stats

type Stats struct {
	Formatted uint64 `json:"formatted"`
	Recorded  uint64 `json:"recorded"`
	Observed  uint64 `json:"observed"`
	LastText  string `json:"last_text"`
}

Jump to

Keyboard shortcuts

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