env

package
v1.72.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2018 License: AGPL-3.0 Imports: 8 Imported by: 154

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

Index

Constants

View Source
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"
)
View Source
const (
	// CommunityEdition is AGPL product variant
	CommunityEdition = "Community"

	// EnterpriseEdition is commercial licensed product variant
	EnterpriseEdition = "Enterprise"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Flags

type Flags struct {
	DBConn            string // database connection string
	Salt              string // the salt string used to encode JWT tokens
	DBType            string // (optional) database type
	SSLCertFile       string // (optional) name of SSL certificate PEM file
	SSLKeyFile        string // (optional) name of SSL key PEM file
	HTTPPort          string // (optional) HTTP or HTTPS port
	ForceHTTPPort2SSL string // (optional) HTTP that should be redirected to HTTPS
	SiteMode          string // (optional) if 1 then serve offline web page
}

Flags provides access to environment and command line switches for this program.

func ParseFlags

func ParseFlags() (f Flags)

ParseFlags loads command line and OS environment variables required by the program to function.

func (*Flags) SSLEnabled

func (f *Flags) SSLEnabled() bool

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

type License

type License struct {
	Name    string    `json:"name"`
	Email   string    `json:"email"`
	Edition string    `json:"edition"`
	Package string    `json:"package"`
	Plan    string    `json:"plan"`
	Start   time.Time `json:"start"`
	End     time.Time `json:"end"`
	Seats   int       `json:"seats"`
	Trial   bool      `json:"trial"`
	Valid   bool      `json:"valid"`
}

License holds details of product license.

func (*License) IsEmpty

func (l *License) IsEmpty() bool

IsEmpty determines if we have a license.

func (*License) IsValid added in v1.51.0

func (l *License) IsValid() bool

IsValid returns if license is valid

func (*License) Status

func (l *License) Status() string

Status returns formatted message stating if license is empty/populated and invalid/valid.

type LicenseData

type LicenseData struct {
	Key       string `json:"key"`
	Signature string `json:"signature"`
}

LicenseData holds encrypted data and is unpacked into License.

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 ProdInfo

type ProdInfo struct {
	Edition  string
	Title    string
	Version  string
	Major    string
	Minor    string
	Patch    string
	Revision int
	License  License
}

ProdInfo describes a product

type Runtime

type Runtime struct {
	Flags         Flags
	Db            *sqlx.DB
	StoreProvider StoreProvider
	Log           Logger
	Product       ProdInfo
}

Runtime provides access to database, logger and other server-level scoped objects. Use Context for per-request values.

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

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"

	// StoreTypeMSSQL is Microsoft SQL Server
	StoreTypeMSSQL StoreType = "MSSQL"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL