Documentation ¶
Overview ¶
Package config will have necessary configuration for the application
Index ¶
Constants ¶
const ( //DbHost is the environment variable storing the database access url DbHost = "DB_HOST" //DbPort is the environment variable storing the database access port DbPort = "DB_PORT" //DbDatabaseName is the environment variable storing the database name DbDatabaseName = "DB_DATABASE_NAME" //DbUsername is the environment variable storing the database username DbUsername = "DB_USERNAME" //DbPassword is the environment variable storing the database password DbPassword = "DB_PASSWORD" //EnabledDB is the environment variable stating whether the db is enabled or not EnabledDB = "ENABLE_DB" )
Variables ¶
var ( //Port in which the application is being served Port = "8090" //IntPort is the port converted into integer IntPort = 8090 //RPCPort in which the application's rpc server is being served RPCPort = "8091" //RPCIntPort is the rpc port converted into integer RPCIntPort = 8091 //ResponseTimeout of the api to respond in milliseconds ResponseTimeout = time.Duration(10000 * time.Millisecond) //RequestRTimeout of the api request body read timeout in milliseconds RequestRTimeout = time.Duration(2000 * time.Millisecond) //ResponseWTimeout of the api response write timeout in milliseconds ResponseWTimeout = time.Duration(2000 * time.Millisecond) //MaxRequests is the maximum no. of requests catered at a given point of time MaxRequests = 1000 //RequestCleanUpCheck is the time after which request cleanup check has to happen RequestCleanUpCheck = time.Duration(2 * time.Minute) //DiscoveryURL is the url of the discovery service DiscoveryURL = "127.0.0.1:8500" //DiscoveryToken is the token to communicate with discovery service DiscoveryToken = "" //ServiceDomain is the url on which the service will be available across the platform ServiceDomain = "127.0.0.1" )
var DataIntegrationServiceID = "Brain-Data-Integeration-Service"
DataIntegrationServiceID is the data integration service id to be used with the discovery service
var DataIntegrationServiceRPCID = "Brain-Data-Integration-Service-RPC"
DataIntegrationServiceRPCID is the data integration service's rpc service id to be used with the discovery service
var IsTest bool
IsTest indicates that the current runtime is for test
var ( //PRODUCTION is the switch to turn on and off the Production environment. //1: On, 0: Off PRODUCTION = 0 )
var SkipVault bool
SkipVault will skip the vault initialization if set true
Functions ¶
Types ¶
type AppContext ¶
type AppContext struct { //Db is the database connection Db *gorm.DB //Log for logging purposes Log Logger //Session is the session associated with the request Session authConfig.Session }
AppContext contains the
func NewAppContext ¶
func NewAppContext(l Logger) *AppContext
NewAppContext returns an initlized app context
func (*AppContext) ConnectToDB ¶
func (a *AppContext) ConnectToDB() error
ConnectToDB connects the database and updates the Db property of the context as new connection If any error happens in between , it will be returned and connection won't be set in the context
type DbConfig ¶
type DbConfig struct { //Host to be used to connect to the database Host string //Port with which the database can be accessed Port string //Database to connect Database string //Username to access the connection Username string //Password to access the connection Password string }
DbConfig is the database configuration to connect to it
func NewDbConfig ¶
func NewDbConfig() *DbConfig
NewDbConfig will read the db config from the os environment variables and set it in the config
type Logger ¶
type Logger interface { //Info logs the informative logs Info(l ...interface{}) //Debug logs for the debugging logs Debug(l ...interface{}) //Warn logs the warning logs Warn(l ...interface{}) //Error logs the error Error(l ...interface{}) //Fatal logs the fatal issues Fatal(l ...interface{}) //GetID returns the ID of the logger GetID() int }
Logger must be implemented by the logger utilities to be an app logger