http

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2018 License: MIT Imports: 5 Imported by: 0

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.

type UnmarshalMessageFunc

type UnmarshalMessageFunc func(topic string, request *http.Request) (*message.Message, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL