confkeys

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 0 Imported by: 3

Documentation

Overview

Package confkeys defines all the configuration key alias that configure all the bundled features of bricks. Bricks expects that a `config.yaml` or similar will be loaded as Configuration and exposed via `interfaces/cfg/Config` interface. Bricks will access embedded keys using a `.` (dot) notation.

Example:

Config.Get("bricks.name").String()

*******************************************************************************

Everything related to bricks itself must be under the ROOT key == "bricks"

*******************************************************************************

Expected configuration structure is a map, below is a complete example in the YAML format:

# Root key of everything related to bricks configuration
bricks:
	# Application/Project name
	# Type: string
	name: "Application Name"
	# Web server related configuration
	server:
		# Host is the host on which the webserver will serve APIs
		# Type: string
		host: localhost
		grpc:
			# gRPC API External port
			# Type: int
			port: 5380
		rest:
			# RESTful API External port
			# Type: int
			external:
				port: 5381
			# RESTful API Internal port
			# Type: int
			internal:
				port: 5382
	# Default Logger related configuration
	logger:
		# Set the default log level for bricks logger
		# Possible values:
		#		trace, debug, info, warn, error
		# Type: string
		level: debug
		static:
			# enables/disables adding a git commit SHA in every log entry
			# Type: bool
			git: true
			# enables/disables adding a hostname in every log entry
			# Type: bool
			host: false
			# enables/disables adding an application/project name in every log entry
			# Type: bool
			name: false

		# Log service start and stop events, custom by log level
		# Possible values:
		#		trace, debug, info, warn, error
		# Type: string
		startStop: info
	# Metrics/Monitoring related configuration
	monitor:
		# sets the namespace/prefix of every metric. Depends on the Metrics implementation
		# Type: string
		prefix: "awesome"
		# allows to include static labels/tags to every published metric
		# Type: map[string]string
		tags:
			tag1: value1
			tag2: value2
			tag3: value3
	# Bundled handlers configuration
	handlers:
		config:
			# defines a list of keywords that once contained within the configuration key will obfuscate the value
			# Type: []string
			obfuscate:
				- "pass"
				- "auth"
				- "secret"
				- "login"
				- "user"
	# Interceptors/Extractors configuration
	middleware:
		# set the default log level of all the bundled middleware that writes to log
		# Possible values:
		# 	trace, debug, info, warn, error
		# Type: string
		logLevel: "trace"
		# this allows to log using a different log level when RPC returned an error
		# Possible values:
		# 	trace, debug, info, warn, error
		# Type: string
		onErrorLogLevel: "warn"
		# add Incoming gRPC request to every log entry
		# Type: bool
		logRequest: true
		# add gRPC response to every log entry
		# Type: bool
		logResponse: true
		# list of headers to be extracted from Incoming gRPC and added to every log entry
		# Type: []string
		logHeaders:
			- "x-forwarded-for"
			- "special-header"
		trace:
			http:
				client:
					# include HTTP client request to trace info ?
					# Type: bool
					request: true
					# include HTTP client response to trace info ?
					# Type: bool
					response: true
			grpc:
				client:
					# include gRPC client request to trace info ?
					# Type: bool
					request: true
					# include gRPC client response to trace info ?
					# Type: bool
					response: true
				server:
					# include incoming gRPC request to trace info ?
					# Type: bool
					request: true
					# include a gRPC response of incoming request to trace info ?
					response: true
		map:
			# List of HTTP header prefixes to map from HTTP headers to gRPC context (Incoming Metadata).
			# Useful when you have some form of correlation IDs that is passed using HTTP headers and you can access via gRPC Incomming Metadata.
			#	['requestID', 'X-Company-']
			#
			# Type: []string
			httpHeaders:
				- "X-Special-"
		copy:
			# list of header prefixes to copy/forward from Incoming gRPC context to outgoing Request context/headers
			# Type: []string
			headers:
				- "authorization"

Index

Constants

View Source
const (

	// GRPCTlsConfig Webserver -> gRPC -> tlsConfig related configuration
	GRPCTlsConfig = gRPC + ".tlsConfig"

	// Host is the host on which the webserver will serve APIs
	//
	// Type: string
	Host = server + ".host"

	// ExternalGRPCPort is the Port on which the webserver will serve gRPC API
	//
	// Type: int
	ExternalGRPCPort string = gRPC + ".port"

	// EnableGRPCTls if true grpc use tls mutual authentication connection
	//
	// Type: bool
	EnableGRPCTls string = GRPCTlsConfig + ".enableTLS"

	// GRPCTlsCACertFile is CA certificate file path
	//
	// Type: string
	GRPCTlsCACertFile string = GRPCTlsConfig + ".caCertFile"

	// GRPCTlsServerKeyFile is server key file path
	//
	// Type: string
	GRPCTlsServerKeyFile string = GRPCTlsConfig + ".serverKeyFile"

	// GRPCTlsServerCertFile is server certificate file path
	//
	// Type: string
	GRPCTlsServerCertFile string = GRPCTlsConfig + ".serverCertFile"

	// GRPCTlsClientKeyFile is client key file path
	//
	// Type: string
	GRPCTlsClientKeyFile string = GRPCTlsConfig + ".clientKeyFile"

	// GRPCTlsClientCertFile is client certificate file path
	//
	// Type: string
	GRPCTlsClientCertFile string = GRPCTlsConfig + ".clientCertFile"

	// ExternalRESTPort is the Port on which the webserver will serve it's external/public RESTful API
	//
	// Type: int
	ExternalRESTPort string = rest + ".external.port"

	// InternalRESTPort is the Port on which the webserver will serve it's internal/private RESTful API
	//
	// Type: int
	InternalRESTPort string = rest + ".internal.port"
)

