config

package
v0.8.4-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2017, Square, Inc.

Package config provides the ability to load config files into predefined structures that are used by SpinCycle. Specifically, the Request Manager uses the RequestManager struct in request-manager/bin/main.go, and the Job Runner uses the JobRunner struct in job-runner/bin/main.go. These structs provide all of the config information needed to run these two services.

Types of config structs provided by this package:

* RequestManager: all of the config needed to run the RM

* JobRunner: all of the config needed to run the JR

  • Server: the configuration for running a webserver (ex: the listen address the server should run on, the TLS config the server should run with, etc.)
  • SQLDb: the configuration for connecting to a SQL database (ex: the type of the database, the DSN of the database server, the TLS config to use when connecting to the server, etc.)
  • HTTPClient: the configuration to use for an HTTP client that will make HTTP requests to external services (ex: the URL of the external service the client should talk to, the TLS config the client should use when connecting to the remote service, etc.)
  • RedisDb: the configuration for connecting to a Redis database (ex: the address of the redis server, etc.)
  • TLS: the configuration for constructing a Go tls.Config (ex: the CA cert file to use, the key file to use, etc.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(configFile string, configStruct interface{}) error

Load loads a configuration file into the struct pointed to by the configStruct argument.

Types

type Auth

type Auth struct {
	// Callers with one of these roles are admins (allowed all ops) for all requests.
	AdminRoles []string `yaml:"admin_roles"`

	// Strict requires all requests to have ACLs, else callers are denied unless
	// they have an admin role. Strict is disabled by default which, with the default
	// auth plugin, allows all callers (no auth).
	Strict bool `yaml:"strict"`
}

Auth configuration.

type HTTPClient

type HTTPClient struct {
	// The base URL of the service that this client communicates with
	// (ex: https://127.0.0.1:9340). If running multiple instances of the
	// service (Job Runner or Request Manager), this URL should point to a
	// load balancer.
	ServerURL string `yaml:"server_url"`

	// The TLS config used by the client.
	TLS `yaml:"tls_config"`
}

Configuration for an HTTP client.

type JobRunner

type JobRunner struct {
	// The config that the JR web server will run with.
	Server

	// The config that the JR will use to make a RM client with. The RM
	// client is used for communicating with the RM.
	RMClient HTTPClient `yaml:"rm_client"`

	// The type of backend to use for the chain repo. Choices are: memory,
	// redis. If this is set to redis, the config for the redis instance
	// will be retrieved from the RedisDb struct.
	ChainRepoType string `yaml:"chain_repo_type"`

	// The config that the JR will use to connect to redis (if
	// ChainRepoType is set to "redis").
	Redis RedisDb
}

The config used by the Job Runner. This is read from in job-runner/bin/main.go

type RedisDb

type RedisDb struct {
	// The network for the redis server (ex: "tcp", "unix")
	Network string

	// The address for the redis server (ex: "localhost:6379", "/path/to/redis.sock")
	Address string

	// The prefix used for redis keys.
	Prefix string

	// The timeout lenght (in seconds) for connections.
	IdleTimeout int `yaml:"idle_timeout"`

	// The maximum number of idle connections in the redis pool.
	MaxIdle int `yaml:"max_idle"`
}

Configuration for a Redis database.

type RequestManager

type RequestManager struct {
	// The config that the RM web server will run with.
	Server

	// The config that the RM will use to connect to its database.
	Db SQLDb `yaml:"db"`

	// The config that the RM will use to make a JR client with. The JR
	// client is used for communicating with the JR.
	JRClient HTTPClient `yaml:"jr_client"`

	// The directory that holds all of the grapher spec files. This dir
	// should not contain anything other than spec files.
	SpecFileDir string `yaml:"spec_file_dir"`

	// Auth specifies auth plugin options. If a user-provide auth plugin is not
	// given, these options are ignored and all users and apps have admin access.
	Auth Auth `yaml:"auth"`
}

The config used by the Request Manager. this is read from in request-manager/bin/main.go

type SQLDb

type SQLDb struct {
	// The driverName that is passed to sql.Open() (ex: "mysql").
	Type string

	// The full Data Source Name (DSN) of the sql database (see
	// https://github.com/go-sql-driver/mysql#dsn-data-source-name for
	// MySQL documentation, or https://godoc.org/github.com/lib/pq for
	// PostgreSQL documentation).
	//
	// Note: if a TLS config is specified within the SQLDb struct, it
	// will automatically get appended to the DSN (you don't have to
	// include it in the string). Also, "parseTime=true" will always be
	// appended to the DSN, so you don't need to add that either.
	DSN string

	// The TLS config used to connect to the sql database..
	TLS `yaml:"tls_config"`

	// The path to the database's CLI tool. This is only used for
	// testing. Ex: /usr/bin/mysql
	CLIPath string `yaml:"cli_path"`
}

Configuration for a SQL database.

type Server

type Server struct {
	// The address the server will listen on (ex: "127.0.0.1:80").
	ListenAddress string `yaml:"listen_address"`

	// The TLS config used by the server.
	TLS `yaml:"tls_config"`
}

Configuration for a web server.

type TLS

type TLS struct {
	// The certificate file to use.
	CertFile string `yaml:"cert_file"`

	// The key file to use.
	KeyFile string `yaml:"key_file"`

	// The CA file to use.
	CAFile string `yaml:"ca_file"`
}

TLS configuration.

Jump to

Keyboard shortcuts

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