bean

package module
v2.0.0-...-fe6a7a6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NetHttpFastTransporter *http.Transport

Support a DNS cache version of the net/http Transport.

View Source
var TenantAlterDbHostParam string

If a command or service wants to use a different `host` parameter for tenant database connection then it's easy to do just by passing that parameter string name using `bean.TenantAlterDbHostParam`. Therfore, `bean` will overwrite all host string in `TenantConnections`.`Connections` JSON.

Functions

func ContextTimeout

func ContextTimeout(timeout time.Duration) echo.MiddlewareFunc

ContextTimeout return custom context timeout middleware

func NewEcho

func NewEcho() (*echo.Echo, func() error)

func NewValidator

NewValidator creates a new validator instance. Currently, it only supports a default validator.

Types

type Bean

type Bean struct {
	DBConn      *DBDeps
	Echo        *echo.Echo
	BeforeServe func()
	ShutdownSrv []func() error
	CleanupDBs  []func() error

	Validate *validatorV10.Validate
	Config   config.Config
	// contains filtered or unexported fields
}

func New

func New() *Bean

func (*Bean) CleanupDB

func (b *Bean) CleanupDB() error

CleanupDB closes all the database (master and tenant) related resources.

func (*Bean) DefaultHTTPErrorHandler

func (b *Bean) DefaultHTTPErrorHandler() echo.HTTPErrorHandler

func (*Bean) InitDB

func (b *Bean) InitDB() error

InitDB initialize all the database dependencies and store it in global variable `global.DBConn`.

func (*Bean) ServeAt

func (b *Bean) ServeAt(host, port string) error

func (*Bean) Shutdown

func (b *Bean) Shutdown() error

Shutdown closes all the server related resources.

func (*Bean) ShutdownAll

func (b *Bean) ShutdownAll() error

ShutdownAll closes all the server and database related resources.

func (*Bean) UseErrorHandlerFuncs

func (b *Bean) UseErrorHandlerFuncs(errHdlrFuncs ...berror.ErrorHandlerFunc)

func (*Bean) UseMiddlewares

func (b *Bean) UseMiddlewares(middlewares ...echo.MiddlewareFunc)

func (*Bean) UseValidation

func (b *Bean) UseValidation(validateFuncs ...validator.ValidatorFunc)

type DBDeps

type DBDeps struct {
	MasterMySQLDB      *gorm.DB
	MasterMySQLDBName  string
	TenantMySQLDBs     map[uint64]*gorm.DB
	TenantMySQLDBNames map[uint64]string
	MasterMongoDB      *mongo.Client
	MasterMongoDBName  string
	TenantMongoDBs     map[uint64]*mongo.Client
	TenantMongoDBNames map[uint64]string
	MasterRedisDB      *dbdrivers.RedisDBConn
	TenantRedisDBs     map[uint64]*dbdrivers.RedisDBConn
	MemoryDB           memory.Cache
}

All database connections are initialized using `DBDeps` structure.

Directories

Path Synopsis
Safe way to execute `go routine` without crashing the parent process while having a `panic`.
Safe way to execute `go routine` without crashing the parent process while having a `panic`.
cmd
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
bean command
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
internal
url
Package urlpath matches paths against a template.
Package urlpath matches paths against a template.
Do not change this file.
Do not change this file.
store
Package sync provides ways to execute multiple tasks concurrently while synchronously managing them at the same time.
Package sync provides ways to execute multiple tasks concurrently while synchronously managing them at the same time.
package test temporarily contains all commonly used, generic utils for testing.
package test temporarily contains all commonly used, generic utils for testing.

Jump to

Keyboard shortcuts

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