Documentation
¶
Overview ¶
Package greeter is the service's domain component: it serves HelloService over every public protocol with one implementation and raises Greeted after every greeting.
Index ¶
- Variables
- type Config
- type Greeted
- type Greeter
- func (g *Greeter) Alive(context.Context) error
- func (g *Greeter) Countdown(req *hellov1.CountdownRequest, ...) error
- func (g *Greeter) Greet(ctx context.Context, req *hellov1.GreetRequest) (*hellov1.GreetResponse, error)
- func (g *Greeter) Greeted() event.Ref[Greeted]
- func (g *Greeter) Ready(ctx context.Context) error
- func (g *Greeter) Record(ctx context.Context, name, text string)
- func (g *Greeter) Register(r grpc.ServiceRegistrar)
- func (g *Greeter) Text(ctx context.Context, name string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrSalute = errors.New("salute must not be empty") ErrSuffix = errors.New("suffix must be at most 8 characters on one line") // ErrStalled: the report loop has not ticked for three periods. ErrStalled = errors.New("greeter: report loop stalled") )
Errors of Validate.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Salute string `json:"salute" schemapb:"default=Hello;description=Word before the name"`
// Live: editable from the console, applied without restart.
Suffix config.Live[string] `json:"suffix" schemapb:"default=!;description=Appended to every greeting"`
Excited config.Live[bool] `json:"excited" schemapb:"default=false"`
}
Config of the greeter.
type Greeted ¶
type Greeted struct {
Name string `json:"name"`
Count uint64 `json:"count"`
Text string `json:"text,omitempty"`
}
Greeted is published after every greeting. Payloads evolve additively: Text was added after Name and Count, readers that predate it ignore it.
type Greeter ¶
type Greeter struct {
hellov1.UnimplementedHelloServiceServer
deps.Component
// contains filtered or unexported fields
}
Greeter is a component: a named node with its own logger, tracer and meter.
func New ¶
New creates the greeter under parent; everything it needs is passed in, the events it raises it declares itself.
func (*Greeter) Alive ¶
Alive is the greeter's liveness check: the report loop, once started, keeps ticking.
func (*Greeter) Countdown ¶
func (g *Greeter) Countdown( req *hellov1.CountdownRequest, stream grpc.ServerStreamingServer[hellov1.CountdownResponse], ) error
Countdown implements HelloService.
func (*Greeter) Greet ¶
func (g *Greeter) Greet(ctx context.Context, req *hellov1.GreetRequest) (*hellov1.GreetResponse, error)
Greet implements HelloService.
func (*Greeter) Record ¶
Record records the greeting actually delivered, whether rendered locally or returned by a bound hook. The same metric and event path serves both. Publication failure (for example, running without NATS) is logged without failing the greeting, just like Text.
func (*Greeter) Register ¶
func (g *Greeter) Register(r grpc.ServiceRegistrar)
Register is the one registration for native gRPC and ws-proto.