Documentation ¶
Index ¶
- type StreamService
- func (s *StreamService) CreateStream(r *http.Request) (int, interface{}, error)
- func (s *StreamService) Demo(w http.ResponseWriter, r *http.Request)
- func (s *StreamService) Endpoints() map[string]map[string]http.HandlerFunc
- func (s *StreamService) Middleware(h http.Handler) http.Handler
- func (s *StreamService) Prefix() string
- func (s *StreamService) Stream(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StreamService ¶
type StreamService struct {
// contains filtered or unexported fields
}
StreamService offers three endpoints: one to create a new topic in Kafka, a second to expose the topic over a websocket and a third to host a web page that provides a demo.
func NewStreamService ¶
func NewStreamService(port int, cfg *kafka.Config) *StreamService
NewStreamService will return a new stream service instance. If the given config is empty, it will default to localhost.
func (*StreamService) CreateStream ¶
func (s *StreamService) CreateStream(r *http.Request) (int, interface{}, error)
CreateStream is a JSON endpoint for creating a new topic in Kafka.
func (*StreamService) Demo ¶
func (s *StreamService) Demo(w http.ResponseWriter, r *http.Request)
Demo will serve an HTML page that demonstrates how to use the 'stream' endpoint.
func (*StreamService) Endpoints ¶
func (s *StreamService) Endpoints() map[string]map[string]http.HandlerFunc
Endpoints returns the two endpoints for our stream service.
func (*StreamService) Middleware ¶
func (s *StreamService) Middleware(h http.Handler) http.Handler
Middleware in this service will do nothing.
func (*StreamService) Prefix ¶
func (s *StreamService) Prefix() string
Prefix is the string prefixed to all endpoint routes.
func (*StreamService) Stream ¶
func (s *StreamService) Stream(w http.ResponseWriter, r *http.Request)
Stream will init a new pubsub.Publisher and pubsub.Subscriber then upgrade the current request to a websocket connection. Any messages consumed from Kafka will be published to the web socket and vice versa.