config

package
v0.0.0-...-56e218b Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2018 License: MIT Imports: 11 Imported by: 6

Documentation

Overview

config helper for cache, mq, and worker

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This file is a wholesale copy of https://github.com/mitchellh/go-homedir@1f6da4a72e57d4e7edd4a7295a585e0a3999a2d4 with Dir() renamed to homeDir() and Expand() deleted.

Index

Constants

This section is empty.

Variables

View Source
var (
	Presets = map[string]Settings{
		"worker": Settings{
			Scheme:     "https",
			Port:       443,
			ApiVersion: "2",
			Host:       "worker-aws-us-east-1.iron.io",
			UserAgent:  "iron_go/worker 2.0 (Go " + goVersion + ")",
		},
		"mq": Settings{
			Scheme:     "https",
			Port:       443,
			ApiVersion: "1",
			Host:       "mq-aws-us-east-1.iron.io",
			UserAgent:  "iron_go/mq 1.0 (Go " + goVersion + ")",
		},
		"cache": Settings{
			Scheme:     "https",
			Port:       443,
			ApiVersion: "1",
			Host:       "cache-aws-us-east-1.iron.io",
			UserAgent:  "iron_go/cache 1.0 (Go " + goVersion + ")",
		},
	}
)

Functions

This section is empty.

Types

type Settings

type Settings struct {
	Token      string `json:"token,omitempty"`
	ProjectId  string `json:"project_id,omitempty"`
	Host       string `json:"host,omitempty"`
	Scheme     string `json:"scheme,omitempty"`
	Port       uint16 `json:"port,omitempty"`
	ApiVersion string `json:"api_version,omitempty"`
	UserAgent  string `json:"user_agent,omitempty"`
}

Contains the configuration for an iron.io service. An empty instance is not usable

func Config

func Config(fullProduct string) (settings Settings)

Config gathers configuration from env variables and json config files. Examples of fullProduct are "iron_worker", "iron_cache", "iron_mq".

func ConfigWithEnv

func ConfigWithEnv(fullProduct, env string) (settings Settings)

Like Config, but useful for keeping multiple dev environment information in one iron.json config file. If env="", works same as Config.

e.g.

{
    "production": {
        "token": ...,
        "project_id": ...
    },
    "test": {
        ...
    }
}

func ManualConfig

func ManualConfig(fullProduct string, configuration *Settings) (settings Settings)

ManualConfig gathers configuration from env variables, json config files and finally overwrites it with specified instance of Settings.

func (*Settings) UseConfigFile

func (s *Settings) UseConfigFile(family, product, path, env string)

Load and merge the given JSON config file.

func (*Settings) UseConfigMap

func (s *Settings) UseConfigMap(data map[string]interface{})

Merge the given data into the settings.

func (*Settings) UseSettings

func (s *Settings) UseSettings(settings *Settings)

Merge the given instance into the settings.

Jump to

Keyboard shortcuts

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