Documentation ¶
Overview ¶
------------------------------------------------------------------------------ The code here is about the configuration of the batcher ------------------------------------------------------------------------------
------------------------------------------------------------------------------ The main concepts involved here in performing batch operations : - batch units = elements we want to handle together, in batches - batch functions =
- defined in another file,
- are the functions to apply to batch units (example: "bulk insert in db")
- batch compartments =
- they gather units of the same kind, to be treated by the same function
- the same function can be used on several compartments
- each compartment can contain several batches (= sets of units of the same size) waiting to be treated
- batch job contexts =
- they bind a batch function, and the batch compartments to deal with it
- the batcher =
- the container of it all, of all the batch job contexts
- is linked to the app server
------------------------------------------------------------------------------
------------------------------------------------------------------------------ The code here is about a specific batch job that can generically handle batch insertions according to what's configured ------------------------------------------------------------------------------
------------------------------------------------------------------------------ The code here is about the links between the batcher and the app's environment, i.e. the app server, or one of its children, job workers, routines, etc. ------------------------------------------------------------------------------
------------------------------------------------------------------------------ Batcher object specific utils ------------------------------------------------------------------------------
----------------------------------------------------------------------------- The code here is about allowing __REPLACE__ logs in temp files for each request, in order to retrospectively know more about a failed request -----------------------------------------------------------------------------
Index ¶
- Constants
- Variables
- func Abs(num int) int
- func BuildConfigWith(pConfigFilePath string, pConfigFileObject IConfigFile) (*ServerConfig, ICustomConfig, error)
- func CamelToShort(camelCasedString string) string
- func CamelToSnake(camelCasedString string) string
- func CheckAndAcquireTimestamp(pString string) (string, error)
- func Count(db IDB, table string, wherePart string, whereValues ...interface{}) (int, error)
- func DateStringToTime(dateString string, format string) (*time.Time, error)
- func DayToTime(simpleDayString string) *time.Time
- func DefineBatchFunction(funcName BatchFuncName, function BatchFunction, ...) (batchFnDef *batchFunctionDefinition)
- func Float64FromNullFloat64(pNf64 *sql.NullFloat64) float64
- func GenerateRandomString(source rand.Source, n int) string
- func GetAppToken(tokenRespObj ITokenResponse, appName string, tokenURL string, user string, ...) (string, bool, error)
- func GetFileContent(pFile *os.File) (string, error)
- func GetIP(pRequest *http.Request) string
- func GetJSONExample() string
- func GetPwdHashingFunc() func(pwd []byte, salt []byte) ([]byte, error)
- func GetPwdMatchingFunc() func(hashedPwd []byte, pwd []byte, salt []byte) error
- func GetScopeSignature(scope LoggingScope) string
- func GetUserAgent(pRequest *http.Request) string
- func IDFromNullID(pNID64 *sql.NullInt64) int64
- func InitGlobalCacheFromConfig(globalCacheConfig *applicationGlobalCacheConfig)
- func InitLocalCacheForTests(localDefaultExpiration time.Duration, localCleanupInterval time.Duration)
- func InitLocalCacheFromConfig(localCacheConfig *applicationLocalCacheConfig)
- func Int64FromNullInt64(pNi64 *sql.NullInt64) int64
- func IntLen(num int) int
- func LeftPad(s string, pad string, length int) string
- func MaxDuration(a, b time.Duration) time.Duration
- func MaxInt(a, b int) int
- func MaxInt64(a, b int64) int64
- func MinDuration(a, b time.Duration) time.Duration
- func MinInt(a, b int) int
- func MinInt64(a, b int64) int64
- func NewRandSource() rand.Source
- func NormalizeAndCapOnce(str string) (result string, err error)
- func NormalizeStringOnce(str string) (result string, err error)
- func Now() *time.Time
- func PascalToCamel(pascalCasedString string) string
- func PascalToSnake(pascalCasedString string) string
- func PurgeAuthTokens(expiredSince time.Duration, doClean bool) (totalSize int, detected int, treated int, err error)
- func RandBool(source rand.Source) bool
- func RandDate(source rand.Source, withMicrosec bool) *time.Time
- func RandDigit(source rand.Source) int64
- func RandDuration(source rand.Source, maxduration string) time.Duration
- func RandFloatString(source rand.Source, minlength int, maxlength int, maxdecimals int) string
- func RandInt(source rand.Source, min int, max int) int
- func RandIntByte(source rand.Source) byte
- func RandIntString(source rand.Source, minlength int, maxlength int) string
- func RandNum(source rand.Source, min int, max int) int64
- func RandSampleInt(source rand.Source, fromIntValues []int) (sample []int)
- func RandString(source rand.Source, minlength int, maxlength int) string
- func RightPad(s string, pad string, length int) string
- func Round(num float64) int64
- func Round1f32(num float32) float32
- func Round1f64(num float64) float64
- func Round2f32(num float32) float32
- func Round2f64(num float64) float64
- func Round32(num float32) int64
- func SaveAuthClient(authClient osin.Client) error
- func SetPwdHashingFunc(daFunc func(pwd []byte, salt []byte) ([]byte, error))
- func SetPwdMatchingFunc(daFunc func(hashedPwd []byte, pwd []byte, salt []byte) error)
- func SnakeToShort(snakeCasedString string) string
- func StringFromNullString(pNs *sql.NullString) string
- func StringInSlice(str string, slice []string) bool
- func TimeToSimpleString(pTime *time.Time) string
- func ToDuration32(timeInFloat float32) time.Duration
- func ToDuration64(timeInFloat float64) time.Duration
- func ToDurationStr(str string) time.Duration
- func ToMicrosec(nanoseconds time.Duration) int64
- func ToMillisec(nanoseconds time.Duration) int64
- func TrimIfLong(s string, maxlength int) string
- type Amount
- type AppMode
- type Appserv
- func (sAppserv *Appserv) AddActionHandler(pAction string, pNeedLogin bool, pCall AppservCall)
- func (sAppserv *Appserv) AddLoggerHook(loggerHook logrus.Hook)
- func (sAppserv *Appserv) Batcher() *Batcher
- func (sAppserv *Appserv) BeginDbTransaction() (*sql.Tx, error)
- func (sAppserv *Appserv) BindOriginalFunction(name string, jfunc interface{})
- func (sAppserv *Appserv) Exec(pQuery string, pParams ...interface{}) (sql.Result, error)
- func (sAppserv *Appserv) GetAppName() string
- func (sAppserv *Appserv) GetAppPath() string
- func (sAppserv *Appserv) GetAppURL() string
- func (sAppserv *Appserv) GetBox() string
- func (sAppserv *Appserv) GetCustomConfig() ICustomConfig
- func (sAppserv *Appserv) GetDbName() string
- func (sAppserv *Appserv) GetDescription() string
- func (sAppserv *Appserv) GetLogger() *logrus.Logger
- func (sAppserv *Appserv) GetMode() AppMode
- func (sAppserv *Appserv) GetNotAuthenticatedCode() int
- func (sAppserv *Appserv) GetOriginalJobConfig(jobID string, doPanicIfNotFound bool) *JobConfig
- func (sAppserv *Appserv) GetParentScope() LoggingScope
- func (sAppserv *Appserv) GetRoutinePoolCapacity() int
- func (sAppserv *Appserv) GetRoutineStats() (currentUse, maxParaUse, totalUse int)
- func (sAppserv *Appserv) GetScheduledFunction(name string) interface{}
- func (sAppserv *Appserv) GetScopeID() string
- func (sAppserv *Appserv) GetSecondaryDB(pDBID string, pCheck bool) (*sql.DB, error)
- func (sAppserv *Appserv) GetSecondaryDBx(pDBID string, pCheck bool) (*sqlx.DB, error)
- func (sAppserv *Appserv) GetSecondaryDbName(id string) string
- func (sAppserv *Appserv) GetSecondaryIDB(pDBID string, pCheck bool) (IDB, error)
- func (sAppserv *Appserv) GetSeparator() string
- func (sAppserv *Appserv) GetSignature() string
- func (sAppserv *Appserv) GetSqlLogThreshold() time.Duration
- func (sAppserv *Appserv) GetTokenExp() time.Duration
- func (sAppserv *Appserv) GetUniqueID(counterName string) (int, error)
- func (sAppserv *Appserv) GetVersion() string
- func (sAppserv *Appserv) GetVostokAppToken(appName string, appURL string, user string, password string, ...) (string, bool, error)
- func (sAppserv *Appserv) HasDb() bool
- func (sAppserv *Appserv) InitAppDB() (vDbManager string, vDbUsername string, vDbName string, ...)
- func (sAppserv *Appserv) InitAuth()
- func (sAppserv *Appserv) InitBatcher()
- func (sAppserv *Appserv) InitGlobalCache()
- func (sAppserv *Appserv) InitLocalCache()
- func (sAppserv *Appserv) InitLoggers()
- func (sAppserv *Appserv) InitProfilingTools(restrictAccess bool)
- func (sAppserv *Appserv) InitRoutinePool()
- func (sAppserv *Appserv) IsDBOpen() bool
- func (sAppserv *Appserv) IsHideFunctionName() bool
- func (sAppserv *Appserv) IsTempLogging() bool
- func (sAppserv *Appserv) IsTestMode() bool
- func (sAppserv *Appserv) IsVerbose() bool
- func (sAppserv *Appserv) Log() LogEntry
- func (sAppserv *Appserv) LogF(skip int, fields logrus.Fields) LogEntry
- func (sAppserv *Appserv) NewBatchRoutineContext(scopeID string) IBatchRoutineContext
- func (sAppserv *Appserv) NewRoutine(scopeID string) Routine
- func (sAppserv *Appserv) OpenAndTweakDBConnection(c *applicationDBConfig) (db IDB, errOpen error)
- func (sAppserv *Appserv) OpenDBConnection(pDriverName string, pDBName string, pDBHost string, pUsername string, ...) (IDB, error)
- func (sAppserv *Appserv) PullJobWorker() (*JobWorker, error)
- func (sAppserv *Appserv) QueryRow(pQuery string, pParams ...interface{}) *sql.Row
- func (sAppserv *Appserv) QuerySQL(pQuery string, pParams ...interface{}) (*sql.Rows, error)
- func (sAppserv *Appserv) ReleaseJobWorker(jobWorker *JobWorker)
- func (sAppserv *Appserv) RemoveFunction(name string)
- func (sAppserv *Appserv) ScheduleFunction(name string, schedule string, fn interface{}, args ...interface{}) error
- func (sAppserv *Appserv) ScheduleJob(jobID string, jobFunc scheduledJobFunc) error
- func (sAppserv *Appserv) ServeHTTP(pResponseWriter http.ResponseWriter, pRequest *http.Request)
- func (sAppserv *Appserv) SetAuthClientGetterFn(fn AuthClientGetterFn)
- func (sAppserv *Appserv) SetAuthCustomService(authCustomService IAuthCustomService)
- func (sAppserv *Appserv) SetMainLogger(logger *logrus.Logger)
- func (sAppserv *Appserv) Start()
- func (sAppserv *Appserv) StartBatchJob(batchJobID BatchJobID)
- func (sAppserv *Appserv) TempLog(frameSkip int, message string, params ...interface{})
- func (sAppserv *Appserv) TempLogKeep()
- func (sAppserv *Appserv) TempLogStart(frameSkip int) *TimedTempLog
- type AppservCall
- type AppservChild
- func (sAppservChild *AppservChild) Batcher() *Batcher
- func (sAppservChild *AppservChild) BeginDbTransaction() (*sql.Tx, error)
- func (sAppservChild *AppservChild) BindOriginalFunction(name string, jfunc interface{})
- func (sAppservChild *AppservChild) DecryptData(pEncryptedData []byte) ([]byte, error)
- func (sAppservChild *AppservChild) EncryptData(pData []byte) ([]byte, error)
- func (sAppservChild *AppservChild) EndTempLogging(removelog bool)
- func (sAppservChild *AppservChild) EscapeStringJavascript(pString string) string
- func (sAppservChild *AppservChild) Exec(pQuery string, pParams ...interface{}) (sql.Result, error)
- func (sAppservChild *AppservChild) ExecuteStatement(pName string, pParams ...interface{}) (sql.Result, error)
- func (sAppservChild *AppservChild) GetAction() string
- func (sAppservChild *AppservChild) GetAppName() string
- func (sAppservChild *AppservChild) GetAppPath() string
- func (sAppservChild *AppservChild) GetAppURL() string
- func (sAppservChild *AppservChild) GetBox() string
- func (sAppservChild *AppservChild) GetChildNumber() int
- func (sAppservChild *AppservChild) GetCookie(pName string) ([]byte, error)
- func (sAppservChild *AppservChild) GetCurrentHTTPRequest() *http.Request
- func (sAppservChild *AppservChild) GetCurrentResponseWriter() http.ResponseWriter
- func (sAppservChild *AppservChild) GetCurrentURL() *url.URL
- func (sAppservChild *AppservChild) GetCustomConfig() ICustomConfig
- func (sAppservChild *AppservChild) GetDbName() string
- func (sAppservChild *AppservChild) GetDescription() string
- func (sAppservChild *AppservChild) GetHTTPMethod() string
- func (sAppservChild *AppservChild) GetIPAddress() string
- func (sAppservChild *AppservChild) GetLogger() *logrus.Logger
- func (sAppservChild *AppservChild) GetLogin() bool
- func (sAppservChild *AppservChild) GetMode() AppMode
- func (sAppservChild *AppservChild) GetOriginalJobConfig(jobID string, doPanicIfNotFound bool) *JobConfig
- func (sAppservChild *AppservChild) GetParentScope() LoggingScope
- func (sAppservChild *AppservChild) GetRoutinePoolCapacity() int
- func (sAppservChild *AppservChild) GetRoutineStats() (currentUse, maxParaUse, totalUse int)
- func (sAppservChild *AppservChild) GetScheduledFunction(name string) interface{}
- func (sAppservChild *AppservChild) GetScopeID() string
- func (sAppservChild *AppservChild) GetSecondaryDB(pDBID string, pCheck bool) (*sql.DB, error)
- func (sAppservChild *AppservChild) GetSecondaryDBx(pDBID string, pCheck bool) (*sqlx.DB, error)
- func (sAppservChild *AppservChild) GetSecondaryDbName(id string) string
- func (sAppservChild *AppservChild) GetSecondaryIDB(pDBID string, pCheck bool) (IDB, error)
- func (sAppservChild *AppservChild) GetSeparator() string
- func (sAppservChild *AppservChild) GetSignature() string
- func (sAppservChild *AppservChild) GetSqlLogThreshold() time.Duration
- func (sAppservChild *AppservChild) GetStartTime() time.Time
- func (sAppservChild *AppservChild) GetStatement(pName string) *sql.Stmt
- func (sAppservChild *AppservChild) GetTokenExp() time.Duration
- func (sAppservChild *AppservChild) GetUniqueID(counterName string) (int, error)
- func (sAppservChild *AppservChild) GetUserInfo() *UserInfo
- func (sAppservChild *AppservChild) GetVersion() string
- func (sAppservChild *AppservChild) GetVostokAppToken(appName string, appURL string, user string, password string, ...) (string, bool, error)
- func (sAppservChild *AppservChild) IsCustomAccessAuthorized() (bool, error, interface{})
- func (sAppservChild *AppservChild) IsCustomAuthUsed() bool
- func (sAppservChild *AppservChild) IsDBOpen() bool
- func (sAppservChild *AppservChild) IsHideFunctionName() bool
- func (sAppservChild *AppservChild) IsTempLogging() bool
- func (sAppservChild *AppservChild) IsTestMode() bool
- func (sAppservChild *AppservChild) IsVerbose() bool
- func (sAppservChild *AppservChild) Log() LogEntry
- func (sAppservChild *AppservChild) LogF(skip int, fields logrus.Fields) LogEntry
- func (sAppservChild *AppservChild) NewRoutine(scopeID string) Routine
- func (sAppservChild *AppservChild) PlayJSON(pJSONObject interface{}, pIndent bool)
- func (sAppservChild *AppservChild) PlayJSONError(pCallName string, pCallVersion string, pErrorCode string, pErrorTitle string, ...)
- func (sAppservChild *AppservChild) PlayJSONIndent(pJSONObject interface{}, pIndentString string)
- func (sAppservChild *AppservChild) PlayJSONIndentWithCode(pJSONObject interface{}, pIndentString string, pCode int)
- func (sAppservChild *AppservChild) PlayJSONResponse(pCallName string, pCallVersion string, pDataObject interface{})
- func (sAppservChild *AppservChild) PlayJSONStatus()
- func (sAppservChild *AppservChild) PlayTemplate(pTemplateName string, pTemplateType string, pTemplateData interface{})
- func (sAppservChild *AppservChild) PullJobWorker() (*JobWorker, error)
- func (sAppservChild *AppservChild) QueryRow(pQuery string, pParams ...interface{}) *sql.Row
- func (sAppservChild *AppservChild) QuerySQL(pQuery string, pParams ...interface{}) (*sql.Rows, error)
- func (sAppservChild *AppservChild) QueryStatement(pName string, pParams ...interface{}) (*sql.Rows, error)
- func (sAppservChild *AppservChild) Redirect(pURL string)
- func (sAppservChild *AppservChild) ReleaseJobWorker(jobWorker *JobWorker)
- func (sAppservChild *AppservChild) RemoveFunction(name string)
- func (sAppservChild *AppservChild) ScheduleFunction(name string, schedule string, fn interface{}, args ...interface{}) error
- func (sAppservChild *AppservChild) SetCookie(pName string, pValue []byte)
- func (sAppservChild *AppservChild) SetLogin(pLoginState bool)
- func (sAppservChild *AppservChild) SetUserInfo(pUserInfo *UserInfo)
- func (sAppservChild *AppservChild) TempLog(frameSkip int, message string, params ...interface{})
- func (sAppservChild *AppservChild) TempLogKeep()
- func (sAppservChild *AppservChild) TempLogStart(frameSkip int) *TimedTempLog
- type AppservError
- type AuthClientGetterFn
- type AuthLoginRequest
- type AuthLoginResponse
- type BaseUser
- type BatchCompartment
- func (thisCompartment *BatchCompartment) ApplyBatchFunction(batchFnCtx IBatchFunctionContext, doPurge bool) (nbTreated, nbUnitsTot int, err error)
- func (thisCompartment *BatchCompartment) GetBatchCompartmentID() BatchCompartmentID
- func (thisCompartment *BatchCompartment) GetBatchJobID() BatchJobID
- func (thisCompartment *BatchCompartment) GetBatchesSize() int
- func (thisCompartment *BatchCompartment) GetContext() interface{}
- func (thisCompartment *BatchCompartment) GetParams() map[string]string
- func (thisCompartment *BatchCompartment) SetContext(compartmentContext IBatchCompartmentContext)
- type BatchCompartmentConfigCheckingFn
- type BatchCompartmentID
- type BatchFuncName
- type BatchFunction
- type BatchJobID
- type Batcher
- func (thisBatcher *Batcher) GetCompartmentsForJob(batchJobUID BatchJobID) map[BatchCompartmentID]*BatchCompartment
- func (thisBatcher *Batcher) HasPendingWork() bool
- func (thisBatcher *Batcher) IsShut() bool
- func (thisBatcher *Batcher) Push(batchJobID BatchJobID, unit IBatchUnit) (nbInBasket, nbBatches, batchSize int, err error)
- func (thisBatcher *Batcher) Shut()
- func (thisBatcher *Batcher) StartBatchJob(batchJobID BatchJobID, execContext IBatchFunctionContext)
- type BulkInsertionsContext
- type Casing
- type Currency
- type CurrencyCode
- type CustomAuthAction
- type CustomAuthLoginResponse
- type Email
- type ErrorMessage
- type IAppservSibling
- type IAuthCustomService
- type IBatchCompartmentConfig
- type IBatchCompartmentContext
- type IBatchFunctionContext
- type IBatchInsertUnit
- type IBatchRoutineContext
- type IBatchSignature
- type IBatchUnit
- type IBatcherOwner
- type ICache
- type ICachePartition
- type IConfigFile
- type ICustomConfig
- type IDB
- type IGlobalCache
- type ILocalCache
- type IPartitionedCache
- type IStringNormalizer
- type ITokenResponse
- type JSONConfigFile
- type JSONResponse
- type JSONResponseError
- type JSONResponseHeader
- type JSONResponseStatus
- type JSONString
- type JSONTime
- type JobConfig
- type JobWorker
- func (thisWorker *JobWorker) Batcher() *Batcher
- func (thisWorker *JobWorker) BeginDbTransaction() (*sql.Tx, error)
- func (thisWorker *JobWorker) Exec(queryAsString string, values ...interface{}) (sql.Result, error)
- func (thisWorker *JobWorker) GetAppName() string
- func (thisWorker *JobWorker) GetAppPath() string
- func (thisWorker *JobWorker) GetCustomConfig() ICustomConfig
- func (thisWorker *JobWorker) GetDbName() string
- func (thisWorker *JobWorker) GetDescription() string
- func (thisWorker *JobWorker) GetLogger() *logrus.Logger
- func (thisWorker *JobWorker) GetMode() AppMode
- func (thisWorker *JobWorker) GetParentScope() LoggingScope
- func (thisWorker *JobWorker) GetRoutineStats() (currentUse, maxParaUse, totalUse int)
- func (thisWorker *JobWorker) GetScopeID() string
- func (thisWorker *JobWorker) GetSecondaryDB(dbID string, check bool) (*sql.DB, error)
- func (thisWorker *JobWorker) GetSecondaryDBx(dbID string, check bool) (*sqlx.DB, error)
- func (thisWorker *JobWorker) GetSecondaryDbName(id string) string
- func (thisWorker *JobWorker) GetSecondaryIDB(pDbID string, pCheck bool) (IDB, error)
- func (thisWorker *JobWorker) GetSeparator() string
- func (thisWorker *JobWorker) GetSignature() string
- func (thisWorker *JobWorker) GetSqlLogThreshold() time.Duration
- func (thisWorker *JobWorker) GetUniqueID(counterName string) (int, error)
- func (thisWorker *JobWorker) GetVersion() string
- func (thisWorker *JobWorker) GetVostokAppToken(appName string, appURL string, user string, password string, ...) (string, bool, error)
- func (thisWorker *JobWorker) GetWorkerID() int
- func (thisWorker *JobWorker) GetWorkerUses() int
- func (thisWorker *JobWorker) IsDBOpen() bool
- func (thisWorker *JobWorker) IsHideFunctionName() bool
- func (thisWorker *JobWorker) IsTempLogging() bool
- func (thisWorker *JobWorker) IsTestMode() bool
- func (thisWorker *JobWorker) IsVerbose() bool
- func (thisWorker *JobWorker) Log() LogEntry
- func (thisWorker *JobWorker) LogF(skip int, fields logrus.Fields) LogEntry
- func (thisWorker *JobWorker) NewBatchRoutineContext(scopeID string) IBatchRoutineContext
- func (thisWorker *JobWorker) NewRoutine(scopeID string) Routine
- func (thisWorker *JobWorker) QueryRow(queryAsString string, values ...interface{}) *sql.Row
- func (thisWorker *JobWorker) QuerySQL(queryAsString string, values ...interface{}) (*sql.Rows, error)
- func (thisWorker *JobWorker) TempLog(frameSkip int, message string, params ...interface{})
- func (thisWorker *JobWorker) TempLogKeep()
- func (thisWorker *JobWorker) TempLogStart(frameSkip int) *TimedTempLog
- type LogEntry
- type LoggingScope
- type OAuthAction
- type RegExpPattern
- type Routine
- type RoutineOwner
- type ServerConfig
- type SessionAuthAction
- type StatelessAuthAction
- type SuccessMessage
- type TimedTempLog
- type URL
- type UserInfo
Constants ¶
const ( // LocalCacheNOEXPIRATION is used for items that have no reason to expire in the cache LocalCacheNOEXPIRATION = goca.NoExpiration // LocalCacheDEFEXPIRATION is used for items that should use the default cache expiration time (set in config) LocalCacheDEFEXPIRATION = goca.DefaultExpiration )
const ( // GlobalCacheDurationNEVER is used for items that should not be cached GlobalCacheDurationNEVER = -2 // GlobalCacheDurationFOREVER is used for items that have no reason to expire in the cache GlobalCacheDurationFOREVER = goca.NoExpiration // GlobalCacheDurationDEFAULT is used for items that should use the default cache expiration time (set in config) GlobalCacheDurationDEFAULT = goca.DefaultExpiration )
const ( // DateFormatYYYYsMMsDD is a format for date that looks like this 2017/12/25 DateFormatYYYYsMMsDD = "2006/01/02" // DateFormatSECONDS is a format for date that looks like this "2017/12/25 19:56:42" DateFormatSECONDS = "2006/01/02 15:04:05" // DateFormatMICROSEC is the time format we use for timestamps DateFormatMICROSEC = "2006-01-02 15:04:05.999999" )
const ( // DbMgrPOSTGRES : the name of the PostgreSQL DB manager DbMgrPOSTGRES = "postgres" // DbMgrMYSQL : the name of the MysQL DB manager DbMgrMYSQL = "mysql" // SQLLibSQLX : when not using the default sql lib for DB connection, but sqlx instead SQLLibSQLX = "sqlx" // CountersTableName the name of the table for holding counters CountersTableName = "vostok_counters" // CountersTableNameConstraint is the name of the constraints that should be put on the counter table's name column CountersTableNameConstraint = "uk_" + CountersTableName + "_name" // DBDefaultIDValue is the value that we associate with the NULL value for a // database index. 0 is complicated because we could imagine the ID could be 0 // this is reason why we choose -1. DBDefaultIDValue int64 = -1 )
const ( // RootPathREST is the path root for REST resources RootPathREST = "/rest/" // RootPathOAUTH is the path root for oauth requests RootPathOAUTH = "/oauth/" // RootPathSESSIONAUTH is the path root for session auth requests RootPathSESSIONAUTH = "/sessionauth/" // RootPathSTATELESSAUTH is the path root for stateless auth requests RootPathSTATELESSAUTH = "/statelessauth/" // RootPathCUSTOMAUTH is the path root for stateless auth requests RootPathCUSTOMAUTH = "/customauth/" )
const ( CasingCAMEL = "camel" CasingSNAKE = "snake" CasingPASCAL = "pascal" )
Variables ¶
var ( // Generic error for authentication data issues ErrAuthDATA = errors.New("authentication data error") // Generic error for token expiration ErrAuthEXPIREDTOKEN = errors.New("authentication token expired") )
var ( // Generic error for DB Connection Issue ErrDBConnectionOPEN = errors.New("could not open Database connection") // Generic error for DB Statement Issue ErrDBStatementPROCESSING = errors.New("could not process statement") )
var ( // Generic error for Login issues ErrAuthLOGIN = errors.New("login error") )
var ( // Generic error for authentication data issues ErrAuthSTORAGE = errors.New("authentication storage error") )
var ( // Generic error to qualify issues due to batcher's configuration. ErrBatcherCONFIG = errors.New("batcher configuration error") )
var ( // Generic error to qualify issues due to batcher's state. ErrBatcherSTATE = errors.New("batcher state error") )
var ( // Generic error for the caching feature ErrCacheGENERIC = errors.New("caching error") )
var ( // Generic error when using crypto procedures ErrCryptoPROCESSING = errors.New("cryptography processing error") )
var ( // Generic error for the regexp feature ErrRegexpGENERIC = errors.New("regular expression error") )
var ( // Generic error for the scheduler feature ErrSchedulerGENERIC = errors.New("generic scheduler error") )
var URICutCUSTOMAUTH int
URICutCUSTOMAUTH is the index at which to cut a custom Auth URI to get the 'action'
var URICutOAUTH int
URICutOAUTH is the index at which to cut a OAuth URI to get the 'action'
var URICutREST int
URICutREST is the index at which to cut a Rest URI to get the resource & action from it
var URICutSESSIONAUTH int
URICutSESSIONAUTH is the index at which to cut a Session Auth URI to get the 'action'
var URICutSTATELESSAUTH int
URICutSTATELESSAUTH is the index at which to cut a Stateless Auth URI to get the 'action'
Functions ¶
func BuildConfigWith ¶
func BuildConfigWith(pConfigFilePath string, pConfigFileObject IConfigFile) (*ServerConfig, ICustomConfig, error)
BuildConfigWith reads a configuration file and hydrates a server configuration object. This expects the configuration file to be a JSON file.
Arguments
pConfigFilePath: the name of the config item for which we want the value pConfigFileObject: the object that will bear the configuration items
Returns
- the root config object for the server
- the application custom configuration object
- the error if there is one
func CamelToShort ¶
CamelToShort converts a camelCasedString to a "short" version, i.e. camCasStr
func CamelToSnake ¶
CamelToSnake converts the givenCamelString to snake case version i.e. given_camel_string
func CheckAndAcquireTimestamp ¶
CheckAndAcquireTimestamp checks the format and tries to complete the string if it is not a full timestamp using the format YYYY-MM-DD HH:MM:SS.uuuuuu
Arguments
pRegExpPattern: the regular expression pattern to use when trying to check the string.
Returns
- the extracted value
- an error if something has failed
func DateStringToTime ¶
DateStringToTime returns a Time object from a given date string, and a given date format TODO _OA$?: what is the catch here? why would we want to wrap time.Parse?
func DayToTime ¶
DayToTime transform a day date given as "2006/01/02" to a pointer to a Time object. Panics if the day format is wrong
func DefineBatchFunction ¶
func DefineBatchFunction(funcName BatchFuncName, function BatchFunction, checkFn BatchCompartmentConfigCheckingFn) (batchFnDef *batchFunctionDefinition)
DefineBatchFunction allows to bind a batch function to a name which serves as a unique ID, and a to a function that helps check the configuration for the compartments that are to be dealt with by the given batch function. NB: this function is to be used next to the batch function declaration, to associate a batch function name with it, and maybe a batch compartment config checking function; thus, such an association is done once, and does not need to be invoked in each applicative case; as a consequence, using the batch function name ensures to point to the right batch function, but also the right config checking method.
func Float64FromNullFloat64 ¶
func Float64FromNullFloat64(pNf64 *sql.NullFloat64) float64
Float64FromNullFloat64 returns the default value for a float64 float when the value was NULL in the result of the SQL request. The default value is 0.0.
Arguments
pNi64: a NullInt64 object
Returns
- the corresponding int64 integer
func GenerateRandomString ¶
GenerateRandomString creates a random string of a given size, from a given rand.Source, with characters in [0-9a-zA-Z] This should be quite an effective way. See benchmark here (to reproduce in a test file): cf. http://stackoverflow.com/a/31832326/7745451
func GetAppToken ¶
func GetAppToken(tokenRespObj ITokenResponse, appName string, tokenURL string, user string, password string, timeout time.Duration, body interface{}) (string, bool, error)
GetAppToken retrieves a token to access another app
func GetFileContent ¶
GetFileContent returns a string representation of a file.
Arguments
pFilename : the name of the file for which we want the content
Returns
- the file's content as a string
- an error if there is a problem
func GetIP ¶
GetIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.
func GetPwdHashingFunc ¶
GetPwdHashingFunc returns the hashing function currently used
func GetPwdMatchingFunc ¶
GetPwdMatchingFunc returns the hashing function currently used
func GetScopeSignature ¶
func GetScopeSignature(scope LoggingScope) string
GetScopeSignature builds a string from the given scope's ID, and the IDs of its parent and all its grandparent, separated by a pipe "|". Example: "01|009765|044"
func GetUserAgent ¶
GetUserAgent gets a requests User Agent
func IDFromNullID ¶
IDFromNullID returns the default value for a database ID which is an int64 int and can be NULL. THe reason why we use this procedure instead of the more generic Int64FromNullInt64 is that for database IDs 0 could potentially be a not null value.
Arguments
pNID64: a NullInt64 object
Returns
- the corresponding int64 integer
func InitGlobalCacheFromConfig ¶
func InitGlobalCacheFromConfig(globalCacheConfig *applicationGlobalCacheConfig)
InitGlobalCacheFromConfig : initialising the main global cache instance - or its partitioned version (if NoPartition = false in the config) - with a given global cache config
func InitLocalCacheForTests ¶
func InitLocalCacheForTests(localDefaultExpiration time.Duration, localCleanupInterval time.Duration)
InitLocalCacheForTests : initialising the main local cache with given cache parameters
func InitLocalCacheFromConfig ¶
func InitLocalCacheFromConfig(localCacheConfig *applicationLocalCacheConfig)
InitLocalCacheFromConfig : initialising the main local cache instance with a given local cache config
func Int64FromNullInt64 ¶
Int64FromNullInt64 returns the default value for an int64 integer when the value was NULL in the result of the SQL request. The default value is 0.
Arguments
pNi64: a NullInt64 object
Returns
- the corresponding int64 integer
func LeftPad ¶
LeftPad left-pads a given string with a padding string, until a given length is reached
func MaxDuration ¶
MaxDuration returns the min between the 2 given integers
func MinDuration ¶
MinDuration returns the min between the 2 given integers
func NewRandSource ¶
NewRandSource is our "standard" way of creating a new rand source
func NormalizeAndCapOnce ¶
NormalizeAndCapOnce normalizes and upper caps a given string. I.e. Jean-Vincent Placé => JEAN-VINCENT PLACE For multiple successive calls to this function, it is recommended to use the ToUpper method on the same IStringNormalizer instance.
func NormalizeStringOnce ¶
NormalizeStringOnce removes accents from a given string. Example: "Yoùr Śtring šđč枊ĐČĆŽ Ötzi's Nationalität èàì" => "Your String sđcczSĐCCZ Otzi's Nationalitat eai" For multiple successive calls to this function, it is recommended to use the String method on the same IStringNormalizer instance.
func PascalToCamel ¶
PascalToCamel returns the given string lowerCamelCased. Ex: KickYourAss => kickYourAss
func PascalToSnake ¶
PascalToSnake converts the GivenPascalString to its snake case version i.e. given_camel_string
func PurgeAuthTokens ¶
func PurgeAuthTokens(expiredSince time.Duration, doClean bool) (totalSize int, detected int, treated int, err error)
PurgeAuthTokens cleans the entities in the "authTableACCESS" table, that expired since a longer time that the argument. This argument should not be less than the configured token expiration time, i.e. calling this function MUST NEVER prune valid tokens.
func RandDuration ¶
RandDuration returns a random duration, from 0 to a given maximum duration
func RandFloatString ¶
RandFloatString generates a random string representing a real number, with a given maximum length
func RandIntByte ¶
RandIntByte returns a random digit, between 0 and 9, as a byte
func RandIntString ¶
RandIntString generates a random string representing an integer, with a given maximum length NB: this is a maximum length, not a maximum int !!
func RandSampleInt ¶
RandSampleInt returns a randomly chosen subset of a given int array
func RandString ¶
RandString generates a random string with at most a given number of characters
func RightPad ¶
RightPad left-pads a given string with a padding string, until a given length is reached
func Round1f32 ¶
Round1f32 rounds a given real 64-bits number to the nearest float, at the first decimal place
func Round1f64 ¶
Round1f64 rounds a given real 64-bits number to the nearest float, at the first decimal place
func Round2f32 ¶
Round2f32 rounds a given real 64-bits number to the nearest float, at the second decimal place
func Round2f64 ¶
Round2f64 rounds a given real 64-bits number to the nearest float, at the second decimal place
func SaveAuthClient ¶
SaveAuthClient saves - i.e. inserts or updates - a user into the auth DB
func SetPwdHashingFunc ¶
SetPwdHashingFunc allows to set a hashing function to hash the passwords
func SetPwdMatchingFunc ¶
SetPwdMatchingFunc allows to set a hashing function to hash the passwords
func SnakeToShort ¶
SnakeToShort converts a snake_case_string to a "short" version, i.e. snaCasStr
func StringFromNullString ¶
func StringFromNullString(pNs *sql.NullString) string
StringFromNullString returns the default value for an string when the value was NULL in the result of the SQL request. The default value is the empty string.
Arguments
pNs: a NullString object
Returns
- the corresponding string
func StringInSlice ¶
StringInSlice tells if a given string is in the given slice
func TimeToSimpleString ¶
TimeToSimpleString formats a time as a date with format "2006/12/25"
func ToDuration32 ¶
ToDuration32 returns a duration from a time, given as a 64-bits float - when it comes from an operation for instance
func ToDuration64 ¶
ToDuration64 returns a duration from a time, given as a 64-bits float - when it comes from an operation for instance
func ToDurationStr ¶
ToDurationStr returns a duration from a given string, like 1d, 30s, 5000us, etc
func ToMicrosec ¶
ToMicrosec outputs the time given in nanoseconds, in microseconds; the result cannot be a duration since it's not nanosecs
func ToMillisec ¶
ToMillisec outputs the time given in nanoseconds, in milliseconds; the result cannot be a duration since it's not nanosecs
func TrimIfLong ¶
TrimIfLong cuts the given string at the maximal size, if it exceeds it
Types ¶
type Amount ¶
type Amount float64
Amount is used for all the amounts of money
func (Amount) MarshalJSON ¶
MarshalJSON for amounts, allowing us to marshall amounts with max 4 decimals
type AppMode ¶
type AppMode int
AppMode helps configure in which environment type the app is running
type Appserv ¶
type Appserv struct {
// contains filtered or unexported fields
}
Appserv carries the vostok application server. From this root object you will get access to the config, the registered actions which are the HTTP handlers, the cached templates, the children processes, the DB connections and also the Job schedulers.
func NewAppserv ¶
NewAppserv reads the JSON config file and builds the configuration of the app server.
Arguments
pRootPath: location from which to find all the resources; "" by default pConfigFilePath: location of the config file
Returns
- the newly created application server object
- the error if something not expected happened
func NewAppservWithConfig ¶
func NewAppservWithConfig(pRootPath string, pConfigFilePath string, pConfigFileObject IConfigFile) (*Appserv, error)
NewAppservWithConfig reads the JSON config file and builds the configuration of the app server.
Arguments
pRootPat: location from which to find all the resources; "" by default pConfigFilePath: location of the config file pConfigFileObject: type of the config file
Returns
- the newly created application server object
- the error if something not expected happened
func (*Appserv) AddActionHandler ¶
func (sAppserv *Appserv) AddActionHandler(pAction string, pNeedLogin bool, pCall AppservCall)
AddActionHandler stores a new action handler to the application server. An action handler is basically an HTTP handler triggered by an action set using the HTTP parameter "action".
Arguments
pAction: the name of the action pNeedLogin: boolean to specify whether the action requires login pCall: a function which will handle the action
func (*Appserv) AddLoggerHook ¶
AddLoggerHook allows to set a logrus logger, even if one is already set
func (*Appserv) BeginDbTransaction ¶
BeginDbTransaction starts an sql transaction using the base SQL library Begin().
Returns
- the transaction started
- the error
func (*Appserv) BindOriginalFunction ¶
BindOriginalFunction allows to keep in memory that we use a certain name, for a given function
func (*Appserv) Exec ¶
Exec executes a SQL query on the primary database using the base SQL library Exec() procedure. This should be used when you are not expecting any resulting row being selected. Classic examples are INSERT and UPDATE.
Arguments
pQuery: a SQL query to execute (INSERT or UPDATE)
Returns
- the result (this is just information like last index for instance)
- the error
func (*Appserv) GetAppName ¶
GetAppName returns a string representing the appname as it appears in the config
func (*Appserv) GetAppPath ¶
GetAppPath returns the current app path, as configured
func (*Appserv) GetCustomConfig ¶
func (sAppserv *Appserv) GetCustomConfig() ICustomConfig
GetCustomConfig returns the custom config from an app server. The custom config's role is to bring to an application its specific config which has nothing to do with the base Vostok application configuration items.
func (*Appserv) GetDbName ¶
GetDbName returns the primary database name as it was provided into the configuration file.
Returns
- the name of the currently preimary DB the App Server is connected to
func (*Appserv) GetDescription ¶
GetDescription returns a string representing the description as it appears in the config.
func (*Appserv) GetMode ¶
GetMode is an accessor to get the application mode / environnement (live, prelive, dev, ...)
Returns
- the application mode
func (*Appserv) GetNotAuthenticatedCode ¶
GetNotAuthenticatedCode returns the code to return to the client when it/he/she fails to authenticate
func (*Appserv) GetOriginalJobConfig ¶
GetOriginalJobConfig returns a jobConfig instance if it exists
func (*Appserv) GetParentScope ¶
func (sAppserv *Appserv) GetParentScope() LoggingScope
GetParentScope returns the parent scope
func (*Appserv) GetRoutinePoolCapacity ¶
GetRoutinePoolCapacity tells us how many routines we can have running in parallel.
Returns
- the routine pool capacity
func (*Appserv) GetRoutineStats ¶
GetRoutineStats : implementation for Appserv
func (*Appserv) GetScheduledFunction ¶
GetScheduledFunction returns the function scheduled with the given name
func (*Appserv) GetScopeID ¶
GetScopeID returns this scope's ID; scope IDs for sibling scopes should have the same length, for better readability
func (*Appserv) GetSecondaryDB ¶
GetSecondaryDB gets a hangle to the named secondary database as a *sql.DB instance if it exists and has been initialised.
Arguments
pDBID: the DB ID pCheck: if true, then a check is performed, to see if the DB is open
Returns
- the DB corresponding to the given name
- an error, if the DB does not exist, or is not open
func (*Appserv) GetSecondaryDBx ¶
GetSecondaryDBx gets a handle to the named secondary database as a *sqlx.DB instance if it exists and has been initialised.
Arguments
pDBID: the DB ID pCheck: if true, then a check is performed, to see if the DB is open
Returns
- the DB corresponding to the given name
- an error, if the DB does not exist, or is not open
func (*Appserv) GetSecondaryDbName ¶
GetSecondaryDbName returns the secondary database name as it was provided into the configuration file with its ID.
Returns
- the name of the referred secondary DB the App Server is connected to
func (*Appserv) GetSecondaryIDB ¶
GetSecondaryIDB does the same as GetSecondaryDB / GetSecondaryDBx but returns a IDB instance, which can be a SQLx instance of not
func (*Appserv) GetSeparator ¶
GetSeparator returns the separator to use after the scope ID; Most of the time it should be "|", but it could be "]["
func (*Appserv) GetSignature ¶
GetSignature : the scope must retain the result of GetScopeSignature(this) and return it through this method
func (*Appserv) GetSqlLogThreshold ¶
GetSqlLogThreshold returns the time above which we automatically log the SQL request executions; -1 means always
Returns
- the configured duration; if nothing configured
func (*Appserv) GetTokenExp ¶
GetTokenExp the configured token expiration as a duration; it panics if the configured value cannot be parsed as a valid duration.
func (*Appserv) GetUniqueID ¶
GetUniqueID allows to get a unique value associated to the given counter name
Returns
- the unique value
- the error
func (*Appserv) GetVersion ¶
GetVersion returns a string representing the version as it appears in the config.
func (*Appserv) GetVostokAppToken ¶
func (sAppserv *Appserv) GetVostokAppToken(appName string, appURL string, user string, password string, timeout time.Duration) (string, bool, error)
GetVostokAppToken retrieves a token to access another Vostok-based app; returns the token, and a boolean to indicate if it's a new one, or not (i.e. cached one)
func (*Appserv) HasDb ¶
HasDb tells if a main app DB has been configured and initialised.
Returns
- true if a DB instance has been created; false otherwise
func (*Appserv) InitAppDB ¶
func (sAppserv *Appserv) InitAppDB() (vDbManager string, vDbUsername string, vDbName string, vEnableDbConnection bool)
InitAppDB initialises the app DB, if the related config items have been provided in the current config file.
func (*Appserv) InitAuth ¶
func (sAppserv *Appserv) InitAuth()
InitAuth initializes the authentication server along with its authentication DB
func (*Appserv) InitBatcher ¶
func (sAppserv *Appserv) InitBatcher()
InitBatcher initializes a Batcher instance for the App server
func (*Appserv) InitGlobalCache ¶
func (sAppserv *Appserv) InitGlobalCache()
InitGlobalCache : initialising the main global cache (partitioned or not) with the appserv config
func (*Appserv) InitLocalCache ¶
func (sAppserv *Appserv) InitLocalCache()
InitLocalCache : initialising the main local cache with the appserv config
func (*Appserv) InitProfilingTools ¶
InitProfilingTools adds 2 handlers: 1 for action "profiling", and 1 for action "memstats"; The "profiling" action needs a "profname" props, within these possible values: allocs, block, goroutine, heap, mutex, profile, threadcreate, trace, cmdline, symbol,
func (*Appserv) InitRoutinePool ¶
func (sAppserv *Appserv) InitRoutinePool()
InitRoutinePool initialises the routine pool
func (*Appserv) IsDBOpen ¶
IsDBOpen returns a boolean telling you whether there is an open connection to the main (primary) database. It is making use of the Ping() procedure implemented by the SQL driver.
Returns
- true if the primary DB associated with the given App Server is open
func (*Appserv) IsHideFunctionName ¶
IsHideFunctionName tells if the caller function should be hidden or not
func (*Appserv) IsTempLogging ¶
func (*Appserv) IsTestMode ¶
IsTestMode tells whether the application mode is test.
Returns
- true is the mode is Test, false otherwise
func (*Appserv) LogF ¶
LogF creates a prefixed log entry with fields, with a given number of frames skipped
func (*Appserv) NewBatchRoutineContext ¶
func (sAppserv *Appserv) NewBatchRoutineContext(scopeID string) IBatchRoutineContext
From the App server
func (*Appserv) NewRoutine ¶
NewRoutine : implementation for Appserv
func (*Appserv) OpenAndTweakDBConnection ¶
OpenAndTweakDBConnection calls OpenDBConnection with arguments coming from a DB config, and also sets some properties about the connection.
Arguments
dbConfig: an applicationDBConfig instance containing the info needed to open and tweak a DB connection
Returns
- same as OpenDBConnection
Comments
The same comments as for OpenDBConnection apply here.
func (*Appserv) OpenDBConnection ¶
func (sAppserv *Appserv) OpenDBConnection( pDriverName string, pDBName string, pDBHost string, pUsername string, pPassword string, pSQLLib string, ) (IDB, error)
OpenDBConnection opens a database connection using the appropriate driver. The caller does not need to know exactly which lib takes which parameters, the procedure does it for him.
Arguments
pDriverName: the driver name to use pDBName: the database name pDBHost: the database host. Empty string should be used to connect to local host pUsername: the username to use pPassword: the password pSQLLib: the library used for DB connection; if void, the native one is used
Returns
- the database handle
- the error if something not expected happened
Comments
It opens connection according to the DB manager. The format for opening the connection varies and here are the references : PostgreSQL: https://godoc.org/github.com/lib/pq "user=%s dbname=%s password=%s sslmode=disable", pUsername, pDBName, pPassword MySQL: https://github.com/go-sql-driver/mysql/ "%s:%s@%s/%s", pUsername, pPassword, pDBHost, pDBName
func (*Appserv) PullJobWorker ¶
PullJobWorker retrieves a job worker from the pool
func (*Appserv) QueryRow ¶
QueryRow sends a SQL request to the primary database and returns the result set. This encapsulate the base SQL library QueryRow() procedure to allow some login. The difference with QuerySQL() is that it is expecting only one row in return.
Arguments
pQuery: the query to execute pParams: the parameters to pass to the statement
Returns
- the resulting row
func (*Appserv) QuerySQL ¶
QuerySQL sends a SQL request to the primary database and returns the result set. This encapsulate the base SQL library Query() procedure to allow some login.
Arguments
pQuery: the query to execute pParams: the parameters to pass to the statement
Returns
- the resulting rows
- the error
func (*Appserv) ReleaseJobWorker ¶
ReleaseJobWorker puts a job worker back intp the pool
func (*Appserv) RemoveFunction ¶
RemoveFunction removes a function that has been put into the scheduler
func (*Appserv) ScheduleFunction ¶
func (sAppserv *Appserv) ScheduleFunction(name string, schedule string, fn interface{}, args ...interface{}) error
ScheduleFunction puts a named function into the scheduler, with a given schedule, and the function's arguments. This is a low level method that do not use the app server's job configurations. Also, the app server's workers are not involved here. This method should never be used in applicative packages, cf. ScheduleJob instead, or rest.ScheduleAndTrackJob, which allow to run functions that have contexts with DB access and logging functionalities passed to them. WARNING : functions directly scheduled this way are not protected against server shutdowns! Meaning they can be interrupted (by a CTRL+C for example), and leave things in an indeterminate state.
func (*Appserv) ScheduleJob ¶
ScheduleJob puts a function into the scheduler, with a job ID. The function is run with a job worker, that provider functionalities such as DB access and logging.
func (*Appserv) ServeHTTP ¶
func (sAppserv *Appserv) ServeHTTP(pResponseWriter http.ResponseWriter, pRequest *http.Request)
ServeHTTP picks a free child and makes it serve the request. It will wait if none is available, and until one is free to pick up the request. This is the entry point of all request handling process.
Arguments
pResponseWriter: the HTTP connection pRequest: the HTTP request which has been sent
func (*Appserv) SetAuthClientGetterFn ¶
func (sAppserv *Appserv) SetAuthClientGetterFn(fn AuthClientGetterFn)
SetAuthClientGetterFn set the getter function which extract the auth client data
func (*Appserv) SetAuthCustomService ¶
func (sAppserv *Appserv) SetAuthCustomService(authCustomService IAuthCustomService)
SetAuthCustomService set a custom authentication service which provides auth functions
func (*Appserv) SetMainLogger ¶
SetMainLogger allows to set a logrus logger, even if one is already set
func (*Appserv) Start ¶
func (sAppserv *Appserv) Start()
Start actually starts the server using the configuration information which has been read at creation time.
func (*Appserv) StartBatchJob ¶
func (sAppserv *Appserv) StartBatchJob(batchJobID BatchJobID)
StartBatchJob starts a batch job identified by its ID, and scheduled as per the configuration of this job
func (*Appserv) TempLogStart ¶
func (sAppserv *Appserv) TempLogStart(frameSkip int) *TimedTempLog
TempLogStart : not implemented
type AppservCall ¶
type AppservCall func(pAppservChild *AppservChild)
AppservCall is the type of the functions which are actually triggered by an HTTP request. For this reason it has two parameters which are the child of the application server, serving the request and also virtual parameters which are here to call programmatically HTTP handlers when there are no actual HTTP parameters.
type AppservChild ¶
type AppservChild struct {
// contains filtered or unexported fields
}
AppservChild is the application server child process. Children actually handle the requests. This is the reason why it provides access to the current HTTP request and also a link to the application server.
func (*AppservChild) Batcher ¶
func (sAppservChild *AppservChild) Batcher() *Batcher
Batcher : IBatcher implem
func (*AppservChild) BeginDbTransaction ¶
func (sAppservChild *AppservChild) BeginDbTransaction() (*sql.Tx, error)
BeginDbTransaction App Server Child version
func (*AppservChild) BindOriginalFunction ¶
func (sAppservChild *AppservChild) BindOriginalFunction(name string, jfunc interface{})
BindOriginalFunction : implementation for appserv children
func (*AppservChild) DecryptData ¶
func (sAppservChild *AppservChild) DecryptData(pEncryptedData []byte) ([]byte, error)
DecryptData decrypts the data using NaCl SecretBox feature. The nonce is stored into the message itself as shown as an example in the package doc https://godoc.org/golang.org/x/crypto/nacl/secretbox
Arguments
pENcryptedData: the string / data we want to decrypt
Returns
- the decrypted version of the string
func (*AppservChild) EncryptData ¶
func (sAppservChild *AppservChild) EncryptData(pData []byte) ([]byte, error)
EncryptData encrypts the data using NaCl SecretBox feature. The nonce is stored into the message itself as shown as an example in the package doc https://godoc.org/golang.org/x/crypto/nacl/secretbox
Arguments
pData: the string / data we want to encrypt
Returns
- the encrypted version of the string
func (*AppservChild) EndTempLogging ¶
func (sAppservChild *AppservChild) EndTempLogging(removelog bool)
func (*AppservChild) EscapeStringJavascript ¶
func (sAppservChild *AppservChild) EscapeStringJavascript(pString string) string
EscapeStringJavascript escapes javascript strings. For the moment it escapes the following characters: ', " and \
Arguments
pString: the string you want to escape
Returns
- the string escaped so it can be inserted as a Javascript string
func (*AppservChild) Exec ¶
func (sAppservChild *AppservChild) Exec(pQuery string, pParams ...interface{}) (sql.Result, error)
Exec App Server Child version
func (*AppservChild) ExecuteStatement ¶
func (sAppservChild *AppservChild) ExecuteStatement(pName string, pParams ...interface{}) (sql.Result, error)
ExecuteStatement executes the named statement expecting no row in result.
Arguments
pName: the name of the statement to execute pParams: the parameters to pass to the statement
Returns
- the result (this is just information)
- the error
func (*AppservChild) GetAction ¶
func (sAppservChild *AppservChild) GetAction() string
GetAction returns the action currently performed
func (*AppservChild) GetAppName ¶
func (sAppservChild *AppservChild) GetAppName() string
GetAppName App Server Child version
func (*AppservChild) GetAppPath ¶
func (sAppservChild *AppservChild) GetAppPath() string
GetAppPath App Server Child version
func (*AppservChild) GetAppURL ¶
func (sAppservChild *AppservChild) GetAppURL() string
GetAppURL App Server Child version
func (*AppservChild) GetBox ¶
func (sAppservChild *AppservChild) GetBox() string
GetBox App Server Child version
func (*AppservChild) GetChildNumber ¶
func (sAppservChild *AppservChild) GetChildNumber() int
GetChildNumber returns a string representing the child number.
func (*AppservChild) GetCookie ¶
func (sAppservChild *AppservChild) GetCookie(pName string) ([]byte, error)
GetCookie returns the value for the cookie named. If no cookie with this name is found an error ErrNoCookie will be returned. If multiple cookies have the same name, only one will be returned. We assumed the content has been encoded with base64 so we decode the content before returning it.
Arguments
pName: the name of the cookie
Returns
- the value of the cookie if found, nil otherwise
- the error if something not expected happened
func (*AppservChild) GetCurrentHTTPRequest ¶
func (sAppservChild *AppservChild) GetCurrentHTTPRequest() *http.Request
GetCurrentHTTPRequest returns the current http request object the child is processing. It could be useful if you want to get the FormValue values for instance.
Returns
- the current request
func (*AppservChild) GetCurrentResponseWriter ¶
func (sAppservChild *AppservChild) GetCurrentResponseWriter() http.ResponseWriter
GetCurrentResponseWriter returns the current response writer object the child is processing. It could be useful if you want to write some stuff straight away.
Returns
- the current response writer
func (*AppservChild) GetCurrentURL ¶
func (sAppservChild *AppservChild) GetCurrentURL() *url.URL
GetCurrentURL tells the time the current request has started.
func (*AppservChild) GetCustomConfig ¶
func (sAppservChild *AppservChild) GetCustomConfig() ICustomConfig
GetCustomConfig App Server Child version
func (*AppservChild) GetDbName ¶
func (sAppservChild *AppservChild) GetDbName() string
GetDbName App Server Child version
func (*AppservChild) GetDescription ¶
func (sAppservChild *AppservChild) GetDescription() string
GetDescription App Server Child version
func (*AppservChild) GetHTTPMethod ¶
func (sAppservChild *AppservChild) GetHTTPMethod() string
GetHTTPMethod returns the currently used HTTP method
func (*AppservChild) GetIPAddress ¶
func (sAppservChild *AppservChild) GetIPAddress() string
GetIPAddress returns the IP address of the client from which the request has originated. It could be IPv4 as well as IPv6. Since we are working behind a proxy, we need to use the X-Forwarded-For Header property and forget about the RemoteAddress since this will always be the local host 127.0.0.1.
func (*AppservChild) GetLogger ¶
func (sAppservChild *AppservChild) GetLogger() *logrus.Logger
GetLogger indicates how to get the logger from this scope
func (*AppservChild) GetLogin ¶
func (sAppservChild *AppservChild) GetLogin() bool
GetLogin returns the login state for the request.
func (*AppservChild) GetMode ¶
func (sAppservChild *AppservChild) GetMode() AppMode
GetMode App Server Child version
func (*AppservChild) GetOriginalJobConfig ¶
func (sAppservChild *AppservChild) GetOriginalJobConfig(jobID string, doPanicIfNotFound bool) *JobConfig
GetOriginalJobConfig returns a jobConfig instance if it exists
func (*AppservChild) GetParentScope ¶
func (sAppservChild *AppservChild) GetParentScope() LoggingScope
GetParentScope returns the parent scope
func (*AppservChild) GetRoutinePoolCapacity ¶
func (sAppservChild *AppservChild) GetRoutinePoolCapacity() int
func (*AppservChild) GetRoutineStats ¶
func (sAppservChild *AppservChild) GetRoutineStats() (currentUse, maxParaUse, totalUse int)
GetRoutineStats : implementation for AppservChild
func (*AppservChild) GetScheduledFunction ¶
func (sAppservChild *AppservChild) GetScheduledFunction(name string) interface{}
GetScheduledFunction returns the function scheduled with the given name
func (*AppservChild) GetScopeID ¶
func (sAppservChild *AppservChild) GetScopeID() string
GetScopeID returns this scope's ID; scope IDs for sibling scopes should have the same length, for better readibiliy
func (*AppservChild) GetSecondaryDB ¶
GetSecondaryDB App Server Child version
func (*AppservChild) GetSecondaryDBx ¶
GetSecondaryDBx App Server Child version
func (*AppservChild) GetSecondaryDbName ¶
func (sAppservChild *AppservChild) GetSecondaryDbName(id string) string
GetSecondaryDbName App Server Child version
func (*AppservChild) GetSecondaryIDB ¶
func (sAppservChild *AppservChild) GetSecondaryIDB(pDBID string, pCheck bool) (IDB, error)
GetSecondaryIDB child version
func (*AppservChild) GetSeparator ¶
func (sAppservChild *AppservChild) GetSeparator() string
GetSeparator returns the separator to use after the scope ID; Most of the time it should be "|", but it could be "]["
func (*AppservChild) GetSignature ¶
func (sAppservChild *AppservChild) GetSignature() string
GetSignature : the scope must retain the result of GetScopeSignature(this) and return it through this method
func (*AppservChild) GetSqlLogThreshold ¶
func (sAppservChild *AppservChild) GetSqlLogThreshold() time.Duration
GetSqlLogThreshold App Server Child version
func (*AppservChild) GetStartTime ¶
func (sAppservChild *AppservChild) GetStartTime() time.Time
GetStartTime tells the time the current request has started.
func (*AppservChild) GetStatement ¶
func (sAppservChild *AppservChild) GetStatement(pName string) *sql.Stmt
GetStatement is a simple getter to retrieve a statement already prepared using its name.
Arguments
pName: the name of the statement the aller wants to get
Returns
- the statement of nil if it does not exist
func (*AppservChild) GetTokenExp ¶
func (sAppservChild *AppservChild) GetTokenExp() time.Duration
GetTokenExp App Server Child version
func (*AppservChild) GetUniqueID ¶
func (sAppservChild *AppservChild) GetUniqueID(counterName string) (int, error)
GetUniqueID App Server Child version
func (*AppservChild) GetUserInfo ¶
func (sAppservChild *AppservChild) GetUserInfo() *UserInfo
GetUserInfo returns the base user information object.
func (*AppservChild) GetVersion ¶
func (sAppservChild *AppservChild) GetVersion() string
GetVersion App Server Child version
func (*AppservChild) GetVostokAppToken ¶
func (sAppservChild *AppservChild) GetVostokAppToken(appName string, appURL string, user string, password string, timeout time.Duration) (string, bool, error)
GetVostokAppToken : child version
func (*AppservChild) IsCustomAccessAuthorized ¶
func (sAppservChild *AppservChild) IsCustomAccessAuthorized() (bool, error, interface{})
IsAccessAuthorized checks if the client has access to this resource (using currentRequest)
func (*AppservChild) IsCustomAuthUsed ¶
func (sAppservChild *AppservChild) IsCustomAuthUsed() bool
IsCustomAuthUsed returns true if the current request has used a custom auth to check access
func (*AppservChild) IsDBOpen ¶
func (sAppservChild *AppservChild) IsDBOpen() bool
IsDBOpen App Server Child version
func (*AppservChild) IsHideFunctionName ¶
func (sAppservChild *AppservChild) IsHideFunctionName() bool
IsHideFunctionName tells if the caller function should be hidden or not
func (*AppservChild) IsTempLogging ¶
func (sAppservChild *AppservChild) IsTempLogging() bool
IsTempLogging tells is temporary logging is currently being used
func (*AppservChild) IsTestMode ¶
func (sAppservChild *AppservChild) IsTestMode() bool
IsTestMode App Server Child version
func (*AppservChild) IsVerbose ¶
func (sAppservChild *AppservChild) IsVerbose() bool
IsVerbose tells if the log is being verbose, as per its configuration
func (*AppservChild) Log ¶
func (sAppservChild *AppservChild) Log() LogEntry
Log creates a prefixed log entry with no frame skipped, and no field
func (*AppservChild) LogF ¶
func (sAppservChild *AppservChild) LogF(skip int, fields logrus.Fields) LogEntry
LogF creates a prefixed log entry with fields, with a given number of frames skipped
func (*AppservChild) NewRoutine ¶
func (sAppservChild *AppservChild) NewRoutine(scopeID string) Routine
NewRoutine : implementation for AppservChild
func (*AppservChild) PlayJSON ¶
func (sAppservChild *AppservChild) PlayJSON(pJSONObject interface{}, pIndent bool)
PlayJSON does the same as PlayJSONIndent, with the tab character as the default indentation.
func (*AppservChild) PlayJSONError ¶
func (sAppservChild *AppservChild) PlayJSONError(pCallName string, pCallVersion string, pErrorCode string, pErrorTitle string, pErrorMessage string)
PlayJSONError plays the JSON corresponding to the Marshalling of the object. It includes the JSON into the Vostok JSON envelope.
Arguments
pCallName: the name of the call the response is for pCallVersion: the version of the call pErrorCode: error code pErrorTitle: error title pErrorMessage: error message
func (*AppservChild) PlayJSONIndent ¶
func (sAppservChild *AppservChild) PlayJSONIndent(pJSONObject interface{}, pIndentString string)
PlayJSONIndent does the same as PlayJSONIndentWithCode, with a default OK code
func (*AppservChild) PlayJSONIndentWithCode ¶
func (sAppservChild *AppservChild) PlayJSONIndentWithCode(pJSONObject interface{}, pIndentString string, pCode int)
PlayJSONIndentWithCode sends the exact representation of the JSON object to the output with a HTTP code defined by the parameter pCode.
Arguments
pJSONObject: the JSON object to send. pIndent: tells the JSON Marshaller to indent the JSON if set to true. pCode: the HTTP code to use in the response.
func (*AppservChild) PlayJSONResponse ¶
func (sAppservChild *AppservChild) PlayJSONResponse(pCallName string, pCallVersion string, pDataObject interface{})
PlayJSONResponse plays the JSON corresponding to the Marshalling of the object. It includes the JSON into the Vostok JSON envelope.
Arguments
pCallName: the name of the call the response is for pCallVersion: the version of the call pDataObject: the data object to use to play the template
func (*AppservChild) PlayJSONStatus ¶
func (sAppservChild *AppservChild) PlayJSONStatus()
PlayJSONStatus provides information about the current state of the application server. It is encapsulated into a standard Vostok response.
func (*AppservChild) PlayTemplate ¶
func (sAppservChild *AppservChild) PlayTemplate(pTemplateName string, pTemplateType string, pTemplateData interface{})
PlayTemplate plays the template using either the object it has created in a previous call or parsing the template for the first time. It allows to cache the template so we dont load twice the same template.
Arguments
pTemplateName: the name of the template we want to play pTemplateType: file type pTemplateData: the data object to use to play the template
func (*AppservChild) PullJobWorker ¶
func (sAppservChild *AppservChild) PullJobWorker() (*JobWorker, error)
PullJobWorker retrieves a job worker from the pool
func (*AppservChild) QueryRow ¶
func (sAppservChild *AppservChild) QueryRow(pQuery string, pParams ...interface{}) *sql.Row
QueryRow App Server Child version
func (*AppservChild) QuerySQL ¶
func (sAppservChild *AppservChild) QuerySQL(pQuery string, pParams ...interface{}) (*sql.Rows, error)
QuerySQL App Server Child version
func (*AppservChild) QueryStatement ¶
func (sAppservChild *AppservChild) QueryStatement(pName string, pParams ...interface{}) (*sql.Rows, error)
QueryStatement queries the named statement expecting rows in return.
Arguments
pName: the name of the statement to execute pParams: the parameters to pass to the statement
Returns
- the resulting rows
- the error
func (*AppservChild) Redirect ¶
func (sAppservChild *AppservChild) Redirect(pURL string)
Redirect issues a 303 redirection to a given url. We expect a Redirection after each POST.
Arguments
pURL: the url to redirect the client to
func (*AppservChild) ReleaseJobWorker ¶
func (sAppservChild *AppservChild) ReleaseJobWorker(jobWorker *JobWorker)
ReleaseJobWorker puts a job worker back intp the pool
func (*AppservChild) RemoveFunction ¶
func (sAppservChild *AppservChild) RemoveFunction(name string)
RemoveFunction : implementation for appserv children
func (*AppservChild) ScheduleFunction ¶
func (sAppservChild *AppservChild) ScheduleFunction(name string, schedule string, fn interface{}, args ...interface{}) error
ScheduleFunction : implementation for appserv children
func (*AppservChild) SetCookie ¶
func (sAppservChild *AppservChild) SetCookie(pName string, pValue []byte)
SetCookie sets a cookie in the current response's header. It will encode the content using base64 algorithm so there is no issue with the original format. There are other procedures to allow setting more parameters for the cookie.
Arguments:
pName: the name of the cookie pValue: the value we want to store
func (*AppservChild) SetLogin ¶
func (sAppservChild *AppservChild) SetLogin(pLoginState bool)
SetLogin is use to set the login state
func (*AppservChild) SetUserInfo ¶
func (sAppservChild *AppservChild) SetUserInfo(pUserInfo *UserInfo)
SetUserInfo stored the user information.
func (*AppservChild) TempLog ¶
func (sAppservChild *AppservChild) TempLog(frameSkip int, message string, params ...interface{})
TempLog allows to write temporary logs in volatile files that remain only when requests fail
func (*AppservChild) TempLogKeep ¶
func (sAppservChild *AppservChild) TempLogKeep()
TempLogKeep is to use to force the current temporary log to be kept, i.e. not deleted at then; use with caution!
func (*AppservChild) TempLogStart ¶
func (sAppservChild *AppservChild) TempLogStart(frameSkip int) *TimedTempLog
TempLogStart starts a temporary log, i.e. writes "Start" in the current's request temp log. Use at a function's start, like this: defer ctx.TempLogStart().AndStopAtExit()
type AppservError ¶
AppservError is the generic Application server error object
type AuthClientGetterFn ¶
type AuthClientGetterFn func(appServChild *AppservChild, id string) (*UserInfo, error)
AuthClientGetterFn is the generic method to get an AuthClient
type AuthLoginRequest ¶
type AuthLoginRequest struct { Username string `json:"username"` Password string `json:"password"` }
AuthLoginRequest is the main structure to make a login request with auth cookie
type AuthLoginResponse ¶
type AuthLoginResponse struct { UserInfo *UserInfo `json:"userData,omitempty"` Error *authError `json:"error,omitempty"` Expires time.Time `json:"expires,omitempty"` }
AuthLoginResponse is the response for a login request with auth cookie
type BaseUser ¶
type BaseUser struct { Username string `db:"username,64" json:"username" i*:"the user's username; if physical, it MUST be an email address"` Password string `db:"password,255" json:"password" i*:"the user's password (should be a kind of hash)"` Physical bool `db:"physical" json:"physical" in:"if true, then the user is a person, else an application"` FirstName string `db:"firstName,20" json:"firstName,omitempty" in:"the user's first name, if physical"` LastName string `db:"lastName,20" json:"lastName,omitempty" in:"the user's last name, if physical"` Active bool `db:"active" json:"active" in:"makes the user account active or not"` Admin bool `db:"admin" json:"admin" in:"tells if the user has admin rights or not"` SuperUser bool `db:"superUser" json:"superUser" in:"tells if the user has super user rights or not"` RedirectURI string `db:"redirectURI,255" json:"redirectURI,omitempty" in:"the user's redirect URI, when the user is a client app"` }
BaseUser defines the minimal info we need for all kinds of 'User' concepts
func (*BaseUser) ClientSecretMatches ¶
ClientSecretMatches : implementing the ClientSecretMatcher interface
func (*BaseUser) GetRedirectUri ¶
GetRedirectUri returns "<unknown>", because a 'BaseUser' does not provide a "redirect URI" for now
func (*BaseUser) GetUserData ¶
func (thisUser *BaseUser) GetUserData() interface{}
GetUserData returns a copy of base user with only a few fields
type BatchCompartment ¶
type BatchCompartment struct {
// contains filtered or unexported fields
}
BatchCompartment : a compartment stores all the similar units that must be treated altogether, by the same batch
func (*BatchCompartment) ApplyBatchFunction ¶
func (thisCompartment *BatchCompartment) ApplyBatchFunction(batchFnCtx IBatchFunctionContext, doPurge bool) (nbTreated, nbUnitsTot int, err error)
ApplyBatchFunction applies the batch function to all of the batches contained in the given compartment; the basket is also included, if it's old enough: Returns the total number of units in the compartment, the number of units treated at the end, and / or an error if one happens. If purge = true, then we ignore the max number of batches to treat at once + we purge the basket
TODO _OA$?: strange to have return with no value when the signature tells us there are 3 values.
func (*BatchCompartment) GetBatchCompartmentID ¶
func (thisCompartment *BatchCompartment) GetBatchCompartmentID() BatchCompartmentID
GetBatchKey shortcut to know a compartment's configured ID
func (*BatchCompartment) GetBatchJobID ¶
func (thisCompartment *BatchCompartment) GetBatchJobID() BatchJobID
GetBatchJobID shortcut to know the UID of the batch treating this compartment
func (*BatchCompartment) GetBatchesSize ¶
func (thisCompartment *BatchCompartment) GetBatchesSize() int
GetBatchesSize shortcut to know a compartment's configured batchSize
func (*BatchCompartment) GetContext ¶
func (thisCompartment *BatchCompartment) GetContext() interface{}
GetCompartmentContext returns the object serving as a specific context for this compartment
func (*BatchCompartment) GetParams ¶
func (thisCompartment *BatchCompartment) GetParams() map[string]string
GetParams shortcut to know a compartment's configured job parameters
func (*BatchCompartment) SetContext ¶
func (thisCompartment *BatchCompartment) SetContext(compartmentContext IBatchCompartmentContext)
GetCompartmentContext returns the object serving as a specific context for this compartment
type BatchCompartmentConfigCheckingFn ¶
type BatchCompartmentConfigCheckingFn func(compConf IBatchCompartmentConfig) error
BatchCompartmentConfigCheckingFn defines a function that checks the current compartment config
type BatchCompartmentID ¶
type BatchCompartmentID string
BatchCompartmentID is a key that should help us uniquely identify a compartment
func BatchInsertCompartmentID ¶
func BatchInsertCompartmentID(db string, table string) BatchCompartmentID
BatchInsertCompartmentID builds a BatchCompartmentID for the insert batch
type BatchFuncName ¶
type BatchFuncName string
BatchFuncName is used to uniquely refer to a batch function
const ( // BatchFunctionBULKINSERTLINES the generic function handling batch insertions into configured tables BatchFunctionBULKINSERTLINES BatchFuncName = "bulkInsertLines" )
type BatchFunction ¶
type BatchFunction func(ctx IBatchFunctionContext, compartment *BatchCompartment, units []IBatchUnit) error
BatchFunction defines the signature of a function that knows what to do of a set of units, coming from a given compartment
type BatchJobID ¶
type BatchJobID string
BatchJobID is used to uniquely refer to a set of batch compartments treated with the same batch function
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher : an instance of this struct can be attached to the app server and provide services; such as piling work elements to be asynchronously treated in batches, through scheduled jobs
func (*Batcher) GetCompartmentsForJob ¶
func (thisBatcher *Batcher) GetCompartmentsForJob(batchJobUID BatchJobID) map[BatchCompartmentID]*BatchCompartment
GetCompartmentsForJob returns all the compartments that should be handled by the job identified by its batch UID
func (*Batcher) HasPendingWork ¶
HasPendingWork tells us if there is at least 1 unit waiting for treatment
func (*Batcher) Push ¶
func (thisBatcher *Batcher) Push(batchJobID BatchJobID, unit IBatchUnit) (nbInBasket, nbBatches, batchSize int, err error)
Push : pushing the unit in one of the batcher's compartment, to be treated later on; returns the number of units accumulated in the basket, or an error if something went south
func (*Batcher) StartBatchJob ¶
func (thisBatcher *Batcher) StartBatchJob(batchJobID BatchJobID, execContext IBatchFunctionContext)
StartBatchJob starts a batch job identified by its ID, and scheduled as per the configuration of this job
type BulkInsertionsContext ¶
type BulkInsertionsContext struct {
// contains filtered or unexported fields
}
a context for each compartment we'll push stuff into
type Currency ¶
type Currency struct { Code CurrencyCode `json:"code"` Num int `json:"num"` Label string `json:"label"` }
Currency is a structure made to contain the code, the number, and the label of a Currency
func GetCurrency ¶
GetCurrency returns the current for the given currency code, if it exists
type CurrencyCode ¶
type CurrencyCode string
CurrencyCode defines an enum for the type of currencies
const ( CurrencyCodeEUR CurrencyCode = "EUR" CurrencyCodeGBP CurrencyCode = "GBP" CurrencyCodeUSD CurrencyCode = "USD" CurrencyCodeCHF CurrencyCode = "CHF" )
For the codes, check this page: https://en.wikipedia.org/wiki/ISO_4217
func (CurrencyCode) Label ¶
func (thisCurrencyCode CurrencyCode) Label() string
Label returns the currency label associated with the given currency label
func (CurrencyCode) Num ¶
func (thisCurrencyCode CurrencyCode) Num() int
Num returns the currency number associated with the given currency code
func (CurrencyCode) String ¶
func (thisCurrencyCode CurrencyCode) String() string
type CustomAuthAction ¶
type CustomAuthAction string
CustomAuthAction allows user to list the available Custom Authentication actions
const ( // CustomAuthLOGIN the action performed to log in an user CustomAuthLOGIN CustomAuthAction = "login" )
type CustomAuthLoginResponse ¶
type CustomAuthLoginResponse struct { AccessToken string `json:"access_token"` Expires string `json:"expires_in"` TokenType string `json:"token_type"` }
CustomAuthLoginResponse response expected for custom auth login request
type ErrorMessage ¶
ErrorMessage is a simple error message TODO _OA$0: checking whether this is still needed.
type IAppservSibling ¶
type IAppservSibling interface { // Loggers IsVerbose() bool LogF(skip int, fields logrus.Fields) LogEntry Log() LogEntry // DB // QueryRow uses the Appserv version of QueryRow QueryRow(pQuery string, pParams ...interface{}) *sql.Row // QuerySQL uses the Appserv version of QuerySQL QuerySQL(pQuery string, pParams ...interface{}) (*sql.Rows, error) // Exec uses the Appserv version of Exec Exec(pQuery string, pParams ...interface{}) (sql.Result, error) // GetSecondaryIDB retrieve the secondary SQL DB connector as a IDB (interface) GetSecondaryIDB(pDbID string, pCheck bool) (IDB, error) // GetSecondaryDB retrieve the secondary SQL DB connector GetSecondaryDB(pDbID string, pCheck bool) (*sql.DB, error) // GetSecondaryDBx retrieve the secondary SQLx DB connector GetSecondaryDBx(pDbID string, pCheck bool) (*sqlx.DB, error) // BeginDbTransaction starts an sql transaction using the base SQL library BeginDbTransaction() (*sql.Tx, error) // GetDbName returns the name of the current DB we're connected to GetDbName() string // GetSecondaryDbName returns the name of the given secondary DB we're connected to GetSecondaryDbName(id string) string // IsDBOpen tells if the DB has been initialized, or not IsDBOpen() bool // GetUniqueID allows to get a unique value associated to the given counter name GetUniqueID(counterName string) (int, error) // GetSqlLogThreshold returns the time above which we automatically log the SQL request executions; 0 means always GetSqlLogThreshold() time.Duration // Config GetCustomConfig() ICustomConfig GetAppName() string GetAppPath() string GetDescription() string GetVersion() string GetMode() AppMode IsTestMode() bool // WS GetVostokAppToken(appName string, appURL string, user string, password string, timeout time.Duration) (string, bool, error) // Batch processing IBatcherOwner }
IAppservSibling is an interface allowing procedure shared by both AppservChild and JobWorker to be executed in both contexts.
type IAuthCustomService ¶
type IAuthCustomService interface { CheckAuth(appservChild *AppservChild, request *http.Request) (userInfo *UserInfo, targeted bool, statusCode int, reponseBody interface{}) IsAccessAuthorized(appServChild *AppservChild) (isAuthorized bool, err error, userData interface{}) Login(appservChild *AppservChild, request *http.Request) (string, string, error) }
IAuthCustomService is an interface for custom authentication usage
type IBatchCompartmentConfig ¶
type IBatchCompartmentConfig interface { // the unique ID for the batch job this config belongs to GetBatchJobID() BatchJobID // the compartment identifier GetBatchCompartmentID() BatchCompartmentID // the maximal number of units to treat at the same time GetBatchesSize() int // the maximal number of batches to treat at each tick of the scheduler; 0 means : no limit GetNbBatchesAtOnce() int // the maximal duration a basket can stay opened without receiving new batch unit GetPurgeBasketAfter(batchFnCtx IBatchFunctionContext) time.Duration // the compartment's additional parameters GetParams() map[string]string // contains filtered or unexported methods }
IBatchCompartmentConfig defines some characteristics for a batch compartment : an identifier, the batches batchSize, etc.
type IBatchCompartmentContext ¶
type IBatchCompartmentContext interface{}
IBatchCompartmentContext : a context used to persist additional data on a compartment
type IBatchFunctionContext ¶
type IBatchFunctionContext interface { IAppservSibling // we should be able to do pretty much everything while treating batches NewBatchRoutineContext(scopeID string) IBatchRoutineContext // this is the context passed for the treatment of a batch, associated with a new routine }
IBatchFunctionContext gathers all the services needed to perform the batch treatments
type IBatchInsertUnit ¶
type IBatchInsertUnit interface { IBatchUnit GetInsertColumns() []string // a list of the columns to insert for a given unit; MUST be the same list for the units of the same compartment GetInsertValues() []interface{} // a list of values corresponding to the columns }
IBatchInsertUnit is a particular IBatchUnit, made for (you guessed it) batch inserts
type IBatchRoutineContext ¶
type IBatchRoutineContext interface { IBatchFunctionContext // we should be able to do pretty much everything while treating a batch Release() // we must be able to release this routine-based context }
IBatchRoutineContext is the context needed for the treatment of a set of units within a new routine
type IBatchSignature ¶
type IBatchSignature interface { // checks if this signature matches the targeted compartment's signature Matches(compartmentSignature IBatchSignature) error // builds a string from that signature for logging purposes ToString() string }
IBatchSignature : a batch signature allow to check that some batch units have the same form. By sharing the same signature, batch units can be treated altogether. A batch unit that has a different signature has to be rejected.
var BatchUnitAutoSign IBatchSignature = &genericBatchUnitAutoSign{}
BatchUnitAutoSign : The instance to use to "auto-sign" batch units
type IBatchUnit ¶
type IBatchUnit interface { // returns the key that must uniquely identify the compartment this unit must land into, before it is treated by the corresponding batch GetBatchCompartmentID() BatchCompartmentID // can this unit enter the given compartment ? must return an error if not IsAllowed(compartment *BatchCompartment) error // a signature - of simple or complex type (object) - that should be shared by all the batch units pushed into a given compartment GetSignature() IBatchSignature }
IBatchUnit designates a unit treated in a batch, along with other similar units
type IBatcherOwner ¶
type IBatcherOwner interface {
Batcher() *Batcher
}
IBatcherOwner defines the capacity to give an access to an IBatcher instance
type ICache ¶
type ICache interface { // Get is the method that allows to retrieve an object from the cache, given a corresponding key Get(key string) (interface{}, bool) // Set is the method that allows to put an object into the cache, with an expiration time Set(key string, object interface{}, expiration time.Duration) // SetDefault is the method that allows to put an object into the cache, with the default configured expiration time SetDefault(key string, object interface{}) // Delete the entry corresponding to the given key Delete(key string) // Add is the method to put an object into the cache if it is not there yet, or is expired, // and returns an error if there's already something with this key Add(key string, object interface{}, expiration time.Duration) error // Flush removes all the entries from the cache Flush() }
ICache defines what services a cache should provide
type ICachePartition ¶
type ICachePartition interface { // PartitionName returns the partition's name PartitionName() string }
ICachePartition is the type for objects used to identify cache spaces
func NewPartition ¶
func NewPartition(partitionName string) ICachePartition
NewPartition can be used to create a new cache partition, while ensuring there's not an existing partition with the same name created THIS WAY. WARNING : this does NOT ensure that there isn't a partition created through another method with the same name ! i.e. this function does not completely prevent name collisions. So stay aware of all the partitions you have !
type IConfigFile ¶
type IConfigFile interface { GetServerConfig() *ServerConfig GetCustomConfig() ICustomConfig }
IConfigFile defines the generic services provided by a config file
type ICustomConfig ¶
type ICustomConfig interface { // IsValid return nil if it's valid, or an error to indicate something's wrong or missing IsValid() error }
ICustomConfig gives a handle to a custom part of the server config
type IDB ¶
type IDB interface { // Ping verifies a connection to the database is still alive, // establishing a connection if necessary. Ping() error // Exec executes a query without returning any rows. // The args are for any placeholder parameters in the query. Exec(query string, args ...interface{}) (sql.Result, error) // Query executes a query that returns rows, typically a SELECT. // The args are for any placeholder parameters in the query. Query(query string, args ...interface{}) (*sql.Rows, error) // QueryRow executes a query that is expected to return at most one row. // QueryRow always returns a non-nil value. Errors are deferred until // Row's Scan method is called. // If the query selects no rows, the *Row's Scan will return ErrNoRows. // Otherwise, the *Row's Scan scans the first selected row and discards // the rest. QueryRow(query string, args ...interface{}) *sql.Row // Begin starts a transaction. The default isolation level // is dependent on the driver. Begin() (*sql.Tx, error) // Prepare creates a prepared statement for use within a transaction. // The returned statement operates within the transaction and can no longer // be used once the transaction has been committed or rolled back. // To use an existing prepared statement on this transaction, see Tx.Stmt. Prepare(query string) (*sql.Stmt, error) // SetConnMaxLifetime sets the maximum amount of time a connection may be reused. // Expired connections may be closed lazily before reuse. // If d <= 0, connections are reused forever. SetConnMaxLifetime(d time.Duration) // SetMaxOpenConns sets the maximum number of open connections to the database. // If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than // MaxIdleConns, then MaxIdleConns will be reduced to match the new // MaxOpenConns limit. // If n <= 0, then there is no limit on the number of open connections. // The default is 0 (unlimited). SetMaxOpenConns(n int) // SetMaxIdleConns sets the maximum number of connections in the idle // connection pool. // If MaxOpenConns is greater than 0 but less than the new MaxIdleConns, // then the new MaxIdleConns will be reduced to match the MaxOpenConns limit. // If n <= 0, no idle connections are retained. // The default max idle connections is currently 2. This may change in // a future release. SetMaxIdleConns(n int) // Stats returns database statistics. Stats() sql.DBStats }
IDB defines the common methods we're using on a DB connection manager
type IGlobalCache ¶
type IGlobalCache interface { ICache // a global cache is a cache... }
IGlobalCache defines what services a global (-as opposed to global) cache should provide TODO : put a cache server behind this, like gomemcache.
func GetGlobalCache ¶
func GetGlobalCache() IGlobalCache
GetGlobalCache returns the global cache associated with the given Appserv instance if the global cache has not been initialised we naturally panic telling whoever reads the log that the calling code need to InitGlobalCache() before. WARNING: can be used only if NoPartition = true in the config.
type ILocalCache ¶
type ILocalCache interface { ICache // a local cache is a cache... }
ILocalCache defines what services a local (-as opposed to global) cache should provide TODO _JW$0: maybe we should remove the local cache ?? or at least, consider it only for "static" objects like entity schemas TODO _JW$0: for everything that can be changed - from the webapp for instance -> caching in a Shared Cache
func GetLocalCache ¶
func GetLocalCache() ILocalCache
GetLocalCache returns the local cache associated with the given Appserv instance if the local cache has not been initialised we naturally panic telling whoever reads the log that the calling code need to InitLocalCache() before.
func NewLocalCache ¶
func NewLocalCache(localDefaultExpiration time.Duration, localCleanupInterval time.Duration) ILocalCache
NewLocalCache returns a new instance implementing the interface ILocalCache
type IPartitionedCache ¶
type IPartitionedCache interface { // Get is the method that allows to retrieve an object from the cache, given a corresponding key Get(partition ICachePartition, key string) (interface{}, bool) // Set is the method that allows to put an object into the cache, with an expiration time Set(partition ICachePartition, key string, object interface{}, expiration time.Duration) // SetDefault is the method that allows to put an object into the cache, with the default configured expiration time SetDefault(partition ICachePartition, key string, object interface{}) // Delete the entry corresponding to the given key Delete(partition ICachePartition, key string) // Add is the method to put an object into the cache if it is not there yet, or is expired, // and returns an error if there's already something with this key Add(partition ICachePartition, key string, object interface{}, expiration time.Duration) error // AllItems returns a map of all the items cached in one cache partition, with their original keys // WARNING : should be used with caution since this can lead to performance issues. AllItems(partition ICachePartition) map[string]interface{} // Flush deletes all the entries from the given cache partition Flush(partition ICachePartition) // Partitions lists all the partitions currently in use Partitions() map[string]ICachePartition }
IPartitionedCache helps dealing with a partitioned global cache
func GetPartitionedCache ¶
func GetPartitionedCache() IPartitionedCache
GetPartitionedCache returns the global cache associated with the given Appserv instance if the global cache has not been initialised we naturally panic telling whoever reads the log that the calling code need to InitGlobalCache() before. WARNING: can be used only if NoPartition = true in the config.
type IStringNormalizer ¶
type IStringNormalizer interface { // basic normalization function: "Yoùr Śtring šđč枊ĐČĆŽ Ötzi's Nationalität èàì" => "Your String sđcczSĐCCZ Otzi's Nationalitat eai" String(str string) (result string, err error) // normalizes and capitalizes: Jean-Vincent Placé => JEAN-VINCENT PLACE ToUpper(str string) (result string, err error) }
IStringNormalizer defines the functions our string normalizer should expose
func NewStringNormalizer ¶
func NewStringNormalizer() IStringNormalizer
IStringNormalizer returns a non-thread-safe string normalizer instance
type ITokenResponse ¶
ITokenResponse interface that must be implemented by all token response
type JSONConfigFile ¶
type JSONConfigFile struct { VostokInfo map[string]string `json:"vostok"` Config *ServerConfig `json:"configuration"` }
JSONConfigFile represents the structure of a config file used by a Vostok app
func (*JSONConfigFile) GetCustomConfig ¶
func (thisFile *JSONConfigFile) GetCustomConfig() ICustomConfig
GetCustomConfig helps implement the IConfigFile interface
func (*JSONConfigFile) GetServerConfig ¶
func (thisFile *JSONConfigFile) GetServerConfig() *ServerConfig
GetServerConfig helps implement the IConfigFile interface
type JSONResponse ¶
type JSONResponse struct { VostokHeader *JSONResponseHeader `json:"VostokHeader"` VostokData interface{} `json:"VostokData"` }
JSONResponse is the root object on which are based the base vostok JSON responses.
type JSONResponseError ¶
type JSONResponseError struct { Code string `json:"Code"` Title string `json:"Title"` Message string `json:"Message"` }
JSONResponseError the JSON error
type JSONResponseHeader ¶
type JSONResponseHeader struct { VostokVersion string `json:"VostokVersion"` Box string `json:"Box"` AppName string `json:"AppName"` AppVersion string `json:"AppVersion"` CallName string `json:"CallName"` ResponseType string `json:"ResponseType"` }
JSONResponseHeader the JSON response header
type JSONResponseStatus ¶
type JSONResponseStatus struct { NbRequests uint64 `json:"NbRequests"` CGIURL string `json:"CGIURL"` Port int `json:"Port"` Memory *responseStatusMemory `json:"Memory"` Children []*responseStatusChildren `json:"Children"` }
JSONResponseStatus correspond to the object which will be sent back by the Status special request.
type JSONTime ¶
JSONTime correspond to a time.Time field compatible with JSON Marshalling.
func (JSONTime) MarshalJSON ¶
MarshalJSON is called implicitly when Marshalling a JSONTime object.
type JobConfig ¶
type JobConfig struct { // the job config unique identifier UID string `json:"UID"` // description of the job Description string `json:"Description"` // the schedule, set as a cron task; can be overridden in a REST application Schedule string `json:"Schedule"` // if true, then jobs are triggered with this config; else, nothing happen with this config Active bool `json:"Active"` // if true, then the values of the parameters contained in the config files are used over other versions of these values (in a DB for instance) UseConfig bool `json:"UseConfig"` // additional params for the job Params map[string]string `json:"Params"` }
JobConfig holds the configuration for workers
type JobWorker ¶
type JobWorker struct {
// contains filtered or unexported fields
}
JobWorker gives access to the scheduler and the app server, and their methods
func (*JobWorker) BeginDbTransaction ¶
BeginDbTransaction start an sql transaction
func (*JobWorker) GetAppName ¶
GetAppName : returns the current app name
func (*JobWorker) GetAppPath ¶
GetAppPath : returns the current app path
func (*JobWorker) GetCustomConfig ¶
func (thisWorker *JobWorker) GetCustomConfig() ICustomConfig
GetCustomConfig : returns the current custom config, i.e. the config belonging to a specific app
func (*JobWorker) GetDbName ¶
GetDbName : the name of the currently configured DB we're connected to
func (*JobWorker) GetDescription ¶
GetDescription : returns the current app description
func (*JobWorker) GetParentScope ¶
func (thisWorker *JobWorker) GetParentScope() LoggingScope
GetParentScope returns the parent scope
func (*JobWorker) GetRoutineStats ¶
GetRoutineStats : implementation for JobWorker
func (*JobWorker) GetScopeID ¶
GetScopeID returns this scope's ID; scope IDs for sibling scopes should have the same length, for better readibiliy
func (*JobWorker) GetSecondaryDB ¶
GetSecondaryDB returns a secondary DB, as a *sql.DB instance, if it exists, and has been initialised
func (*JobWorker) GetSecondaryDBx ¶
GetSecondaryDBx returns a secondary DB, as a *sqlx.DB instance, if it exists, and has been initialised
func (*JobWorker) GetSecondaryDbName ¶
GetSecondaryDbName : the name of a secondary DB identified by its ID
func (*JobWorker) GetSecondaryIDB ¶
GetSecondaryDB returns a secondary DB, as a IDB instance, if it exists, and has been initialised
func (*JobWorker) GetSeparator ¶
GetSeparator returns the separator to use after the scope ID; Most of the time it should be "|", but it could be "]["
func (*JobWorker) GetSignature ¶
GetSignature : the scope must retain the result of GetScopeSignature(this) and return it through this method
func (*JobWorker) GetSqlLogThreshold ¶
GetSqlLogThreshold returns the duration above which SQL executions are logged
func (*JobWorker) GetUniqueID ¶
GetUniqueID allows to get a unique value associated to the given counter name
func (*JobWorker) GetVersion ¶
GetVersion : returns the current app version
func (*JobWorker) GetVostokAppToken ¶
func (thisWorker *JobWorker) GetVostokAppToken(appName string, appURL string, user string, password string, timeout time.Duration) (string, bool, error)
GetVostokAppToken retrieves a token to access another Vostok-based app
func (*JobWorker) GetWorkerID ¶
GetWorkerID returns the worker ID
func (*JobWorker) GetWorkerUses ¶
GetWorkerUses returns the number of jobs this worker has been treated
func (*JobWorker) IsDBOpen ¶
IsDBOpen : true if the DB associated with the given App Server or Child is open
func (*JobWorker) IsHideFunctionName ¶
IsHideFunctionName tells if the caller function should be hidden or not
func (*JobWorker) IsTempLogging ¶
IsTempLogging tells is temporary logging is currently being used
func (*JobWorker) IsTestMode ¶
IsTestMode : tells if we're in test mode or not
func (*JobWorker) IsVerbose ¶
IsVerbose : tells if we're in verbose mode; a logger can tell since it has to know to chose what to log
func (*JobWorker) LogF ¶
LogF creates a prefixed log entr, with fiel, y with a given number of frames skippds
func (*JobWorker) NewBatchRoutineContext ¶
func (thisWorker *JobWorker) NewBatchRoutineContext(scopeID string) IBatchRoutineContext
From one the app server's job workers
func (*JobWorker) NewRoutine ¶
NewRoutine : implementation for JobWorker
func (*JobWorker) QuerySQL ¶
func (thisWorker *JobWorker) QuerySQL(queryAsString string, values ...interface{}) (*sql.Rows, error)
QuerySQL should execute a query bringing back rows from the DB
func (*JobWorker) TempLogKeep ¶
func (thisWorker *JobWorker) TempLogKeep()
TempLogKeep : not implemented
func (*JobWorker) TempLogStart ¶
func (thisWorker *JobWorker) TempLogStart(frameSkip int) *TimedTempLog
TempLogStart : not implemented
type LogEntry ¶
type LogEntry interface { Trace(format string, args ...interface{}) Debug(format string, args ...interface{}) Info(format string, args ...interface{}) Warn(format string, args ...interface{}) Error(format string, args ...interface{}) Fatal(format string, args ...interface{}) Panic(format string, args ...interface{}) AtLevel(level logrus.Level, format string, args ...interface{}) }
LogEntry is the interface we want to expose
type LoggingScope ¶
type LoggingScope interface { // LogF creates a prefixed log entry wither of frames skipped, with fields LogF(skip int, fields logrus.Fields) LogEntry // Log creates a prefixed log entry with no frame skipped, and no field Log() LogEntry // GetParentScope returns the parent scope GetParentScope() LoggingScope // GetLogger indicates how to get the logger from this scope GetLogger() *logrus.Logger // GetScopeID returns this scope's ID; scope IDs for sibling scopes // should have the same length, for better readibiliy GetScopeID() string // GetSignature : the scope must retain the result of GetScopeSignature(this) // and return it through this method GetSignature() string // GetSeparator returns the separator to use after the scope ID; // Most of the time it should be "|", but it could be "][" GetSeparator() string // IsVerbose tells if the log is being verbose, as per its configuration IsVerbose() bool // IsHideFunctionName tells if the caller function should be hidden or not IsHideFunctionName() bool // IsTempLogging tells if this scope can currently write temporary logs IsTempLogging() bool // TempLog allows to write temporary logs in volatile files that remain only when requests fail // Use frameSkip = 0 if you want to display the current caller's name; 1 if you want the super-caller, etc. TempLog(frameSkip int, message string, params ...interface{}) // TempLogStart starts a temporary log, i.e. writes "Start" in the current's request temp log. // Use at a function's start, like this: defer ctx.TempLogStart().AndStopAtExit() TempLogStart(frameSkip int) *TimedTempLog // TempLogKeep is to use to force the current temporary log to be kept, i.e. not deleted at then; use with caution! TempLogKeep() }
LoggingScope helps use define what is a scope in terms of logging.
type OAuthAction ¶
type OAuthAction string
OAuthAction allows use to list the available OAuth actions
type RegExpPattern ¶
type RegExpPattern struct {
// contains filtered or unexported fields
}
RegExpPattern provide both the object used to match the regexp and the string definition
var ( // VOSTOK_REGEXP_UINT matches unsigned integers VOSTOK_REGEXP_UINT *RegExpPattern // VOSTOK_REGEXP_INT matches signed integers VOSTOK_REGEXP_INT *RegExpPattern // VOSTOK_REGEXP_FLOAT matches floating points numbers VOSTOK_REGEXP_FLOAT *RegExpPattern // VOSTOK_REGEXP_TIMESTAMP matches Mysql types timestamps YYYY-MM-DD HH:MM:SS.uuuuuu VOSTOK_REGEXP_TIMESTAMP *RegExpPattern // VOSTOK_REGEXP_TIMESTAMP_LONG matches Mysql types timestamps YYYY-MM-DD HH:MM:SS VOSTOK_REGEXP_TIMESTAMP_LONG *RegExpPattern // VOSTOK_REGEXP_TIMESTAMP_MEDIUM matches Mysql types timestamps YYYY-MM-DD HH:MM VOSTOK_REGEXP_TIMESTAMP_MEDIUM *RegExpPattern // VOSTOK_REGEXP_TIMESTAMP_SHORT matches Mysql types timestamps YYYY-MM-DD VOSTOK_REGEXP_TIMESTAMP_SHORT *RegExpPattern // VOSTOK_REGEXP_TIMESTAMP_YEAR matches a four chars Year VOSTOK_REGEXP_TIMESTAMP_YEAR *RegExpPattern // VOSTOK_REGEXP_MD5 matches the MD5 32 hex digits format VOSTOK_REGEXP_MD5 *RegExpPattern // VOSTOK_REGEXP_NAME matches names with letters and underscore and dash VOSTOK_REGEXP_NAME *RegExpPattern // VOSTOK_REGEXP_IP matches IPv4 or IPv6 IP addresses VOSTOK_REGEXP_IP *RegExpPattern )
func NewRegExpPattern ¶
func NewRegExpPattern(pPattern string) *RegExpPattern
NewRegExpPattern returns a new RegExpPattern object by compiling the string definition provides as an parameter.
Arguments
pPattern: the pattern as a string
func (*RegExpPattern) MatchString ¶
func (sRegExpPattern *RegExpPattern) MatchString(pString string) bool
MatchString does nothing clever but just reuse the MatchString from Go package regexp.
Arguments
pString: the string you want to test against the regexp pattern.
Returns
- true if it matches, false otherwise.
type Routine ¶
type Routine interface { Release() // this should make the inner routine go back into the pool RoutineOwner // we should be able to start a routine from a routine! }
Routine is an interface for the objects that should: - wrap a routine - offer the same services as the appserv, its children, or workers
type RoutineOwner ¶
type RoutineOwner interface { LoggingScope // it should allow scoped logs IAppservSibling // it should exposes the services we need while doing stuff inside a routine IBatcherOwner // it should be able to pile on stuff to treat in batches // contains filtered or unexported methods }
RoutineOwner is the type of the objects that can start a new routine, log, and access the DB
type ServerConfig ¶
type ServerConfig struct { Box string `json:"Box"` AppName string `json:"AppName"` Description string `json:"Description"` Version string `json:"Version"` Application *applicationConfig `json:"Application"` Items map[string]string `json:"Items"` Flags map[string]bool `json:"Flags"` Custom ICustomConfig `json:"Custom"` }
ServerConfig is the root object holding the configuration items
func BuildConfig ¶
func BuildConfig(pConfigFilePath string) (rConfig *ServerConfig, rErr error)
BuildConfig read a configuration file and hydrates a Server configuration object. This expects the configuration file to be a JSON file. This procedure doesn't use any specific configuration object as an argument which means it will not generate any custom configuration.
Arguments
pConfigFilePath: the name of the config item for which we want the value
Returns
- the root config object for the server
- the error if there is one
type SessionAuthAction ¶
type SessionAuthAction string
SessionAuthAction allows use to list the available Session Authentication actions
const ( // SessionAuthLOGIN the action performed to log in an user SessionAuthLOGIN SessionAuthAction = "login" // SessionAuthLOGOUT the action performed to log out an user SessionAuthLOGOUT SessionAuthAction = "logout" )
type StatelessAuthAction ¶
type StatelessAuthAction string
StatelessAuthAction allows user to list the available Stateless Authentication actions
const ( // StatelessAuthLOGIN the action performed to log in an user StatelessAuthLOGIN StatelessAuthAction = "login" // StatelessAuthLOGOUT the action performed to log out an user StatelessAuthLOGOUT StatelessAuthAction = "logout" )
type SuccessMessage ¶
SuccessMessage is a simple success message TODO _OA$0: checking whether if is still needed.
type TimedTempLog ¶
type TimedTempLog struct {
// contains filtered or unexported fields
}
timedTempLogContext : used as a short-lived context associated with a function's scope Use : defer ctx.TempLogStart(0).StopAtExit()
func (*TimedTempLog) StopAtExit ¶
func (thislog *TimedTempLog) StopAtExit()
StopAtExit : use = 'defer logger.TempLogStart(0).StopAtExit()' at the beginning of a function!
Source Files ¶
- auth_.go
- auth_cookie_utils.go
- auth_custom.go
- auth_db.go
- auth_oauth.go
- auth_oauth_utils.go
- auth_session.go
- auth_session_utils.go
- auth_stateless.go
- batcher_.go
- batcher_conf.go
- batcher_defs.go
- batcher_func.go
- batcher_inserts.go
- batcher_serv.go
- batcher_utils.go
- cache.go
- config.go
- crypto.go
- date_.go
- db_.go
- db_utils.go
- finance.go
- logging_init.go
- logging_proxy.go
- logging_scope.go
- logging_temp.go
- math_.go
- player.go
- profiling.go
- regexp_.go
- routine_.go
- routine_stats.go
- scheduler.go
- server_.go
- server_gzipped.go
- shutdown.go
- stats.go
- string_.go
- util.go
- worker.go
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
_archives/sigterm/go
------------------------------------------------------------------------------ Here, we put code that would normally be put into 3 seperate files ------------------------------------------------------------------------------
|
------------------------------------------------------------------------------ Here, we put code that would normally be put into 3 seperate files ------------------------------------------------------------------------------ |
packages
|
|
taskengine
------------------------------------------------------------------------------ NB: the code here has been initialized by using the VSCode snippet "New Entity BI"; we leave all the commented code here to show all the methods that can be overridden ------------------------------------------------------------------------------
|
------------------------------------------------------------------------------ NB: the code here has been initialized by using the VSCode snippet "New Entity BI"; we leave all the commented code here to show all the methods that can be overridden ------------------------------------------------------------------------------ |