Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber can subscribe to HTTP requests and create Watermill's messages based on them.
func NewSubscriber ¶
func NewSubscriber(addr string, unmarshalMessageFunc UnmarshalMessageFunc, logger watermill.LoggerAdapter) (*Subscriber, error)
NewSubscriber creates new Subscriber.
addr is TCP address to listen on
unmarshalMessageFunc is function which converts HTTP request to Watermill's message.
logger is Watermill's logger.
func NewSubscriberWithRouter ¶ added in v0.2.0
func NewSubscriberWithRouter( addr string, router chi.Router, unmarshalMessageFunc UnmarshalMessageFunc, logger watermill.LoggerAdapter) (*Subscriber, error)
NewSubscriberWithRouter creates new Subscriber with provided router.
addr is TCP address to listen on
unmarshalMessageFunc is function which converts HTTP request to Watermill's message.
logger is Watermill's logger.
func (*Subscriber) Close ¶
func (s *Subscriber) Close() error
func (*Subscriber) StartHTTPServer ¶
func (s *Subscriber) StartHTTPServer() error
StartHTTPServer starts http server. StartHTTPServer must be called after all subscribe function are called.
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe(url string) (chan *message.Message, error)
Subscribe adds HTTP handler which will listen in provided url for messages.
Subscribe needs to be called before `StartHTTPServer`.
When request is sent, it will wait for the `Ack`. When Ack is received 200 HTTP status wil be sent. When Nack is sent, 500 HTTP status will be sent.