context

package
v0.0.0-...-7638cb1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package context defines a type that carries context specific data such as the logger. Inspired by Google's http://godoc.org/golang.org/x/net/context

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	mock.Mock
}

Mock stands for a mocked context.

func NewMockDefault

func NewMockDefault() *Mock

NewMockDefault returns an instance of Mock with default expectations set.

func NewMockDefaultWithContext

func NewMockDefaultWithContext(context []string) *Mock

NewMockDefaultWithContext returns an instance of Mock with specified context.

func (*Mock) AppConfig

func (m *Mock) AppConfig() appconfig.SsmagentConfig

AppConfig mocks the Config function.

func (*Mock) CurrentContext

func (m *Mock) CurrentContext() []string

With mocks the With function.

func (*Mock) Log

func (m *Mock) Log() log.T

Log mocks the Log function.

func (*Mock) With

func (m *Mock) With(ctx string) T

With mocks the With function.

type T

type T interface {
	Log() log.T
	AppConfig() appconfig.SsmagentConfig
	With(context string) T
	CurrentContext() []string
}

T transfers context specific data across different execution boundaries. Instead of adding the context to specific structs, we pass Context as the first parameter to the methods themselves.

func Default

func Default(logger log.T, appconfig appconfig.SsmagentConfig) T

Default returns an empty context that use the default logger and appconfig.

Jump to

Keyboard shortcuts

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