hello

package
v1.22.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Hostname = helloapi.Hostname
	Version  = 325
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate added in v1.22.0

type Intermediate struct {
	*connector.Connector
	ToDo
}

Intermediate extends and customizes the generic base connector.

func NewIntermediate added in v1.22.0

func NewIntermediate(impl ToDo) *Intermediate

NewIntermediate creates a new instance of the intermediate.

func (*Intermediate) Greeting added in v1.22.0

func (svc *Intermediate) Greeting() (value string)

Greeting to use.

func (*Intermediate) Repeat added in v1.22.0

func (svc *Intermediate) Repeat() (value int)

Repeat indicates how many times to display the greeting.

func (*Intermediate) SetGreeting added in v1.22.0

func (svc *Intermediate) SetGreeting(value string) (err error)

SetGreeting sets the value of the configuration property.

func (*Intermediate) SetRepeat added in v1.22.0

func (svc *Intermediate) SetRepeat(value int) (err error)

SetRepeat sets the value of the configuration property.

type Mock

type Mock struct {
	*Intermediate
	// contains filtered or unexported fields
}

Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.

func NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

func (*Mock) BusPNG added in v1.22.0

func (svc *Mock) BusPNG(w http.ResponseWriter, r *http.Request) (err error)

BusPNG executes the mock handler.

func (*Mock) Calculator added in v1.22.0

func (svc *Mock) Calculator(w http.ResponseWriter, r *http.Request) (err error)

Calculator executes the mock handler.

func (*Mock) Echo added in v1.22.0

func (svc *Mock) Echo(w http.ResponseWriter, r *http.Request) (err error)

Echo executes the mock handler.

func (*Mock) Hello added in v1.22.0

func (svc *Mock) Hello(w http.ResponseWriter, r *http.Request) (err error)

Hello executes the mock handler.

func (*Mock) Localization added in v1.22.0

func (svc *Mock) Localization(w http.ResponseWriter, r *http.Request) (err error)

Localization executes the mock handler.

func (*Mock) MockBusPNG added in v1.22.0

func (svc *Mock) MockBusPNG(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockBusPNG sets up a mock handler for BusPNG.

func (*Mock) MockCalculator added in v1.22.0

func (svc *Mock) MockCalculator(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockCalculator sets up a mock handler for Calculator.

func (*Mock) MockEcho added in v1.22.0

func (svc *Mock) MockEcho(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockEcho sets up a mock handler for Echo.

func (*Mock) MockHello added in v1.22.0

func (svc *Mock) MockHello(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockHello sets up a mock handler for Hello.

func (*Mock) MockLocalization added in v1.22.0

func (svc *Mock) MockLocalization(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockLocalization sets up a mock handler for Localization.

func (*Mock) MockPing added in v1.22.0

func (svc *Mock) MockPing(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockPing sets up a mock handler for Ping.

func (*Mock) MockRoot added in v1.22.0

func (svc *Mock) MockRoot(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockRoot sets up a mock handler for Root.

func (*Mock) MockTickTock added in v1.22.0

func (svc *Mock) MockTickTock(handler func(ctx context.Context) (err error)) *Mock

MockTickTock sets up a mock handler for TickTock.

func (*Mock) OnShutdown added in v1.22.0

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup added in v1.22.0

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Mock) Ping added in v1.22.0

func (svc *Mock) Ping(w http.ResponseWriter, r *http.Request) (err error)

Ping executes the mock handler.

func (*Mock) Root added in v1.22.0

func (svc *Mock) Root(w http.ResponseWriter, r *http.Request) (err error)

Root executes the mock handler.

func (*Mock) TickTock added in v1.22.0

func (svc *Mock) TickTock(ctx context.Context) (err error)

TickTock executes the mock handler.

type Service

type Service struct {
	*Intermediate // IMPORTANT: Do not remove
}

Service implements the hello.example microservice.

The Hello microservice demonstrates the various capabilities of a microservice.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) BusPNG

func (svc *Service) BusPNG(w http.ResponseWriter, r *http.Request) (err error)

BusPNG serves an image from the embedded resources.

func (*Service) Calculator

func (svc *Service) Calculator(w http.ResponseWriter, r *http.Request) error

Calculator renders a UI for a calculator. The calculation operation is delegated to another microservice in order to demonstrate a call from one microservice to another.

func (*Service) Echo

func (svc *Service) Echo(w http.ResponseWriter, r *http.Request) error

Echo back the incoming request in wire format.

func (*Service) Hello

func (svc *Service) Hello(w http.ResponseWriter, r *http.Request) error

Hello prints a greeting.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

func (*Service) Localization

func (svc *Service) Localization(w http.ResponseWriter, r *http.Request) (err error)

Localization prints hello in the language best matching the request's Accept-Language header.

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Service) Ping

func (svc *Service) Ping(w http.ResponseWriter, r *http.Request) error

Ping all microservices and list them.

func (*Service) Root

func (svc *Service) Root(w http.ResponseWriter, r *http.Request) (err error)

Root is the top-most root page.

func (*Service) TickTock

func (svc *Service) TickTock(ctx context.Context) error

TickTock is executed every 10 seconds.

type ToDo added in v1.22.0

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Hello(w http.ResponseWriter, r *http.Request) error              // MARKER: Hello
	Echo(w http.ResponseWriter, r *http.Request) error               // MARKER: Echo
	Ping(w http.ResponseWriter, r *http.Request) error               // MARKER: Ping
	Calculator(w http.ResponseWriter, r *http.Request) error         // MARKER: Calculator
	BusPNG(w http.ResponseWriter, r *http.Request) (err error)       // MARKER: BusPNG
	Localization(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Localization
	Root(w http.ResponseWriter, r *http.Request) (err error)         // MARKER: Root
	TickTock(ctx context.Context) error                              // MARKER: TickTock
}

ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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