Webserver related keys

View Source
const (
	// LogLevel set the default log level for bricks logger
	// Possible values:
	//		trace, debug, info, warn, error
	//
	// Type: string
	LogLevel string = logger + ".level"

	// Log service start and stop events, custom by log level
	// Possible values:
	//		trace, debug, info, warn, error
	// Type: string
	LogStartStop string = logger + ".startStop"
	// LogIncludeGitSHA enables/disables adding a git commit SHA in every log entry
	//
	// Type: bool
	LogIncludeGitSHA string = logger + ".static.git"

	// LogIncludeHost enables/disables adding a hostname in every log entry
	//
	// Type: bool
	LogIncludeHost string = logger + ".static.host"

	// LogIncludeName enables/disables adding an application/project name in every log entry
	//
	// Type: bool
	LogIncludeName string = logger + ".static.name"
)

Logger related keys

View Source
const (
	// MonitorPrefix sets the namespace/prefix of every metric. Depends on the Metrics implementation
	//
	// Type: string
	MonitorPrefix string = monitor + ".prefix"

	// MonitorTags allows to include static labels/tags to every published metric
	//
	// Example:
	//		tags:
	//			tag1: value1
	//			tag2: value2
	//			tag3: value3
	//
	// Type: map[string]string
	MonitorTags string = monitor + ".tags"
)

Monitoring related keys

View Source
const (
	// MiddlewareLogLevel set the default log level of all the bundled middleware that writes to log
	// Possible values:
	//		trace, debug, info, warn, error
	//
	// Type: string
	MiddlewareLogLevel = middleware + ".logLevel"

	// MiddlewareOnErrorLogLevel this allows to log using a different log level when RPC returned an error
	// Possible values:
	//		trace, debug, info, warn, error
	//
	// Type: string
	MiddlewareOnErrorLogLevel = middleware + ".onErrorLogLevel"

	// MiddlewareLogIncludeRequest add incoming gRPC request to log
	//
	// Type: bool
	MiddlewareLogIncludeRequest = middleware + ".logRequest"

	// MiddlewareLogIncludeResponse add gRPC response of incoming request to log
	//
	// Type: bool
	MiddlewareLogIncludeResponse = middleware + ".logResponse"

	// HTTPClientTraceIncludeRequest add HTTP client request to trace info ?
	//
	// Type: bool
	HTTPClientTraceIncludeRequest = traceHTTP + ".client.request"

	// HTTPClientTraceIncludeResponse add HTTP client response to trace info ?
	//
	// Type: bool
	HTTPClientTraceIncludeResponse = traceHTTP + ".client.response"

	// GRPCClientTraceIncludeRequest add gRPC client request to trace info
	//
	// Type: bool
	GRPCClientTraceIncludeRequest = traceGRPC + ".client.request"

	// GRPCClientTraceIncludeResponse add gRPC client response to trace info
	//
	// Type: bool
	GRPCClientTraceIncludeResponse = traceGRPC + ".client.response"

	// GRPCServerTraceIncludeRequest add incoming gRPC request to trace info
	//
	// Type: bool
	GRPCServerTraceIncludeRequest = traceGRPC + ".server.request"

	// GRPCServerTraceIncludeResponse add a gRPC response of incoming request to trace info
	//
	// Type: bool
	GRPCServerTraceIncludeResponse = traceGRPC + ".server.response"

	// ForwardIncomingGRPCMetadataHeadersList is a list of header prefixes to copy from Incoming gRPC context to outgoing Request context/headers
	//
	// Type: []string
	ForwardIncomingGRPCMetadataHeadersList = middleware + ".copy.headers"

	// List of HTTP header prefixes to map from HTTP headers to gRPC context (Incoming Metadata).
	// Useful when you have some form of correlation IDs that is passed using HTTP headers and you can access via gRPC Incomming Metadata.
	//	['requestID', 'X-Company-']
	//
	// Type: []string
	MapHTTPRequestHeadersToGRPCMetadata = middleware + ".map.httpHeaders"

	// LoggerIncomingGRPCMetadataHeadersExtractor is a list of headers to be extracted from Incoming gRPC and added to every log entry
	//
	// Type: []string
	LoggerIncomingGRPCMetadataHeadersExtractor = middleware + ".logHeaders"
)

Middleware

View Source
const (
	// ApplicationName is the name of this Application/Project
	//
	// Type: string
	ApplicationName string = bricks + ".name"
)

Root level keys

View Source
const (
	// ConfigHandlerObfuscateKeys defines a list of keywords that once contained within the configuration key will obfuscate the value
	//
	// Type: []string
	ConfigHandlerObfuscateKeys = handlers + ".config.obfuscate"
)

Bundled Handlers

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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