module

package module
v0.0.0-...-79ff044 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

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:

  1. Explicit Config field
  2. Environment variable (MUXCORE_GRPC_ADDR, MUXCORE_MODULE_ID)
  3. CLI flag (--muxcore-mesh-addr, --muxcore-module-id)
  4. 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

func Run(cfg Config) error

Run starts the module, connects to core, registers, and blocks until SIGTERM/SIGINT. Returns nil on clean shutdown.

func WaitForShutdown

func WaitForShutdown() os.Signal

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.

Jump to

Keyboard shortcuts

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