orlop

package module
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 32 Imported by: 0

README

orlop

Orlop is the base deck in a ship where the cables are stowed.

It is Ketch's standard (opinionated) library that all of our projects include.

  • Configuration
  • Logging (Logrus)
  • Metrics (OpenTracing/Prometheus)
  • Tracing (OpenTracing/Jaeger)

Documentation

Index

Constants

View Source
const EnvironmentKey = "KETCH_ENVIRONMENT"

EnvironmentKey is the environment variable we look for to set the environment

Variables

View Source
var AuthToken struct{}

AuthToken is the context key to retrieve the Authentication token from context

Functions

func FxContext

func FxContext(ctx context.Context) fx.Option

func FxOptions

func FxOptions(c any) fx.Option

func GetVariablesFromConfig

func GetVariablesFromConfig(prefix string, cfg interface{}) ([]string, error)

GetVariablesFromConfig returns the environment variables from the given config object

func LoadEnvironment

func LoadEnvironment(env Environment, files ...string)

LoadEnvironment loads the environment variables from the specified files and from the standard locations

func Populate added in v2.2.0

func Populate(ctx context.Context, prefix string, e env.Environment, module fx.Option, targets ...interface{}) error

func RegisterConfigParser

func RegisterConfigParser(typeName string, parser func(value reflect.Value, input string) error)

RegisterConfigParser registers a config parser

func Run

func Run(prefix string, runner interface{}, cfg interface{})

Run loads config and then executes the given runner

func URLParamFromContext

func URLParamFromContext(ctx context.Context, key string) string

URLParamFromContext returns the url parameter from a context.Context object.

func URLParamFromRequest

func URLParamFromRequest(r *http.Request, key string) string

URLParamFromRequest returns the url parameter from a http.Request object.

func Unmarshal

func Unmarshal(prefix string, cfg interface{}) error

Unmarshal reads configuration into the cfg object

func UnmarshalFromEnv

func UnmarshalFromEnv(prefix string, vars []string, cfg interface{}) error

UnmarshalFromEnv reads configuration into the cfg object from the env vars

Types

type BinaryMarshaler

type BinaryMarshaler struct{}

BinaryMarshaler marshals the given object as a binary object

func (BinaryMarshaler) ContentType

func (BinaryMarshaler) ContentType() string

ContentType returns the Content-Type which this marshaler is responsible for.

func (BinaryMarshaler) Marshal

func (BinaryMarshaler) Marshal(v interface{}) ([]byte, error)

Marshal marshals "v" into byte sequence.

func (BinaryMarshaler) NewDecoder

func (BinaryMarshaler) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a Decoder which reads byte sequence from "r".

func (BinaryMarshaler) NewEncoder

func (BinaryMarshaler) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes bytes sequence into "w".

func (BinaryMarshaler) Unmarshal

func (BinaryMarshaler) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals "data" into "v". "v" must be a pointer value.

type ContextCredentials

type ContextCredentials struct{}

ContextCredentials provides credentials to the client based on the context

func (ContextCredentials) GetRequestMetadata

func (j ContextCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata returns authorization metadata

func (ContextCredentials) RequireTransportSecurity

func (j ContextCredentials) RequireTransportSecurity() bool

RequireTransportSecurity denotes we require transport security

type Enabled

type Enabled struct {
	Enabled bool
}

Enabled provides an Enabled flag

func (Enabled) GetEnabled

func (c Enabled) GetEnabled() bool

GetEnabled returns true if enabled

type Environment

type Environment string

Environment is a defined environment

func Env

func Env() Environment

Env returns the environment from the environment variables

func (Environment) IsLocal

func (e Environment) IsLocal() bool

IsLocal returns true if the environment is not defined (aka local)

func (Environment) IsProduction

func (e Environment) IsProduction() bool

IsProduction returns true if the environment is the production environment.

func (Environment) IsTest

func (e Environment) IsTest() bool

IsTest returns true if the environment is the test environment

func (Environment) String

func (e Environment) String() string

String returns a string version of the environment.

type File

type File struct {
	File string
}

File provides a filename

func (File) GetFile

func (f File) GetFile() string

GetFile returns the filename

type HasEnabled

type HasEnabled interface {
	GetEnabled() bool
}

HasEnabled denotes an object provides an Enabled flag

type HasFile

type HasFile interface {
	GetFile() string
}

HasFile denotes an object provides a filename

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner represents a command runner

func NewRunner

func NewRunner(prefix string) *Runner

NewRunner creates a new Runner

func (*Runner) Getenv

func (r *Runner) Getenv(key string) string

Getenv returns the value of the environment variabled named `key`

func (*Runner) Setup

func (r *Runner) Setup(cmd *cobra.Command, runner interface{}, cfg interface{}) *Runner

Setup sets up the Command

func (*Runner) SetupLogging

func (r *Runner) SetupLogging(env Environment, loglevel string)

SetupLogging sets up logging for the environment and the default log level

func (*Runner) SetupRoot

func (r *Runner) SetupRoot(cmd *cobra.Command) *Runner

SetupRoot sets up the root Command

Directories

Path Synopsis
Package errors provides utilities to augment errors Architecture of a good error: * system information - err Error() - displayed in logs * user message - displayed to end user * status code - returned to other systems * error code - standard error code usable within an application
Package errors provides utilities to augment errors Architecture of a good error: * system information - err Error() - displayed in logs * user message - displayed to end user * status code - returned to other systems * error code - standard error code usable within an application
Code generated by winch.
Code generated by winch.

Jump to

Keyboard shortcuts

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