formatter

package
v0.6.46 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 12 Imported by: 0

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