Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExplicitScoper ¶
func ExplicitScoper() *explicitScoper
ExplicitScoper mints a Scoper that we can define explicitly things like SessionId and TraceId
Types ¶
type Caller ¶
func ConfiguredHttpCaller ¶
ConfiguredHttpCaller with more explicit configuration options than simple HttpCaller
func ErrorCaller ¶
ErrorCaller is a very simple caller that just returns an error If no error provided, defaults to a `NotFound` error with code "errorcaller.notfound"
func HttpCaller ¶
HttpCaller returns a caller that hits a "thin API" by HTTP, where baseUrl is provided and is something like 'https://api-staging.elasticride.com'
func PlatformCaller ¶
func PlatformCaller() Caller
PlatformCaller is the default caller and makes requests via the platform layer RPC mechanism (eg: RabbitMQ)
type Errors ¶
type Errors interface { error // IgnoreUid removes all errors for the given request uid(s) IgnoreUid(uids ...string) Errors // IgnoreService removes all errors for requests to the given service(s) IgnoreService(services ...string) Errors // IgnoreEndpoint removes all errors to a given service endpoint IgnoreEndpoint(service, endpoint string) Errors // IgnoreType removes all errors of the given type(s) IgnoreType(types ...string) Errors // IgnoreCode removes all errors with the given code(s) IgnoreCode(codes ...string) Errors // Errors returns all matching errors, mapped to their request uid Errors() map[string]errors.Error // Count returns a count of matching errors Count() int // AnyErrors returns whether there are any contained errors AnyErrors() bool // ForUid returns the error for a given request uid (or nil) ForUid(uid string) errors.Error // Suffix sets a dotted suffix to add to any returned errors Suffix(suffix string) Errors // Combined returns a platform error with the given suffix, scoped correctly (or nil) Combined() errors.Error // MultiError returns a combined MultiError MultiError() *multierror.MultiError }
type Mock ¶
func (*Mock) Caller ¶
Caller returns something that implements `Caller` - allowing us to use this as our gateway to service calls - the returned `Caller` is thread safe
type MultiClient ¶
type MultiClient interface { // DefaultScopeFrom defines a server request that we can leverage for scoping, meaning that any // `ScopedReq`s added don't have to include the From scope DefaultScopeFrom(s Scoper) MultiClient // SetCaller optionally defines a caller for use with this multiclient request (overrides the default) SetCaller(c Caller) MultiClient // AddScopedReq adds a server-scoped request (from the server request `from`) to our multi-client // with the `uid` that uniquely identifies the request within the group (for getting response from `Outcome`) AddScopedReq(sr *ScopedReq) MultiClient // Reset removes all scoped requests/results ready for re-use Reset() MultiClient // Execute runs all requests in parallel, blocking until all have completed Execute() MultiClient // AnyErrors will return true if ANY request resulted in an error AnyErrors() bool // AnyErrorsIgnoring will return true if ANY request resulted in an error, but ignoring the supplied types/codes AnyErrorsIgnoring(types []string, codes []string) bool // PlatformError mints a new platform error, with the specified code suffix (and server namespace prefix), // describing all errors that occurred PlatformError(codeSuffix string) errors.Error // Errors returns Errors representing all errors that occurred Errors() Errors // Succeeded tests if request with this uid had an error Succeeded(uid string) errors.Error // Response returns the response for request uid Response(uid string) proto.Message }
MultiClient represents a session where we want to make one or more requests
type Responder ¶
Responder is a function that yields a mocked response (successful in the form of proto.Message or unsuccessful in the form of errors.Error), in response to some inbound client `req`. The `invocation` parameter will contain the call sequence number, indexed from 1, for example it will be `1` the first time we are asked for a response, `2` on the next invocation etc..
type ScopedReq ¶
type ScopedReq struct { Uid string From Scoper Service string Endpoint string Req proto.Message Rsp proto.Message Options client.Options }
ScopedReq describes a scoped request
type Scoper ¶
type Scoper interface { // Name returns the scope name, for example the server name, or scoping request name, // which can be used to give context to error messages etc. Context() string // ScopedRequest yields a new RPC request, preserving scope of trace/auth etc. ScopedRequest(service, endpoint string, payload proto.Message) (*client.Request, error) }
Scoper represents something that generate us a "scoped" request A "scoped" request includes some context, either taken from the "server" (who we are) or an inbound request
type Stub ¶
type Stub struct {
Service, Endpoint string
Response proto.Message // Response to return on every matched request
Error errors.Error // Error to return on every matched request
Responder Responder // Responder function to use to give more control over exact response
// contains filtered or unexported fields
}
func (*Stub) CountCalls ¶
CountCalls returns the number of calls that this stub has handled