common

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Code generated by mockery v1.0.0. DO NOT EDIT.

Index

Constants

View Source
const (
	ContextKeyRequestArrivalTime contextKey = iota
	ContextKeyRequestTID
	ContextKeyTransactionInfoLogger
)

Keys to important context values on incoming requests to TR1D1UM

View Source
const HeaderWPATID = "X-WebPA-Transaction-Id"

HeaderWPATID is the header key for the WebPA transaction UUID

Variables

View Source
var ErrTr1d1umInternal = errors.New("oops! Something unexpected went wrong in this service")

ErrTr1d1umInternal should be the error shown to external API consumers in Internal Server error cases

Functions

func Capture

func Capture(logger kitlog.Logger) kithttp.RequestFunc

Capture (for lack of a better name) captures context values of interest from the incoming request. Unlike Welcome, values captured here are intended to be used only throughout the gokit server flow: (request decoding, business logic, response encoding)

func ErrorLogEncoder

func ErrorLogEncoder(logger kitlog.Logger, ee kithttp.ErrorEncoder) kithttp.ErrorEncoder

ErrorLogEncoder decorates the errorEncoder in such a way that errors are logged with their corresponding unique request identifier

func ForwardHeadersByPrefix

func ForwardHeadersByPrefix(p string, from http.Header, to http.Header)

ForwardHeadersByPrefix copies headers h where the source and target are 'from' and 'to' respectively such that key(h) has p as prefix

func TransactionLogging

func TransactionLogging(logger kitlog.Logger) kithttp.ServerFinalizerFunc

TransactionLogging is used by the different Tr1d1um services to keep track of incoming requests and their corresponding responses

func Welcome

func Welcome(delegate http.Handler) http.Handler

Welcome is an Alice-style constructor that defines necessary request context values assumed to exist by the delegate. These values should be those expected to be used both in and outside the gokit server flow

Types

type CodedError

type CodedError interface {
	error
	StatusCode() int
}

CodedError describes the behavior of an error that additionally has an HTTP status code used for TR1D1UM business logic

func NewBadRequestError

func NewBadRequestError(e error) CodedError

NewBadRequestError is the constructor for an error returned for bad HTTP requests to tr1d1um

func NewCodedError

func NewCodedError(e error, code int) CodedError

NewCodedError upgrades an Error to a CodedError e must not be non-nil to avoid panics

type MockTr1d1umTransactor

type MockTr1d1umTransactor struct {
	mock.Mock
}

MockTr1d1umTransactor is an autogenerated mock type for the Tr1d1umTransactor type

func (*MockTr1d1umTransactor) Transact

func (_m *MockTr1d1umTransactor) Transact(_a0 *http.Request) (*XmidtResponse, error)

Transact provides a mock function with given fields: _a0

type Tr1d1umTransactor

type Tr1d1umTransactor interface {
	Transact(*http.Request) (*XmidtResponse, error)
}

Tr1d1umTransactor performs a typical HTTP request but enforces some logic onto the HTTP transaction such as context-based timeout and header filtering this is a common utility for the stat and config tr1d1um services

type Tr1d1umTransactorOptions

type Tr1d1umTransactorOptions struct {
	//RequestTimeout is the deadline duration for the HTTP transaction to be completed
	RequestTimeout time.Duration

	//Do is the core responsible to perform the actual HTTP request
	Do func(*http.Request) (*http.Response, error)
}

Tr1d1umTransactorOptions include parameters needed to configure the transactor

type XmidtResponse

type XmidtResponse struct {

	//Code is the HTTP Status code received from the transaction
	Code int

	//ForwardedHeaders contains all the headers tr1d1um keeps from the transaction
	ForwardedHeaders http.Header

	//Body represents the full data off the XMiDT http.Response body
	Body []byte
}

XmidtResponse represents the data that a tr1d1um transactor keeps from an HTTP request to the XMiDT API

Jump to

Keyboard shortcuts

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