config

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 13 Imported by: 2

README

Config

Usage

customize Configor at runtime with Environment Variables

export CONFIGOR_FILE_PATH=/config/config.yaml
export CONFIGOR_DEBUG_MODE=true
export CONFIGOR_VERBOSE_MODE=true
export CONFIGOR_USE_PKGER=true
export CONFIGOR_ENV=prod

export CONFIGOR_ENV_PREFIX=APP
export APP_FEATURES_TLS_ENABLED=true

# for example 
MICRO_SERVER_ADDRESS=0.0.0.0:9999 CONFIGOR_ENV_PREFIX=APP APP_FEATURES_TLS_ENABLED=true ./build/greeter-service

Documentation

Overview

config package from micro-strter-kit import myConfig "github.com/xmlking/micro-starter-kit/shared/config" to `main.go` and all test files. then use Helper Methods `config.GetServiceConfig()` anywhere you need to retrieve `Configuration`

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Configor *configor.Configor

	// Version is populated by govvv in compile-time.
	Version = "untouched"
	// BuildDate is populated by govvv.
	BuildDate string
	// GitCommit is populated by govvv.
	GitCommit string
	// GitBranch is populated by govvv.
	GitBranch string
	// GitState is populated by govvv.
	GitState string
	// GitSummary is populated by govvv.
	GitSummary string
)

Functions

func CreateServerCerts added in v0.3.2

func CreateServerCerts() (tlsConfig *tls.Config, err error)

func GetBuildInfo

func GetBuildInfo() string

func GetConfig added in v0.3.2

func GetConfig() configPB.Configuration
Example
package main

import (
	"fmt"

	"github.com/xmlking/micro-starter-kit/shared/config"
)

func main() {
	fmt.Println(config.GetConfig().Email)
	// fmt.Println(config.GetConfig().Services["account"].Deadline)

}
Output:

username:"yourGmailUsername" password:"yourGmailAppPassword" email_server:"smtp.gmail.com" port:587 from:"xmlking-test@gmail.com"
Example (Check_defaults)
package main

import (
	"fmt"

	"github.com/xmlking/micro-starter-kit/shared/config"
)

func main() {
	fmt.Println(config.GetConfig().Services.Account.Endpoint)
	fmt.Println(config.GetConfig().Services.Account.Version)
	fmt.Println(config.GetConfig().Services.Account.Deadline)

}
Output:

mkit.service.account:8080
v0.1.0
8888

func GetListener added in v0.3.3

func GetListener(endpoint string) (lis net.Listener, err error)

func IsProduction

func IsProduction() bool

func IsSecure added in v0.3.4

func IsSecure() bool

func ParseTarget added in v0.3.4

func ParseTarget(target string) (ret resolver.Target)

ParseTarget splits target into a resolver.Target struct containing scheme, authority and endpoint.

If target is not a valid scheme://authority/endpoint, it returns {Endpoint: target}.

Types

This section is empty.

Jump to

Keyboard shortcuts

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