service

package
v0.0.0-...-6c0bb26 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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.

Jump to

Keyboard shortcuts

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