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 = "8081" //IntPort is the port converted into integer IntPort = 8081 //RPCPort in which the application's rpc server is being served RPCPort = "8082" //RPCIntPort is the rpc port converted into integer RPCIntPort = 8082 //ResponseTimeout of the api to respond in milliseconds ResponseTimeout = time.Duration(12000 * time.Millisecond) //RequestRTimeout of the api request body read timeout in milliseconds RequestRTimeout = time.Duration(10000 * time.Millisecond) //ResponseWTimeout of the api response write timeout in milliseconds ResponseWTimeout = time.Duration(1000 * 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" //FileDumpDirectory is the directory to dump the uploaded files FileDumpDirectory = Separator + "cuttle.ai" + Separator + "uploaded-files" + Separator //DoSCPFileTransfer will do file transfers over scp to the datastore. If false, it will do a simple cp assuming the datastore store is the same server DoSCPFileTransfer = true )
var FileUploadServiceID = "Brain-File-Upload-Service"
FileUploadServiceID is the file upload service id to be used with the discovery service
var FileUploadServiceRPCID = "Brain-File-Upload-Service-RPC"
FileUploadServiceRPCID is the file upload 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 Separator = string([]byte{filepath.Separator})
Separator is the file separator used by the underlying os
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
func (AppContext) DiscoveryAddress ¶
func (a AppContext) DiscoveryAddress() string
DiscoveryAddress of thedisocvery service
func (AppContext) DiscoveryToken ¶
func (a AppContext) DiscoveryToken() string
DiscoveryToken of the discovery service
func (AppContext) Logger ¶
func (a AppContext) Logger() bLog.Log
Logger returns the logger of the app 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