modules

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 5 Imported by: 21

README

Getting Started with modules

What's the use?

Use instead of func init() { } to accomplish what you expect by an explicit initialization sequence

What modules are available for farseer-go?

  • cache.Module
  • cacheMemory.Module
  • data.Module
  • elasticSearch.Module
  • eventBus.Module
  • fss.Module
  • queue.Module
  • rabbit.Module
  • redis.Module
  • tasks.Module

Add your StartupModule Files

type StartupModule struct {
}

// Dependent modules
func (module StartupModule) DependsModule() []modules.FarseerModule {
    return []modules.FarseerModule{interfaces.Module{}, infrastructure.Module{}}
}

// Pre-initialization
func (module StartupModule) PreInitialize() {
}

// Initialize
func (module StartupModule) Initialize() {
}

// PostInitialize
func (module StartupModule) PostInitialize() {
}

// Shutdown
func (module StartupModule) Shutdown() {
}

DependsModule

DependsModule is used to load modules that you need to depend on, such as data.Module, redis.Module, cache.Module, or your business module

Initialization

// First all dependent modules will be loaded according to DependsModule's dependencies.
// and perform the initialization of each module in the order of dependency
fs.Initialize[StartupModule]("FOPS")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoad

func IsLoad(module FarseerModule) bool

IsLoad 模块是否加载

func ShutdownModules

func ShutdownModules(farseerModules []FarseerModule)

ShutdownModules 关闭模块

func StartModules

func StartModules(farseerModules []FarseerModule)

StartModules 启动模块

func ThrowIfNotLoad

func ThrowIfNotLoad(module FarseerModule)

ThrowIfNotLoad 如果没加载模块时,退出应用

Types

type FarseerKernelModule

type FarseerKernelModule struct {
}

func (FarseerKernelModule) DependsModule

func (module FarseerKernelModule) DependsModule() []FarseerModule

func (FarseerKernelModule) Initialize

func (module FarseerKernelModule) Initialize()

func (FarseerKernelModule) PostInitialize

func (module FarseerKernelModule) PostInitialize()

func (FarseerKernelModule) PreInitialize

func (module FarseerKernelModule) PreInitialize()

func (FarseerKernelModule) Shutdown

func (module FarseerKernelModule) Shutdown()

type FarseerModule

type FarseerModule interface {
	// DependsModule 依赖的模块
	DependsModule() []FarseerModule
	// PreInitialize 预初始化
	PreInitialize()
	// Initialize 初始化
	Initialize()
	// PostInitialize 初始化之后
	PostInitialize()
	// Shutdown 应用关闭之前先关闭模块
	Shutdown()
}

func Distinct

func Distinct(modules []FarseerModule) []FarseerModule

Distinct 模块去重

func GetDependModule

func GetDependModule(module ...FarseerModule) []FarseerModule

GetDependModule 查找模块的依赖

Jump to

Keyboard shortcuts

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