Package amqp implements an AMQP transport.
const ( ContextKeyExchange contextKey = iota ContextKeyPublishKey ContextKeyNackSleepDuration ContextKeyAutoAck ContextKeyConsumeArgs )
This section is empty.
DefaultDeliverer is a deliverer that publishes the specified Publishing and returns the first Delivery object with the matching correlationId. If the context times out while waiting for a reply, an error will be returned.
DefaultErrorEncoder simply ignores the message. It does not reply nor Ack/Nack the message.
DefaultResponsePublisher extracts the reply exchange and reply key from the request, and sends the response object to that destination.
EncodeJSONResponse marshals the response as JSON as part of the payload of the AMQP Publishing object.
EncodeNopResponse is a response function that does nothing.
NopResponsePublisher does not deliver a response to the original sender. This response publisher is used when the user wants the subscriber to receive and forget.
func ReplyAndAckErrorEncoder ¶ReplyAndAckErrorEncoder serializes the error message as a DefaultErrorResponse JSON and sends the message to the ReplyTo address then Acks the original message.
ReplyErrorEncoder serializes the error message as a DefaultErrorResponse JSON and sends the message to the ReplyTo address.
func SendAndForgetDeliverer ¶ added in v0.9.0SendAndForgetDeliverer delivers the supplied publishing and returns a nil response. When using this deliverer please ensure that the supplied DecodeResponseFunc and PublisherResponseFunc are able to handle nil-type responses.
SingleNackRequeueErrorEncoder issues a Nack to the delivery with multiple flag set as false and requeue flag set as true. It does not reply the message.
type Channel interface { Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error Consume(queue, consumer string, autoAck, exclusive, noLocal, noWail bool, args amqp.Table) (<-chan amqp.Delivery, error) }
Channel is a channel interface to make testing possible. It is highly recommended to use *amqp.Channel as the interface implementation.
DecodeRequestFunc extracts a user-domain request object from an AMQP Delivery object. It is designed to be used in AMQP Subscribers.
DecodeResponseFunc extracts a user-domain response object from an AMQP Delivery object. It is designed to be used in AMQP Publishers.
type DefaultErrorResponse struct { Error string `json:"err"` }
DefaultErrorResponse is the default structure of responses in the event of an error.
Deliverer is invoked by the Publisher to publish the specified Publishing, and to retrieve the appropriate response Delivery object.
EncodeRequestFunc encodes the passed request object into an AMQP Publishing object. It is designed to be used in AMQP Publishers.
EncodeResponseFunc encodes the passed response object to an AMQP Publishing object. It is designed to be used in AMQP Subscribers.
ErrorEncoder is responsible for encoding an error to the subscriber reply. Users are encouraged to use custom ErrorEncoders to encode errors to their replies, and will likely want to pass and check for their own error types.
type Publisher struct { }
Publisher wraps an AMQP channel and queue, and provides a method that implements endpoint.Endpoint.
NewPublisher constructs a usable Publisher for a single remote method.
Endpoint returns a usable endpoint that invokes the remote endpoint.
PublisherOption sets an optional parameter for clients.
PublisherAfter sets the ClientResponseFuncs applied to the incoming AMQP request prior to it being decoded. This is useful for obtaining anything off of the response and adding onto the context prior to decoding.
PublisherBefore sets the RequestFuncs that are applied to the outgoing AMQP request before it's invoked.
PublisherDeliverer sets the deliverer function that the Publisher invokes.
PublisherTimeout sets the available timeout for an AMQP request.
PublisherResponseFunc may take information from an AMQP request and make the response available for consumption. PublisherResponseFunc are only executed in publishers, after a request has been made, but prior to it being decoded.
RequestFunc may take information from a publisher request and put it into a request context. In Subscribers, RequestFuncs are executed prior to invoking the endpoint.
SetConsumeArgs returns a RequestFunc that set the arguments for amqp Consume function. It is designed to be used by Publishers.
SetConsumeAutoAck returns a RequestFunc that sets whether or not to autoAck messages when consuming. When set to false, the publisher will Ack the first message it receives with a matching correlationId. It is designed to be used by Publishers.
SetContentEncoding returns a RequestFunc that sets the ContentEncoding field of an AMQP Publishing.
SetContentType returns a RequestFunc that sets the ContentType field of an AMQP Publishing.
SetCorrelationID returns a RequestFunc that sets the CorrelationId field of an AMQP Publishing.
SetNackSleepDuration returns a RequestFunc that sets the amount of time to sleep in the event of a Nack. This has to be used in conjunction with an error encoder that Nack and sleeps. One example is the SingleNackRequeueErrorEncoder. It is designed to be used by Subscribers.
SetPublishDeliveryMode sets the delivery mode of a Publishing. Please refer to AMQP delivery mode constants in the AMQP package.
SetPublishExchange returns a RequestFunc that sets the Exchange field of an AMQP Publish call.
SetPublishKey returns a RequestFunc that sets the Key field of an AMQP Publish call.
ResponsePublisher functions are executed by the subscriber to publish response object to the original sender. Please note that the word "publisher" does not refer to the publisher of pub/sub. Rather, publisher is merely a function that publishes, or sends responses.
type Subscriber struct { }
Subscriber wraps an endpoint and provides a handler for AMQP Delivery messages.
NewSubscriber constructs a new subscriber, which provides a handler for AMQP Delivery messages.
ServeDelivery handles AMQP Delivery messages It is strongly recommended to use *amqp.Channel as the Channel interface implementation.
SubscriberOption sets an optional parameter for subscribers.
SubscriberAfter functions are executed on the subscriber reply after the endpoint is invoked, but before anything is published to the reply.
SubscriberBefore functions are executed on the publisher delivery object before the request is decoded.
SubscriberErrorEncoder is used to encode errors to the subscriber reply whenever they're encountered in the processing of a request. Clients can use this to provide custom error formatting. By default, errors will be published with the DefaultErrorEncoder.
func SubscriberErrorHandler ¶ added in v0.9.0SubscriberErrorHandler is used to handle non-terminal errors. By default, non-terminal errors are ignored. This is intended as a diagnostic measure. Finer-grained control of error handling, including logging in more detail, should be performed in a custom SubscriberErrorEncoder which has access to the context.
SubscriberErrorLogger is used to log non-terminal errors. By default, no errors are logged. This is intended as a diagnostic measure. Finer-grained control of error handling, including logging in more detail, should be performed in a custom SubscriberErrorEncoder which has access to the context. Deprecated: Use SubscriberErrorHandler instead.
SubscriberResponsePublisher is used by the subscriber to deliver response objects to the original sender. By default, the DefaultResponsePublisher is used.
SubscriberResponseFunc may take information from a request context and use it to manipulate a Publisher. SubscriberResponseFuncs are only executed in subscribers, after invoking the endpoint but prior to publishing a reply.
SetAckAfterEndpoint returns a SubscriberResponseFunc that prompts the service to Ack the Delivery object after successfully evaluating the endpoint, and before it encodes the response. It is designed to be used by Subscribers.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4