modules

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package modules is the package for managing the modules of the application.

Modules are the building blocks of the application, and they can be used to extend the application with new features. The package provides functions and interfaces for managing the modules of the application.

Package modules contains the implementation of the background workers service.

The background workers service is responsible for running background workers as goroutines, and for providing a way to register and start workers.

The service is useful for running background tasks, such as sending emails, in a separate goroutine from the main application goroutine.

Package modules provides the main logic for the module system in the application. It allows registering modules, starting them, and stopping them. It also provides a way to register HTTP handlers for the modules.

Package modules provides a builder for initializing and running modules.

The builder is used to: - Set the logger and prompter for the module. - Register HTTP handlers for the module. - Register background workers for the module. - Start the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppManager

type AppManager struct {
	// Modules is a map of strings to IBaseModule, where the key is the name of the module
	// and the value is the module itself.
	Modules map[string]IBaseModule
	// Logger is a logger.ILogger, which is used to log messages.
	Logger logger.ILogger
}

AppManager is a struct that manages the modules of the application.

It contains a map of strings to IBaseModule, where the key is the name of the module and the value is the module itself. It also contains a logger.ILogger, which is used to log messages.

func (*AppManager) GetModules

func (manager *AppManager) GetModules() (modules map[string]IBaseModule, err error)

GetModules retrieves all registered modules.

func (*AppManager) Ignite

func (manager *AppManager) Ignite() (err error)

Ignite starts all saved module builders by igniting each module.

func (*AppManager) IgniteModule

func (manager *AppManager) IgniteModule(name string, logger logger.ILogger, module_builder *ModuleBuilder) error

IgniteModule initializes and registers a module from the module builder.

func (*AppManager) LoadModule

func (manager *AppManager) LoadModule(module IBaseModule, module_name string) *ModuleBuilder

LoadModule initializes a ModuleBuilder with the specified module and name.

type IBackgroundWorkerModule

type IBackgroundWorkerModule interface {
	RegisterBackgroundWorkers() []Worker
}

IBackgroundWorkerModule is an interface that modules can implement to add background workers. RegisterBackgroundWorkers is called by the app manager to register the background workers.

type IBaseModule

type IBaseModule interface {
	// OnStart is called when the module is started.
	OnStart() func()
	// OnEnd is called when the module is stopped.
	OnEnd() func()
}

IBaseModule is the interface that all modules must implement. It provides methods for starting and stopping the module.

type IHttpModule

type IHttpModule interface {
	RegisterHttpHandlers(r *mux.Router, prefix string)
}

IHttpModule is an interface that modules can implement to add HTTP handlers. RegisterHttpHandlers is called by the app manager to register the HTTP handlers.

type ISeederModule

type ISeederModule interface {
	Seed(entities []string, is_new_only bool) error
	GetSeedables() (entities []string, err error)
}

ISeederModule is an interface that modules can implement to add seeders. Seed is called by the app manager to seed the database. GetSeedables is called by the app manager to get the list of seedables.

type ModuleBuilder

type ModuleBuilder struct {
	Logger   logger.ILogger
	Prompter userio.Prompter
	// contains filtered or unexported fields
}

ModuleBuilder is a builder for initializing and running modules.

func (*ModuleBuilder) RegisterBackgroundWorkers

func (builder *ModuleBuilder) RegisterBackgroundWorkers() *ModuleBuilder

RegisterBackgroundWorkers registers background workers for the module.

func (*ModuleBuilder) RegisterHttpHandlers

func (builder *ModuleBuilder) RegisterHttpHandlers(router *mux.Router) *ModuleBuilder

RegisterHttpHandlers registers HTTP handlers for the module.

func (*ModuleBuilder) Save

func (builder *ModuleBuilder) Save()

Save saves the module builder for later use.

type Worker

type Worker struct {
	Interval time.Duration
	Task     func()
}

Worker represents a background worker. Interval is the duration between each run of the task. Task is the function that is called every Interval.

Directories

Path Synopsis
Package auth contains the authentication module which is responsible for authenticating and authorizing users on the endpoints.
Package auth contains the authentication module which is responsible for authenticating and authorizing users on the endpoints.
middlewares
Package middlewares provides a set of middleware functions used to check Zitadel access token for auth and roles.
Package middlewares provides a set of middleware functions used to check Zitadel access token for auth and roles.
Package core contains the core module of the nutrix application.
Package core contains the core module of the nutrix application.
dto
Package dto contains structs for data transfer objects (DTOs) used in the core module of nutrix.
Package dto contains structs for data transfer objects (DTOs) used in the core module of nutrix.
handlers
Package handlers contains HTTP handlers for the core module of nutrix.
Package handlers contains HTTP handlers for the core module of nutrix.
middlewares
Package middlewares contains middleware functions for the web server.
Package middlewares contains middleware functions for the web server.
models
Package models contains the data models for the application.
Package models contains the data models for the application.
services
Package services contains the business logic of the core module of nutrix.
Package services contains the business logic of the core module of nutrix.

Jump to

Keyboard shortcuts

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