community: github.com/documize/community/core/env Index | Files

package env

import "github.com/documize/community/core/env"

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

Package Files

command_line.go flags.go logger.go parser.go provider.go runtime.go

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"
)

type ConfigToml Uses

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 Uses

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 Uses

func LoadConfig() (f Flags, ok bool)

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 Uses

func (f *Flags) SSLEnabled() bool

SSLEnabled returns true if both cert and key were provided at runtime.

type Logger Uses

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 Uses

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 Uses

func (r *Runtime) Commit(tx *sqlx.Tx) bool

Commit flushes pending changes to database. Any error encountered during this operation is logged to runtime logger.

func (*Runtime) Rollback Uses

func (r *Runtime) Rollback(tx *sqlx.Tx) bool

Rollback aborts active database transaction. Any error encountered during this operation is logged to runtime logger.

func (*Runtime) StartTx Uses

func (r *Runtime) StartTx(i sql.IsolationLevel) (tx *sqlx.Tx, ok bool)

StartTx begins database transaction with given transaction isolation level. Any error encountered during this operation is logged to runtime logger.

type StoreProvider Uses

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 Uses

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"
)

Package env imports 12 packages (graph) and is imported by 52 packages. Updated 2019-10-03. Refresh now. Tools for package owners.