message_handlers

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2016 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Indexer = NewMiddleware("indexer", func(h MessageHandler) MessageHandler {
	fn := func(c Connection, m *Message, e error) {
		if !Config().Indices.Disable && e == nil {
			if chItr, found := c.Metadata()["channel"]; found {
				ch := chItr.(*Channel)
				id := uuid.NewV1().String()
				p, err := NewPoint(id, ch, c, m)
				if err == nil {
					if meta, found := c.Metadata()["metadata"]; found && meta != nil {
						p.Metadata(meta.(map[string]string))
					}

					_, err := IndexClient.Index().
						Index(TimedIndexName(ch, p.Timestamp)).
						Type(p.IndexType()).
						Id(id).
						BodyJson(p).
						Do()
					if err != nil {
						Logger.Error(fmt.Sprintf("error indexing point, %s", err.Error()))
					}
				} else {
					Logger.Error(fmt.Sprintf("error creating point, %s", err.Error()))
				}
			}
		}

		h(c, m, e)
	}
	return MessageHandler(fn)
})
View Source
var SupportedMessageHandlers = map[string]*Middleware{"indexer": Indexer}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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