Documentation ¶
Index ¶
- Variables
- func AsyncTopic(pub *Publication) error
- func Pub(topic string, payload proto.Message) error
- func Push(req *Request) error
- func Req(req *Request, rsp proto.Message, options ...Options) errors.Error
- type Client
- type MockClient
- func (m *MockClient) AddRequestExpectation(req *Request, rsp proto.Message)
- func (m *MockClient) AsyncTopic(pub *Publication) error
- func (m *MockClient) CustomReq(req *Request, options ...Options) (*Response, hailo_errors.Error)
- func (m *MockClient) Pub(topic string, payload proto.Message) error
- func (m *MockClient) Push(req *Request) error
- func (m *MockClient) Req(req *Request, rsp proto.Message, options ...Options) hailo_errors.Error
- type MockResponseDelivery
- type Options
- type Publication
- type Request
- func (r *Request) Authorised() bool
- func (r *Request) ContentType() string
- func (r *Request) Endpoint() string
- func (r *Request) From() string
- func (r *Request) FromEndpoint() string
- func (r *Request) GetOptions() Options
- func (r *Request) MessageID() string
- func (r *Request) ParentMessageID() string
- func (r *Request) Payload() []byte
- func (r *Request) RemoteAddr() string
- func (r *Request) Service() string
- func (r *Request) SessionID() string
- func (r *Request) SetAuthorised(val bool)
- func (r *Request) SetFrom(service string)
- func (r *Request) SetFromEndpoint(endpoint string)
- func (r *Request) SetOptions(options Options)
- func (r *Request) SetParentMessageID(id string)
- func (r *Request) SetRemoteAddr(addr string)
- func (r *Request) SetSessionID(id string)
- func (r *Request) SetTraceID(id string)
- func (r *Request) SetTraceShouldPersist(val bool)
- func (r *Request) TraceID() string
- func (r *Request) TraceShouldPersist() bool
- func (r *Request) Unmarshal(into proto.Message) (err error)
- type Response
- func (self *Response) Body() []byte
- func (self *Response) ContentType() string
- func (self *Response) CorrelationID() string
- func (self *Response) Header() amqp.Table
- func (self *Response) IsError() bool
- func (self *Response) MessageID() string
- func (self *Response) String() string
- func (self *Response) Unmarshal(into proto.Message) (err error)
- type Timeout
Constants ¶
This section is empty.
Variables ¶
var ( // NewDefaultClient is the regular Client constructor, used to create real clients. NewDefaultClient func() Client = newClient // NewClient is the default client constructor used. Override this during testing to ensure all new clients created // will use a mock (ensuring to set it back to DefaultClientConstructor at the conclusion of the tests). NewClient func() Client = NewDefaultClient // DefaultClient is a client with default options. This can be overridden for testing. DefaultClient Client = NewClient() )
Functions ¶
func AsyncTopic ¶
func AsyncTopic(pub *Publication) error
AsyncTopic is a wrapper around DefaultClient.AsyncTopic
Types ¶
type Client ¶
type Client interface { // Req sends a request, and marhsals a successful response or returns an error Req(req *Request, rsp proto.Message, options ...Options) errors.Error // CustomReq is similar to Req, but without the automatic response unmarshaling, and instead returning a response CustomReq(req *Request, options ...Options) (*Response, errors.Error) // Push sends a request where we do not wish to wait for a REP (but is still REQ/REP pattern) Push(req *Request) error // AsyncTopic sends a pub/sub message (a Publication) AsyncTopic(pub *Publication) error // Pub created and sends a Publication (via AsyncTopic) in one handy step Pub(topic string, payload proto.Message) error }
A client stores the details of a service client
func NewMockClient ¶
func NewMockClient() Client
type MockClient ¶
var ActiveMockClient *MockClient = nil
This must be set to an instance of MockClient before tests begin. NewMockClient will always return this pointer
func (*MockClient) AddRequestExpectation ¶
func (m *MockClient) AddRequestExpectation(req *Request, rsp proto.Message)
Adds a request expectation to the mock, to be returned when a matching request is received (only the service and endpoint parameters are compared)
func (*MockClient) AsyncTopic ¶
func (m *MockClient) AsyncTopic(pub *Publication) error
func (*MockClient) CustomReq ¶
func (m *MockClient) CustomReq(req *Request, options ...Options) (*Response, hailo_errors.Error)
func (*MockClient) Push ¶
func (m *MockClient) Push(req *Request) error
func (*MockClient) Req ¶
func (m *MockClient) Req(req *Request, rsp proto.Message, options ...Options) hailo_errors.Error
type MockResponseDelivery ¶
type Publication ¶
type Publication struct {
// contains filtered or unexported fields
}
Publication packages data needed to send a publication out
func NewJsonPublication ¶
func NewJsonPublication(topic string, payload []byte) (*Publication, error)
NewJsonPublication returns a new publication based on topic and json payload
func NewPublication ¶
func NewPublication(topic string, payload proto.Message) (*Publication, error)
NewPublication returns a new publication based on topic and payload
func (*Publication) ContentType ¶
func (self *Publication) ContentType() string
ContentType return the content type of the publication
func (*Publication) MessageID ¶
func (self *Publication) MessageID() string
MessageID returns the message ID of the publication
func (*Publication) Payload ¶
func (self *Publication) Payload() []byte
Payload returns the payload of the publication
func (*Publication) SessionID ¶
func (self *Publication) SessionID() string
SessionID returns the session ID of the publication
func (*Publication) SetSessionID ¶
func (self *Publication) SetSessionID(id string)
SetSessionID sets the session ID of the publication
func (*Publication) Topic ¶
func (self *Publication) Topic() string
Topic returns the topic of the publication
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request packages data needed to send a request out
func NewJsonRequest ¶
NewJsonRequest builds a new request object for JSON requests
func NewProtoRequest ¶
NewProtoRequest builds a new request object for raw protobuf requests
func NewRequest ¶
NewRequest builds a new request object, checking for bad data
func (*Request) Authorised ¶
Authorised returns whether the request has already been authorised
func (*Request) ContentType ¶
ContentType returns the content type of the request
func (*Request) From ¶
From returns information about which service sent this request @todo return something that can be cryptographically verified
func (*Request) FromEndpoint ¶
From returns information about which endpoint sent this request
func (*Request) GetOptions ¶
func (*Request) ParentMessageID ¶
ParentMessageID returns the message ID of a message (if any) that was received and triggered this message In other words, we use this to build up the call stack / hierarchy
func (*Request) RemoteAddr ¶
RemoteAddr returns the remote IP Address of the request
func (*Request) SetAuthorised ¶
SetAuthorised sets whether the request has already been authorised
func (*Request) SetFrom ¶
SetFrom sets details about which service is making this request @todo eventually this should include an async cryptographic signature such that the receiver can verify this to establish trust
func (*Request) SetFromEndpoint ¶
SetFromEndpoint sets details about which endpoint is making this request
func (*Request) SetOptions ¶
func (*Request) SetParentMessageID ¶
SetParentMessageID sets the parent message ID, so we can build up the call stack
func (*Request) SetRemoteAddr ¶
SetRemoteAddr sets the address of the remote client making this request
func (*Request) SetSessionID ¶
SetSessionID sets the session ID of the request
func (*Request) SetTraceID ¶
SetTraceID sets the trace ID of the request
func (*Request) SetTraceShouldPersist ¶
SetTraceShouldPersist sets whether the request trace should be stored persistently
func (*Request) TraceShouldPersist ¶
TraceShouldPersist returns if the trace should be stored persistently
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response wraps an AMQP delivery
func (*Response) ContentType ¶
ContentType returns the content type of the delivery
func (*Response) CorrelationID ¶
CorrelationID returns the MessageId of the original message
func (*Response) MessageID ¶
MessageID returns the ID of the underlying message transport system, which is unique per delivery, and only really useful for debugging
type Timeout ¶
Timeout stores state information about services in order to make decisions on what timeout to use when contacting other services
func NewTimeout ¶
NewTimeout mints a blank timeout container from which we can calculate timeouts to use for requests