Documentation
¶
Overview ¶
Package module provides a framework for building MuxCore sidecar modules.
The SDK handles the full module lifecycle: connecting to core, registering, handling shutdown signals, and unregistering on exit.
Basic usage (sidecar module) ¶
func main() {
modulesdk.Run(modulesdk.Config{
Module: myModule,
})
}
CLI tool usage (client only, no registration) ¶
conn, cleanup := modulesdk.Connect(modulesdk.ConnectConfig{
OnConnect: func(c *grpc.ClientConn) {
// use c to create service clients
},
})
defer cleanup()
Config resolution priority:
- Explicit Config field
- Environment variable (MUXCORE_GRPC_ADDR, MUXCORE_MODULE_ID)
- CLI flag (--muxcore-mesh-addr, --muxcore-module-id)
- Module.Info().ID (for module ID only)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(cfg ConnectConfig) (*grpc.ClientConn, error)
Connect opens a gRPC connection to core and returns it. The caller must close the connection when done.
Config is resolved from the same sources as Run (env vars, CLI flags).
func Run ¶
Run starts the module, connects to core, registers, and blocks until SIGTERM/SIGINT. Returns nil on clean shutdown.
func WaitForShutdown ¶
WaitForShutdown blocks until SIGTERM or SIGINT, then returns the signal. Useful for CLI tools that connect to core and need to block until shutdown.
Types ¶
type Config ¶
type Config struct {
// Module is the module implementation. Required.
Module contracts.Module
// GRPCAddr is the core gRPC address (host:port).
// If empty, reads from MUXCORE_GRPC_ADDR or --muxcore-mesh-addr.
GRPCAddr string
// ModuleID overrides the module identifier.
// If empty, reads from MUXCORE_MODULE_ID, --muxcore-module-id,
// then falls back to Module.Info().ID.
ModuleID string
// Insecure disables TLS. Use for development only.
Insecure bool
}
Config configures a sidecar module's lifecycle.
type ConnectConfig ¶
type ConnectConfig struct {
// GRPCAddr is the core gRPC address (host:port).
// If empty, reads from MUXCORE_GRPC_ADDR or --muxcore-mesh-addr.
GRPCAddr string
// Insecure disables TLS for development.
Insecure bool
}
ConnectConfig configures a client-only connection to core.