auxiliary

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AuxiliaryStats = new(expvar.Map)
)

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	// Authorize returns `true` if the principal in the context
	// object is allowed to peform the given request.  If the
	// principal is not allowed `false` must be returned, not an
	// error.  If there is a problem completing authorization an
	// error should be returned.
	Authorize(context.Context, *httpx.Request) (bool, merry.Error)
}

Authorizer defines a provider for authorizing principals to make requests.

type AuthorizerAuthorizeInvocation

type AuthorizerAuthorizeInvocation struct {
	Parameters struct {
		Ident1 context.Context
		Ident2 *httpx.Request
	}
	Results struct {
		Ident3 bool
		Ident4 merry.Error
	}
}

AuthorizerAuthorizeInvocation represents a single call of FakeAuthorizer.Authorize

func NewAuthorizerAuthorizeInvocation added in v0.3.1

func NewAuthorizerAuthorizeInvocation(ident1 context.Context, ident2 *httpx.Request, ident3 bool, ident4 merry.Error) *AuthorizerAuthorizeInvocation

NewAuthorizerAuthorizeInvocation creates a new instance of AuthorizerAuthorizeInvocation

type AuthorizerTestingT

type AuthorizerTestingT interface {
	Error(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Helper()
}

AuthorizerTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.

type DebugServer

type DebugServer struct {
	HTTPServer
	Path string // URL path to listen on, "/debug/vars" if empty
}

DebugServer serves values from the `expvar` package to the configured address and path.

func (*DebugServer) Name

func (s *DebugServer) Name() string

func (*DebugServer) Route

func (s *DebugServer) Route(ctx context.Context, request *httpx.Request) httpx.Handler

func (*DebugServer) Serve

func (s *DebugServer) Serve() error

func (*DebugServer) Service

func (s *DebugServer) Service(ctx context.Context, request *httpx.Request) httpx.Response

type FakeAuthorizer

type FakeAuthorizer struct {
	AuthorizeHook func(context.Context, *httpx.Request) (bool, merry.Error)

	AuthorizeCalls []*AuthorizerAuthorizeInvocation
}

FakeAuthorizer is a mock implementation of Authorizer for testing. Use it in your tests as in this example:

package example

func TestWithAuthorizer(t *testing.T) {
	f := &auxiliary.FakeAuthorizer{
		AuthorizeHook: func(ident1 context.Context, ident2 *httpx.Request) (ident3 bool, ident4 merry.Error) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeAuthorize ...
	f.AssertAuthorizeCalledOnce(t)
}

Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeAuthorize.

func NewFakeAuthorizerDefaultError

func NewFakeAuthorizerDefaultError(t AuthorizerTestingT) *FakeAuthorizer

NewFakeAuthorizerDefaultError returns an instance of FakeAuthorizer with all hooks configured to call t.Error

func NewFakeAuthorizerDefaultFatal

func NewFakeAuthorizerDefaultFatal(t AuthorizerTestingT) *FakeAuthorizer

NewFakeAuthorizerDefaultFatal returns an instance of FakeAuthorizer with all hooks configured to call t.Fatal

func NewFakeAuthorizerDefaultPanic

func NewFakeAuthorizerDefaultPanic() *FakeAuthorizer

NewFakeAuthorizerDefaultPanic returns an instance of FakeAuthorizer with all hooks configured to panic

func (*FakeAuthorizer) AssertAuthorizeCalled

func (f *FakeAuthorizer) AssertAuthorizeCalled(t AuthorizerTestingT)

AssertAuthorizeCalled calls t.Error if FakeAuthorizer.Authorize was not called

func (*FakeAuthorizer) AssertAuthorizeCalledN

func (f *FakeAuthorizer) AssertAuthorizeCalledN(t AuthorizerTestingT, n int)

AssertAuthorizeCalledN calls t.Error if FakeAuthorizer.Authorize was called less than n times

func (*FakeAuthorizer) AssertAuthorizeCalledOnce

func (f *FakeAuthorizer) AssertAuthorizeCalledOnce(t AuthorizerTestingT)

AssertAuthorizeCalledOnce calls t.Error if FakeAuthorizer.Authorize was not called exactly once

func (*FakeAuthorizer) AssertAuthorizeCalledOnceWith

func (_f9 *FakeAuthorizer) AssertAuthorizeCalledOnceWith(t AuthorizerTestingT, ident1 context.Context, ident2 *httpx.Request)

AssertAuthorizeCalledOnceWith calls t.Error if FakeAuthorizer.Authorize was not called exactly once with the given values

func (*FakeAuthorizer) AssertAuthorizeCalledWith

func (_f7 *FakeAuthorizer) AssertAuthorizeCalledWith(t AuthorizerTestingT, ident1 context.Context, ident2 *httpx.Request)

AssertAuthorizeCalledWith calls t.Error if FakeAuthorizer.Authorize was not called with the given values

func (*FakeAuthorizer) AssertAuthorizeNotCalled

func (f *FakeAuthorizer) AssertAuthorizeNotCalled(t AuthorizerTestingT)

AssertAuthorizeNotCalled calls t.Error if FakeAuthorizer.Authorize was called

func (*FakeAuthorizer) Authorize

func (_f1 *FakeAuthorizer) Authorize(ident1 context.Context, ident2 *httpx.Request) (ident3 bool, ident4 merry.Error)

func (*FakeAuthorizer) AuthorizeCalled

func (f *FakeAuthorizer) AuthorizeCalled() bool

AuthorizeCalled returns true if FakeAuthorizer.Authorize was called

func (*FakeAuthorizer) AuthorizeCalledN

func (f *FakeAuthorizer) AuthorizeCalledN(n int) bool

AuthorizeCalledN returns true if FakeAuthorizer.Authorize was called at least n times

func (*FakeAuthorizer) AuthorizeCalledOnce

func (f *FakeAuthorizer) AuthorizeCalledOnce() bool

AuthorizeCalledOnce returns true if FakeAuthorizer.Authorize was called exactly once

func (*FakeAuthorizer) AuthorizeCalledOnceWith

func (_f8 *FakeAuthorizer) AuthorizeCalledOnceWith(ident1 context.Context, ident2 *httpx.Request) bool

AuthorizeCalledOnceWith returns true if FakeAuthorizer.Authorize was called exactly once with the given values

func (*FakeAuthorizer) AuthorizeCalledWith

func (_f6 *FakeAuthorizer) AuthorizeCalledWith(ident1 context.Context, ident2 *httpx.Request) (found bool)

AuthorizeCalledWith returns true if FakeAuthorizer.Authorize was called with the given values

func (*FakeAuthorizer) AuthorizeNotCalled

func (f *FakeAuthorizer) AuthorizeNotCalled() bool

AuthorizeNotCalled returns true if FakeAuthorizer.Authorize was not called

func (*FakeAuthorizer) AuthorizeResultsForCall

func (_f10 *FakeAuthorizer) AuthorizeResultsForCall(ident1 context.Context, ident2 *httpx.Request) (ident3 bool, ident4 merry.Error, found bool)

AuthorizeResultsForCall returns the result values for the first call to FakeAuthorizer.Authorize with the given values

func (*FakeAuthorizer) Reset

func (f *FakeAuthorizer) Reset()

func (*FakeAuthorizer) SetAuthorizeInvocation added in v0.3.1

func (_f3 *FakeAuthorizer) SetAuthorizeInvocation(calls_f4 []*AuthorizerAuthorizeInvocation, fallback_f5 func() (bool, merry.Error))

SetAuthorizeInvocation configures Authorizer.Authorize to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeAuthorizer) SetAuthorizeStub added in v0.3.1

func (_f2 *FakeAuthorizer) SetAuthorizeStub(ident3 bool, ident4 merry.Error)

SetAuthorizeStub configures Authorizer.Authorize to always return the given values

type FakeServer

type FakeServer struct {
	NameHook     func() string
	AddressHook  func() string
	ListenHook   func() error
	ServeHook    func() error
	ShutdownHook func(time.Duration) error

	NameCalls     []*ServerNameInvocation
	AddressCalls  []*ServerAddressInvocation
	ListenCalls   []*ServerListenInvocation
	ServeCalls    []*ServerServeInvocation
	ShutdownCalls []*ServerShutdownInvocation
}

FakeServer is a mock implementation of Server for testing. Use it in your tests as in this example:

package example

func TestWithServer(t *testing.T) {
	f := &auxiliary.FakeServer{
		NameHook: func() (ident1 string) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeName ...
	f.AssertNameCalledOnce(t)
}

Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeName.

func NewFakeServerDefaultError

func NewFakeServerDefaultError(t ServerTestingT) *FakeServer

NewFakeServerDefaultError returns an instance of FakeServer with all hooks configured to call t.Error

func NewFakeServerDefaultFatal

func NewFakeServerDefaultFatal(t ServerTestingT) *FakeServer

NewFakeServerDefaultFatal returns an instance of FakeServer with all hooks configured to call t.Fatal

func NewFakeServerDefaultPanic

func NewFakeServerDefaultPanic() *FakeServer

NewFakeServerDefaultPanic returns an instance of FakeServer with all hooks configured to panic

func (*FakeServer) Address

func (_f3 *FakeServer) Address() (ident1 string)

func (*FakeServer) AddressCalled

func (f *FakeServer) AddressCalled() bool

AddressCalled returns true if FakeServer.Address was called

func (*FakeServer) AddressCalledN

func (f *FakeServer) AddressCalledN(n int) bool

AddressCalledN returns true if FakeServer.Address was called at least n times

func (*FakeServer) AddressCalledOnce

func (f *FakeServer) AddressCalledOnce() bool

AddressCalledOnce returns true if FakeServer.Address was called exactly once

func (*FakeServer) AddressNotCalled

func (f *FakeServer) AddressNotCalled() bool

AddressNotCalled returns true if FakeServer.Address was not called

func (*FakeServer) AssertAddressCalled

func (f *FakeServer) AssertAddressCalled(t ServerTestingT)

AssertAddressCalled calls t.Error if FakeServer.Address was not called

func (*FakeServer) AssertAddressCalledN

func (f *FakeServer) AssertAddressCalledN(t ServerTestingT, n int)

AssertAddressCalledN calls t.Error if FakeServer.Address was called less than n times

func (*FakeServer) AssertAddressCalledOnce

func (f *FakeServer) AssertAddressCalledOnce(t ServerTestingT)

AssertAddressCalledOnce calls t.Error if FakeServer.Address was not called exactly once

func (*FakeServer) AssertAddressNotCalled

func (f *FakeServer) AssertAddressNotCalled(t ServerTestingT)

AssertAddressNotCalled calls t.Error if FakeServer.Address was called

func (*FakeServer) AssertListenCalled

func (f *FakeServer) AssertListenCalled(t ServerTestingT)

AssertListenCalled calls t.Error if FakeServer.Listen was not called

func (*FakeServer) AssertListenCalledN

func (f *FakeServer) AssertListenCalledN(t ServerTestingT, n int)

AssertListenCalledN calls t.Error if FakeServer.Listen was called less than n times

func (*FakeServer) AssertListenCalledOnce

func (f *FakeServer) AssertListenCalledOnce(t ServerTestingT)

AssertListenCalledOnce calls t.Error if FakeServer.Listen was not called exactly once

func (*FakeServer) AssertListenNotCalled

func (f *FakeServer) AssertListenNotCalled(t ServerTestingT)

AssertListenNotCalled calls t.Error if FakeServer.Listen was called

func (*FakeServer) AssertNameCalled

func (f *FakeServer) AssertNameCalled(t ServerTestingT)

AssertNameCalled calls t.Error if FakeServer.Name was not called

func (*FakeServer) AssertNameCalledN

func (f *FakeServer) AssertNameCalledN(t ServerTestingT, n int)

AssertNameCalledN calls t.Error if FakeServer.Name was called less than n times

func (*FakeServer) AssertNameCalledOnce

func (f *FakeServer) AssertNameCalledOnce(t ServerTestingT)

AssertNameCalledOnce calls t.Error if FakeServer.Name was not called exactly once

func (*FakeServer) AssertNameNotCalled

func (f *FakeServer) AssertNameNotCalled(t ServerTestingT)

AssertNameNotCalled calls t.Error if FakeServer.Name was called

func (*FakeServer) AssertServeCalled

func (f *FakeServer) AssertServeCalled(t ServerTestingT)

AssertServeCalled calls t.Error if FakeServer.Serve was not called

func (*FakeServer) AssertServeCalledN

func (f *FakeServer) AssertServeCalledN(t ServerTestingT, n int)

AssertServeCalledN calls t.Error if FakeServer.Serve was called less than n times

func (*FakeServer) AssertServeCalledOnce

func (f *FakeServer) AssertServeCalledOnce(t ServerTestingT)

AssertServeCalledOnce calls t.Error if FakeServer.Serve was not called exactly once

func (*FakeServer) AssertServeNotCalled

func (f *FakeServer) AssertServeNotCalled(t ServerTestingT)

AssertServeNotCalled calls t.Error if FakeServer.Serve was called

func (*FakeServer) AssertShutdownCalled

func (f *FakeServer) AssertShutdownCalled(t ServerTestingT)

AssertShutdownCalled calls t.Error if FakeServer.Shutdown was not called

func (*FakeServer) AssertShutdownCalledN

func (f *FakeServer) AssertShutdownCalledN(t ServerTestingT, n int)

AssertShutdownCalledN calls t.Error if FakeServer.Shutdown was called less than n times

func (*FakeServer) AssertShutdownCalledOnce

func (f *FakeServer) AssertShutdownCalledOnce(t ServerTestingT)

AssertShutdownCalledOnce calls t.Error if FakeServer.Shutdown was not called exactly once

func (*FakeServer) AssertShutdownCalledOnceWith

func (_f17 *FakeServer) AssertShutdownCalledOnceWith(t ServerTestingT, ident1 time.Duration)

AssertShutdownCalledOnceWith calls t.Error if FakeServer.Shutdown was not called exactly once with the given values

func (*FakeServer) AssertShutdownCalledWith

func (_f15 *FakeServer) AssertShutdownCalledWith(t ServerTestingT, ident1 time.Duration)

AssertShutdownCalledWith calls t.Error if FakeServer.Shutdown was not called with the given values

func (*FakeServer) AssertShutdownNotCalled

func (f *FakeServer) AssertShutdownNotCalled(t ServerTestingT)

AssertShutdownNotCalled calls t.Error if FakeServer.Shutdown was called

func (*FakeServer) Listen

func (_f5 *FakeServer) Listen() (ident1 error)

func (*FakeServer) ListenCalled

func (f *FakeServer) ListenCalled() bool

ListenCalled returns true if FakeServer.Listen was called

func (*FakeServer) ListenCalledN

func (f *FakeServer) ListenCalledN(n int) bool

ListenCalledN returns true if FakeServer.Listen was called at least n times

func (*FakeServer) ListenCalledOnce

func (f *FakeServer) ListenCalledOnce() bool

ListenCalledOnce returns true if FakeServer.Listen was called exactly once

func (*FakeServer) ListenNotCalled

func (f *FakeServer) ListenNotCalled() bool

ListenNotCalled returns true if FakeServer.Listen was not called

func (*FakeServer) Name

func (_f1 *FakeServer) Name() (ident1 string)

func (*FakeServer) NameCalled

func (f *FakeServer) NameCalled() bool

NameCalled returns true if FakeServer.Name was called

func (*FakeServer) NameCalledN

func (f *FakeServer) NameCalledN(n int) bool

NameCalledN returns true if FakeServer.Name was called at least n times

func (*FakeServer) NameCalledOnce

func (f *FakeServer) NameCalledOnce() bool

NameCalledOnce returns true if FakeServer.Name was called exactly once

func (*FakeServer) NameNotCalled

func (f *FakeServer) NameNotCalled() bool

NameNotCalled returns true if FakeServer.Name was not called

func (*FakeServer) Reset

func (f *FakeServer) Reset()

func (*FakeServer) Serve

func (_f7 *FakeServer) Serve() (ident1 error)

func (*FakeServer) ServeCalled

func (f *FakeServer) ServeCalled() bool

ServeCalled returns true if FakeServer.Serve was called

func (*FakeServer) ServeCalledN

func (f *FakeServer) ServeCalledN(n int) bool

ServeCalledN returns true if FakeServer.Serve was called at least n times

func (*FakeServer) ServeCalledOnce

func (f *FakeServer) ServeCalledOnce() bool

ServeCalledOnce returns true if FakeServer.Serve was called exactly once

func (*FakeServer) ServeNotCalled

func (f *FakeServer) ServeNotCalled() bool

ServeNotCalled returns true if FakeServer.Serve was not called

func (*FakeServer) SetAddressStub added in v0.3.1

func (_f4 *FakeServer) SetAddressStub(ident1 string)

SetAddressStub configures Server.Address to always return the given values

func (*FakeServer) SetListenStub added in v0.3.1

func (_f6 *FakeServer) SetListenStub(ident1 error)

SetListenStub configures Server.Listen to always return the given values

func (*FakeServer) SetNameStub added in v0.3.1

func (_f2 *FakeServer) SetNameStub(ident1 string)

SetNameStub configures Server.Name to always return the given values

func (*FakeServer) SetServeStub added in v0.3.1

func (_f8 *FakeServer) SetServeStub(ident1 error)

SetServeStub configures Server.Serve to always return the given values

func (*FakeServer) SetShutdownInvocation added in v0.3.1

func (_f11 *FakeServer) SetShutdownInvocation(calls_f12 []*ServerShutdownInvocation, fallback_f13 func() error)

SetShutdownInvocation configures Server.Shutdown to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeServer) SetShutdownStub added in v0.3.1

func (_f10 *FakeServer) SetShutdownStub(ident2 error)

SetShutdownStub configures Server.Shutdown to always return the given values

func (*FakeServer) Shutdown

func (_f9 *FakeServer) Shutdown(ident1 time.Duration) (ident2 error)

func (*FakeServer) ShutdownCalled

func (f *FakeServer) ShutdownCalled() bool

ShutdownCalled returns true if FakeServer.Shutdown was called

func (*FakeServer) ShutdownCalledN

func (f *FakeServer) ShutdownCalledN(n int) bool

ShutdownCalledN returns true if FakeServer.Shutdown was called at least n times

func (*FakeServer) ShutdownCalledOnce

func (f *FakeServer) ShutdownCalledOnce() bool

ShutdownCalledOnce returns true if FakeServer.Shutdown was called exactly once

func (*FakeServer) ShutdownCalledOnceWith

func (_f16 *FakeServer) ShutdownCalledOnceWith(ident1 time.Duration) bool

ShutdownCalledOnceWith returns true if FakeServer.Shutdown was called exactly once with the given values

func (*FakeServer) ShutdownCalledWith

func (_f14 *FakeServer) ShutdownCalledWith(ident1 time.Duration) (found bool)

ShutdownCalledWith returns true if FakeServer.Shutdown was called with the given values

func (*FakeServer) ShutdownNotCalled

func (f *FakeServer) ShutdownNotCalled() bool

ShutdownNotCalled returns true if FakeServer.Shutdown was not called

func (*FakeServer) ShutdownResultsForCall

func (_f18 *FakeServer) ShutdownResultsForCall(ident1 time.Duration) (ident2 error, found bool)

ShutdownResultsForCall returns the result values for the first call to FakeServer.Shutdown with the given values

type HTTPServer

type HTTPServer struct {
	Addr             string // TCP address to listen on, ":http" if empty
	UseTLS           bool   // should this server use TLS?
	DisableKeepAlive bool   // Should TCP keep alive be disabled?

	// TLSConfig is optional TLS configuration,
	// This must be non-nil and properly initialized if `UseTLS`
	// is `true`.
	TLSConfig *tls.Config

	// ReadTimeout is the maximum duration for reading the entire
	// request, including the body.
	//
	// Because ReadTimeout does not let Handlers make per-request
	// decisions on each request body's acceptable deadline or
	// upload rate, most users will prefer to use
	// ReadHeaderTimeout. It is valid to use them both.
	ReadTimeout time.Duration

	// ReadHeaderTimeout is the amount of time allowed to read
	// request headers. The connection's read deadline is reset
	// after reading the headers and the Handler can decide what
	// is considered too slow for the body.
	ReadHeaderTimeout time.Duration

	// WriteTimeout is the maximum duration before timing out
	// writes of the response. It is reset whenever a new
	// request's header is read. Like ReadTimeout, it does not
	// let Handlers make decisions on a per-request basis.
	WriteTimeout time.Duration

	// IdleTimeout is the maximum amount of time to wait for the
	// next request when keep-alives are enabled. If IdleTimeout
	// is zero, the value of ReadTimeout is used. If both are
	// zero, ReadHeaderTimeout is used.
	IdleTimeout time.Duration

	// MaxHeaderBytes controls the maximum number of bytes the
	// server will read parsing the request header's keys and
	// values, including the request line. It does not limit the
	// size of the request body.
	// If zero, DefaultMaxHeaderBytes is used.
	MaxHeaderBytes int

	// TLSNextProto optionally specifies a function to take over
	// ownership of the provided TLS connection when an NPN/ALPN
	// protocol upgrade has occurred. The map key is the protocol
	// name negotiated. The Handler argument should be used to
	// handle HTTP requests and will initialize the Request's TLS
	// and RemoteAddr if not already set. The connection is
	// automatically closed when the function returns.
	// If TLSNextProto is not nil, HTTP/2 support is not enabled
	// automatically.
	TLSNextProto map[string]func(*http.Server, *tls.Conn, http.Handler)

	// RequestIDHeaderName optionally customizes the name of the
	// response header for the request id.
	// If empty "X-Request-Id" will be used.
	RequestIDHeaderName string

	// RequestIDGenerator optionally customizes how request ids
	// are generated.
	// If nil then `httpx.Request.GenerateID` will be used.
	RequestIDGenerator httpx.StringExtractor

	// Authentication optionally enforces authentication before
	// other request handling.  This is recommended to prevent
	// leaking details about the implementation to unknown user
	// agents.
	Authentication *middleware.Authentication

	// Authorizer optionally enforces authentication before other
	// request handling.  Use of this field requires the
	// `Authentication` field to be configured and return a
	// principal.
	Authorizer Authorizer

	// Router is called by the `ServeHTTP` method to find the
	// correct handler to invoke for the current request.
	// If nil is returned a 404 status code with an empty body is
	// returned to the user agent.
	Router Router

	// ErrorHook optionally customizes how errors encountered
	// servicing a request are disposed.
	// If nil no action will be taken.
	ErrorHook httpx.ErrorHook

	// CompletionHook optionally customizes the behavior after
	// a request has been serviced.
	// If nil no action will be taken.
	CompletionHook httpx.CompletionHook
	// contains filtered or unexported fields
}

func (*HTTPServer) Address

func (s *HTTPServer) Address() string

func (*HTTPServer) Authenticate

func (s *HTTPServer) Authenticate(ctx context.Context, request *httpx.Request) (response httpx.Response)

func (*HTTPServer) Authorize

func (s *HTTPServer) Authorize(ctx context.Context, request *httpx.Request) (response httpx.Response)

func (*HTTPServer) Listen

func (s *HTTPServer) Listen() (err error)

func (*HTTPServer) Serve

func (s *HTTPServer) Serve() error

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown(timeout time.Duration) error

type HealthcheckServer

type HealthcheckServer struct {
	HTTPServer
	Path string // URL path to listen on, "/healthcheck" if empty

	// Checkers are the resources to include in the status report.
	Checkers []Healthchecker
}

HealthcheckServer serves JSON status reports of all configured `Healthchecker` resources to the given address and path. If all resources return no error a 200 status code is returned, otherwise a 503 is returned. The status report is a JSON Resource with the `Name()` of the resources as keys and either the `merry.UserMessage` of the error or `"OK"` as the value.

func (*HealthcheckServer) Listen

func (s *HealthcheckServer) Listen() error

func (*HealthcheckServer) Name

func (s *HealthcheckServer) Name() string

func (*HealthcheckServer) Route

func (s *HealthcheckServer) Route(ctx context.Context, request *httpx.Request) httpx.Handler

func (*HealthcheckServer) Service

func (s *HealthcheckServer) Service(ctx context.Context, request *httpx.Request) httpx.Response

type Healthchecker

type Healthchecker interface {
	// Name is the resource's name for external reporting
	Name() string
	// Healthcheck should return an error if the resource has a
	// problem and should not be considered reliable for further
	// requests.
	Healthcheck(context.Context) merry.Error
}

Healthchecker is a named resource that can report its status. If the resource is unable to perform its function it should return an error with the UserMessage explaining the problem.

type Router

type Router func(context.Context, *httpx.Request) httpx.Handler

func (Router) InvokeSafely

func (r Router) InvokeSafely(ctx context.Context, request *httpx.Request) (_ httpx.Handler, exception merry.Error)

type Server

type Server interface {
	Name() string
	Address() string
	Listen() error
	Serve() error
	Shutdown(time.Duration) error
}

type ServerAddressInvocation

type ServerAddressInvocation struct {
	Results struct {
		Ident1 string
	}
}

ServerAddressInvocation represents a single call of FakeServer.Address

type ServerListenInvocation

type ServerListenInvocation struct {
	Results struct {
		Ident1 error
	}
}

ServerListenInvocation represents a single call of FakeServer.Listen

type ServerNameInvocation

type ServerNameInvocation struct {
	Results struct {
		Ident1 string
	}
}

ServerNameInvocation represents a single call of FakeServer.Name

type ServerServeInvocation

type ServerServeInvocation struct {
	Results struct {
		Ident1 error
	}
}

ServerServeInvocation represents a single call of FakeServer.Serve

type ServerShutdownInvocation

type ServerShutdownInvocation struct {
	Parameters struct {
		Ident1 time.Duration
	}
	Results struct {
		Ident2 error
	}
}

ServerShutdownInvocation represents a single call of FakeServer.Shutdown

func NewServerShutdownInvocation added in v0.3.1

func NewServerShutdownInvocation(ident1 time.Duration, ident2 error) *ServerShutdownInvocation

NewServerShutdownInvocation creates a new instance of ServerShutdownInvocation

type ServerTestingT

type ServerTestingT interface {
	Error(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Helper()
}

ServerTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.

Jump to

Keyboard shortcuts

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