Documentation ¶
Overview ¶
Package env provides runtime, server level setup and configuration
Package env provides runtime, server level setup and configuration ¶
Package env provides runtime, server level setup and configuration ¶
Package env provides runtime, server level setup and configuration ¶
Package env provides runtime, server level setup and configuration ¶
Package env provides runtime, server level setup and configuration
Index ¶
Constants ¶
const ( // SiteModeNormal serves app SiteModeNormal = "" // SiteModeOffline serves offline.html SiteModeOffline = "1" // SiteModeSetup tells Ember to serve setup route SiteModeSetup = "2" // SiteModeBadDB redirects to db-error.html page SiteModeBadDB = "3" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigToml ¶
type ConfigToml struct { HTTP httpConfig `toml:"http"` Database databaseConfig `toml:"database"` Install installConfig `toml:"install"` }
ConfigToml represents configuration file that contains all flags as per above.
type Flags ¶
type Flags struct { DBType string // database type DBConn string // database connection string Salt string // the salt string used to encode JWT tokens HTTPPort string // (optional) HTTP or HTTPS port ForceHTTPPort2SSL string // (optional) HTTP that should be redirected to HTTPS SSLCertFile string // (optional) name of SSL certificate PEM file SSLKeyFile string // (optional) name of SSL key PEM file SiteMode string // (optional) if 1 then serve offline web page Location string // reserved ConfigSource string // tells us if configuration info was obtained from command line or config file }
Flags provides access to environment and command line switches for this program.
func LoadConfig ¶
LoadConfig loads runtime parameters like port numbers and DB connections. We first check for -config switch that would point us towards a .CONF file. If not found, we then read parameters from command line and environment vars.
func (*Flags) SSLEnabled ¶
SSLEnabled returns true if both cert and key were provided at runtime.
type Logger ¶
type Logger interface { Info(message string) Infof(message string, a ...interface{}) Trace(message string) Error(message string, err error) }
Logger provides the interface for Documize compatible loggers.
type Runtime ¶
type Runtime struct { Flags Flags Db *sqlx.DB StoreProvider StoreProvider Log Logger Product domain.Product }
Runtime provides access to database, logger and other server-level scoped objects. Use Context for per-request values.
func (*Runtime) Commit ¶ added in v1.76.1
Commit flushes pending changes to database. Any error encountered during this operation is logged to runtime logger.
type StoreProvider ¶ added in v1.71.0
type StoreProvider interface { // Name of provider Type() StoreType // TypeVariant returns flavor of database provider. TypeVariant() StoreType // SQL driver name used to open DB connection. DriverName() string // Database connection string parameters that must be present before connecting to DB. Params() map[string]string // Example holds storage provider specific connection string format. // used in error messages Example() string // DatabaseName holds the SQL database name where Documize tables live. DatabaseName() string // Make connection string with default parameters. MakeConnectionString() string // QueryMeta is how to extract version number, collation, character set from database provider. QueryMeta() string // QueryRecordVersionUpgrade returns database specific insert statement // that records the database version number. QueryRecordVersionUpgrade(version int) string // QueryRecordVersionUpgrade returns database specific insert statement // that records the database version number. // For use on databases before The Great Schema Migration (v25, MySQL). QueryRecordVersionUpgradeLegacy(version int) string // QueryGetDatabaseVersion returns the schema version number. QueryGetDatabaseVersion() string // QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL). QueryGetDatabaseVersionLegacy() string // QueryTableList returns a list tables in Documize database. QueryTableList() string // QueryDateInterval returns provider specific // interval style date SQL. QueryDateInterval(days int64) string // JSONEmpty returns empty SQL JSON object. // Typically used as 2nd parameter to COALESCE(). JSONEmpty() string // JSONGetValue returns JSON attribute selection syntax. // Typically used in SELECT <my_json_field> query. JSONGetValue(column, attribute string) string // VerfiyVersion checks to see if actual database meets // minimum version requirements. VerfiyVersion(dbVersion string) (versionOK bool, minVerRequired string) // VerfiyCharacterCollation checks to see if actual database // has correct character set and collation settings. VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string) // ConvertTimestamp returns SQL function to correctly convert // ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific // timestamp value (e.g. 2016-09-08 06:37:23). // Must use ? for parameter placeholder character as DB layer // will convert to database specific parameter placeholder character. ConvertTimestamp() (statement string) // IsTrue returns storage provider boolean TRUE: // MySQL is 1, PostgresSQL is TRUE, SQL Server is 1 IsTrue() string // IsFalse returns storage provider boolean FALSE: // MySQL is 0, PostgresSQL is FALSE, SQL Server is 0 IsFalse() string // RowLimit returns SQL for limited number of returned rows RowLimit(max int) string }
StoreProvider defines a database provider.
type StoreType ¶ added in v1.71.0
type StoreType string
StoreType represents name of database system
const ( // StoreTypeMySQL is MySQL StoreTypeMySQL StoreType = "MySQL" // StoreTypePercona is Percona StoreTypePercona StoreType = "Percona" // StoreTypeMariaDB is MariaDB StoreTypeMariaDB StoreType = "MariaDB" // StoreTypePostgreSQL is PostgreSQL StoreTypePostgreSQL StoreType = "PostgreSQL" // StoreTypeSQLServer is Microsoft SQL Server StoreTypeSQLServer StoreType = "SQLServer" )