Documentation ¶
Overview ¶
Package wrpendpoint integrates go-kit endpoints with the notion of services that consume and emit WRP. Code in this package is transport-neutral. See the wrp/wrphttp package for HTTP-specific integrations with go-kit's transport/http package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Note ¶
type Note interface { // Destination returns the WRP destination string from the decoded message Destination() string // TransactionID returns the transaction identifier, if any TransactionID() string // Message returns the underlying decoded WRP message. This can be nil in the case of // raw messages. Callers should never modify the returned Message instance. Message() *wrp.Message // Encode writes out the WRP message fronted by this Note in the format supported by the pool. Encode(output io.Writer, format wrp.Format) error // EncodeBytes works like Encode, except that it returns a []byte. EncodeBytes(format wrp.Format) ([]byte, error) }
Note is the core type implemented by any entity which carries a WRP message.
type Request ¶
type Request interface { Note // Logger returns the enriched logger associated with this Request. Client code should take care // to preserve this logger when changing loggers via WithLogger. // // If the logger associated with this Request is nil, for example via WithLogger(nil), this method // returns logging.DefaultLogger(). Logger() log.Logger // WithLogger produces a shallow copy of this Request with a new Logger. Generally, when creating a new // request logger, start with Logger(): // // var request Request = ... // request = request.WithLogger(log.With(request.Logger(), "more", "stuff")) WithLogger(log.Logger) Request }
Request is a WRP request. In addition to implementing Note, this type also provides contextual logging. A Request is considered immutable once instantiated. Methods that update a Request return a shallow copy with the modification.
func DecodeRequest ¶
DecodeRequest extracts a WRP request from the given source.
func DecodeRequestBytes ¶
DecodeRequestBytes returns a Request taken from the contents. The given pool is used to decode the WRP message.
This function also enhances the given logger with contextual information about the returned WRP request. The logger that is passed to this function should never be nil and should never have a Caller or DefaultCaller set.
func WrapAsRequest ¶
WrapAsRequest takes an existing WRP message and produces a Request for that message.
type Response ¶
Response represents a WRP response to a Request. Note that not all WRP requests will have responses, e.g. SimpleEvents. A Response instance is considered immutable once created. Methods that modify a response will return a shallow copy with the modification.
func DecodeResponse ¶
DecodeResponse extracts a WRP response from the given source.
func DecodeResponseBytes ¶
DecodeResponseBytes returns a Response taken from the contents. The given pool is used to decode the WRP message.
func WrapAsResponse ¶
func WrapAsResponse(m *wrp.Message) Response
WrapAsResponse takes an existing WRP message and produces a Response for that message.