server

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker is the event message broker

func ListenAndServeOnSocket

func ListenAndServeOnSocket(socketPath string, optionalURLPattern ...string) (*Broker, error)

ListenAndServeOnSocket starts a minimal server (mostly for testing) listening at the given unix socket path.

func NewBroker

func NewBroker() *Broker

NewBroker returns an instance of the broker

func (*Broker) Publish

func (b *Broker) Publish(topic string, data interface{}, optionalTimeout ...time.Duration) error

Publish publishes a message at the topic

func (*Broker) ServeHTTP

func (b *Broker) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServerHTTP implements the HTTP handler

func (*Broker) Stop

func (b *Broker) Stop()

Stop stops the broker and exits the goroutine

type ErrInvalidTopic

type ErrInvalidTopic string

ErrInvalidTopic is the error raised when topic is invalid

func (ErrInvalidTopic) Error

func (e ErrInvalidTopic) Error() string

type ErrNotAuthorized

type ErrNotAuthorized string

ErrNotAuthorized is the error raised when the user isn't authorized

func (ErrNotAuthorized) Error

func (e ErrNotAuthorized) Error() string

type Interceptor

type Interceptor struct {

	// Do is the body of the http handler -- required
	Do http.HandlerFunc

	// Pre is called to before actual subscription to a topic happens.
	// This is the hook where validation and authentication / authorization checks happen.
	Pre func(topic string, headers map[string][]string) error

	// Post is called when the client disconnects.  This is optional.
	Post func(topic string)
}

Interceptor implements http Handler and is used to intercept incoming requests to subscribe to topics and perform some validations before allowing the subscription to be established. Tasks that the interceptor can do include authn and authz, topic validation, etc.

func (*Interceptor) ServeHTTP

func (i *Interceptor) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP calls the before and after subscribe methods.

Jump to

Keyboard shortcuts

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