control

command
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

README

Control Plane Example

This example demonstrates the Control Plane features (v1.5+) of lifecycle.

Features Demonstrated

  1. Control Router: A mux-style event router (control.Router) that dispatches generic events to handlers.
  2. Event Sources:
    • OSSignalSource: Turns SIGINT/SIGTERM into generic events.
    • TickerSource: Emits periodic "Tick" events (headless progress).
  3. Managed Concurrency: Uses lifecycle.Go(ctx, fn) to spawn a background task that is automatically waited for during shutdown.
  4. Introspection: You can print router.Routes() to see registered handlers (not shown in output but available).

Run

go run ./examples/control/main.go

Expected Output:

Application started. Press Ctrl+C to exit.
[Background] Task started (will run for 2s)
[Router] Tick(2023-10-27T10:00:00Z)
[Router] Tick(...)
[Background] Task finished
...
(Press Ctrl+C)
[Router] Received Signal: Signal(interrupt)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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