Documentation
¶
Overview ¶
Package initiator provides application initialization utilities for Gin-based services.
Index ¶
- Constants
- func GetEnv(name, title string, wsParams libParams.ParamInterface, requestFields string) *requestCore.RequestCoreModel
- func InitDB(dbParams *libParams.DbParams)
- func InitDataBases(params libParams.ParamInterface, dbNames []string)
- func Listen(netParams *libParams.NetworkParams, app *gin.Engine)
- func StartApp[T any](app App[T])
- type App
- type AppEnv
- type Application
- type NoReq
- func (n NoReq) AddRequestEvent(_ webFramework.WebFramework, _, _, _ string, _ libRequest.RequestPtr)
- func (n NoReq) AddRequestLog(_, _ string, _ libRequest.RequestPtr)
- func (n NoReq) CheckDuplicateRequest(_ libRequest.RequestPtr) error
- func (n NoReq) InitRequest(_ webFramework.WebFramework, _, _ string) error
- func (n NoReq) Initialize(_ webFramework.WebFramework, _, _ string, _ libRequest.RequestPtr, _ ...any) (int, map[string]string, error)
- func (n NoReq) InitializeNoLog(_ webFramework.WebFramework, _, _ string, _ libRequest.RequestPtr, _ ...any) (int, map[string]string, error)
- func (n NoReq) InsertRequest(_ libRequest.RequestPtr) error
- func (n NoReq) LogEnd(_, _ string, _ libRequest.RequestPtr)
- func (n NoReq) LogStart(_ webFramework.WebFramework, _, _ string) libRequest.RequestPtr
- func (n NoReq) UpdateRequestWithContext(_ context.Context, _ libRequest.RequestPtr) error
Constants ¶
const DefaultRequestFields = "id,dt,incoming,action_id,national_id,branch_id,user_id,outgoing,result,events"
DefaultRequestFields is the default comma-separated list of request fields used in SQL insert/update.
const LogRequest = "log_req"
LogRequest is the request mode constant indicating log-only request tracking.
const NoRequest = "no_req"
NoRequest is the request mode constant indicating no request tracking.
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶
func GetEnv( name, title string, wsParams libParams.ParamInterface, requestFields string, ) *requestCore.RequestCoreModel
GetEnv creates and returns a RequestCoreModel configured with query runner and request handler.
func InitDB ¶
InitDB opens and pings the database connection, initializing both the sql.DB and gorm.DB handles.
func InitDataBases ¶
func InitDataBases(params libParams.ParamInterface, dbNames []string)
InitDataBases initializes all databases listed in dbNames using the provided parameters.
Types ¶
type App ¶ added in v0.16.6
type App[T any] struct { Instance Application[T] Params *libParams.ApplicationParams[T] Engine *gin.Engine Model requestCore.RequestCoreInterface }
App holds the initialized application instance, parameters, Gin engine, and model.
func InitializeApp ¶
func InitializeApp[T any](app Application[T]) *App[T]
InitializeApp initializes and returns a fully configured App from the given Application instance.
type AppEnv ¶
type AppEnv struct {
Params libParams.ParamInterface
Interface requestCore.RequestCoreInterface
}
AppEnv holds the application parameter interface and request core interface.
type Application ¶
type Application[T any] interface { AddRoutes( model *requestCore.RequestCoreModel, wsParams *libParams.ApplicationParams[T], roleMap map[string]string, rg *gin.RouterGroup, ) Title() string Name() string Version() string BasePath() string HasSwagger() bool SwaggerSpec() *swag.Spec RequestFields() string InitGinApp(*gin.Engine) InitParams(wsParams *libParams.ApplicationParams[T]) GetDbList() []string GetKeys() [][]byte GetCorsConfig() *cors.Config }
Application defines the interface that a requestCore-based service must implement.
type NoReq ¶
type NoReq struct {
}
NoReq is a no-op implementation of RequestInterface that skips request tracking.
func (NoReq) AddRequestEvent ¶
func (n NoReq) AddRequestEvent(_ webFramework.WebFramework, _, _, _ string, _ libRequest.RequestPtr)
AddRequestEvent is a no-op that does not add a request event.
func (NoReq) AddRequestLog ¶
func (n NoReq) AddRequestLog(_, _ string, _ libRequest.RequestPtr)
AddRequestLog is a no-op that does not add any request log.
func (NoReq) CheckDuplicateRequest ¶
func (n NoReq) CheckDuplicateRequest(_ libRequest.RequestPtr) error
CheckDuplicateRequest is a no-op that returns nil without checking for duplicates.
func (NoReq) InitRequest ¶
func (n NoReq) InitRequest(_ webFramework.WebFramework, _, _ string) error
InitRequest is a no-op that returns nil without initializing a request.
func (NoReq) Initialize ¶
func (n NoReq) Initialize( _ webFramework.WebFramework, _, _ string, _ libRequest.RequestPtr, _ ...any) ( int, map[string]string, error)
Initialize is a no-op that returns success without tracking the request.
func (NoReq) InitializeNoLog ¶
func (n NoReq) InitializeNoLog( _ webFramework.WebFramework, _, _ string, _ libRequest.RequestPtr, _ ...any) ( int, map[string]string, error)
InitializeNoLog is a no-op that returns success without logging the request.
func (NoReq) InsertRequest ¶
func (n NoReq) InsertRequest(_ libRequest.RequestPtr) error
InsertRequest is a no-op that returns nil without inserting the request.
func (NoReq) LogEnd ¶
func (n NoReq) LogEnd(_, _ string, _ libRequest.RequestPtr)
LogEnd is a no-op that does not log the request end.
func (NoReq) LogStart ¶
func (n NoReq) LogStart(_ webFramework.WebFramework, _, _ string) libRequest.RequestPtr
LogStart is a no-op that returns nil without logging the request start.
func (NoReq) UpdateRequestWithContext ¶
func (n NoReq) UpdateRequestWithContext(_ context.Context, _ libRequest.RequestPtr) error
UpdateRequestWithContext is a no-op that returns nil without updating the request.