module

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(module Module)

Types

type Config

type Config struct {
	// Active module
	Active bool `mapstructure:"active"`
}

func (*Config) IsActive

func (c *Config) IsActive() bool

type ConfigInterface

type ConfigInterface interface {
	IsActive() bool
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(modules []Module, shutdownNotify func(err error)) *Manager

func (*Manager) FindModule

func (m *Manager) FindModule(name string) Module

FindModule instance by module name

func (*Manager) ShutdownModules

func (m *Manager) ShutdownModules(err error)

ShutdownModules means close the rover instance dynamically

type Module

type Module interface {
	// Name of module.
	// It would be use when declaring this module into configuration or other module need to reference.
	Name() string

	// RequiredModules means which modules do this module is depended on,
	// The current module started after the dependent modules are Start success.
	RequiredModules() []string

	// Config of this module
	// The config is automatically read from the configuration file before module Start
	Config() ConfigInterface

	// Start module
	// The module needs to return the start result after startup is completed
	Start(ctx context.Context, mgr *Manager) error

	// NotifyStartSuccess when all module have been start success
	NotifyStartSuccess()

	// Shutdown module, the sequence of shutdown is the reverse of the module Start
	// The shutdown would trigger in the following cases
	// 1. If other modules fail to start
	// 2. The module is actively shutdown through Manager.ShutdownModules
	// 3. The Rover receive the close SIGNAL
	Shutdown(ctx context.Context, mgr *Manager) error
}

Module define

func FindModule

func FindModule(name string) Module

Jump to

Keyboard shortcuts

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