internal

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWebApiMode       = gin.ReleaseMode
	DefaultWebApiBind       = ":8080"
	DefaultWebApiHost       = "localhost:8080"
	DefaultWebApiBasePath   = "/"
	DefaultWebApiSchemes    = "https,http"
	GracefulShutdownTimeout = 10 * time.Second
)
View Source
const (
	RouteApiV1        = "/v1"
	RouteSwagger      = "/swagger"
	RouteSwaggerIndex = "/swagger/index.html"
)

The root routes that are available on the running bot.

View Source
const DatabaseLoggerPrefix = "database"
View Source
const ModePostgres = "Postgres"
View Source
const ModeSQLite = "SQLite"

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap()

Bootstrap handles the start of the application. It is responsible to execute the startup sequence and get the application up and running properly.

func CreateEntityManager added in v0.0.3

func CreateEntityManager() api.EntityManager

CreateEntityManager creates a new api.EntityManager with the default gorm.DB instance

func ExitFatal

func ExitFatal(reason string)

ExitFatal shutdowns the application ungracefully with a non-zero exit code. The routines to properly stop the application are not applied on a fatal exit. The function should be only called when the application cannot recover, which is typically the case when core connections cannot be established or an initialization routine fails.

func ExitFatalGracefully

func ExitFatalGracefully(reason string)

ExitFatalGracefully shutdowns the application gracefully with a non-zero exit code. The routines to properly stop the application are not applied on a ExitFatal exit. The function should be only called when the application cannot recover, which is typically the case when core connections cannot be established or an initialization routine fails.

func ExitGracefully

func ExitGracefully(reason string)

ExitGracefully shutdowns the bot gracefully. Using this functions results in the process exiting with exit code 0.

The function tries to ensure that all allocated resources like connections or locks are freed/closed correctly.

func LoadComponents added in v0.0.3

func LoadComponents(discord *discordgo.Session)

LoadComponents handles the initialization of all components listed in the Components array.

When it is not possible to register a component, an error will be printed in the log. The application will continue to run as nothing happened.

func RegisterComponents added in v0.0.3

func RegisterComponents()

RegisterComponents registers all available components in the database and fills the available components in the database API, to provide a unified API to get component information.

func UnloadComponents added in v0.0.3

func UnloadComponents(discord *discordgo.Session)

UnloadComponents iterates through all registered api.Component registered in the Components array and calls their UnloadComponent function.

If an api.Component does not have an UnloadComponent function defined, it will be ignored.

func WebApiLogger added in v0.1.0

func WebApiLogger() gin.HandlerFunc

WebApiLogger creates a new gin.HandlerFunc that acts as a logger middleware and replaces the original logger. This is done to match our standard logging format and support our standard api.

Types

type JojoBotConfig

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

JojoBotConfig represents the entire environment variable based configuration of the application. Globally available values are public, sensitive values are private and can only being read from within the current package.

When new configuration options get added to the application, they should be appended to the structure.

var Config JojoBotConfig

Config holds the currently loaded configuration of the application.

It should be used to retrieve the set environment variables instead of directly calling os.Getenv.

The variable is initialized during the init function.

Jump to

Keyboard shortcuts

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