module

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 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 DeleteEvent

type DeleteEvent struct {
	EventBase
}

DeleteEvent is the type of event passed to the OnDelete function of the event handler

type DeleteResponse

type DeleteResponse struct {
	Finished bool
	ToDelete []string
}

DeleteResponse is the type returned for delete events. The response indicates which if any RediSearch documents to delete in response to the event. It also indicates if the event handling should continue to the next handler or is finished.

type Event

type Event struct {
	Op *gtm.Op
}

Event is the type available to event handlers when determining whether or not the handler will handle the event

type EventBase

type EventBase struct {
	MongoClient       *mongo.Client
	RedisSearchClient *redisearch.Client
	Op                *gtm.Op
	Logs              *Loggers
}

EventBase is the type holding the common context available to all event handlers via the passed in event

type EventHandler

type EventHandler interface {
	Name() string
	Handles(*Event) bool
	OnInsert(*InsertEvent) (*IndexResponse, error)
	OnUpdate(*UpdateEvent) (*IndexResponse, error)
	OnDelete(*DeleteEvent) (*DeleteResponse, error)
}

type IndexResponse

type IndexResponse struct {
	Finished bool
	ToIndex  []redisearch.Document
}

IndexResponse is the type returned for insert and update events. The response indicates which if any RediSearch documents to index in response to the event. It also indicates if the event handling should continue to the next handler or is finished.

type InsertEvent

type InsertEvent struct {
	EventBase
}

InsertEvent is the type of event passed to the OnInsert function of the event handler

type Loggers

type Loggers struct {
	InfoLog  *log.Logger
	WarnLog  *log.Logger
	TraceLog *log.Logger
	ErrorLog *log.Logger
}

Loggers is the type holding a set of loggers available to event handlers

type PipeBuilder

type PipeBuilder interface {
	Name() string
	BuildPipeline(*PipeRequest) (*PipeResponse, error)
}

type PipeRequest

type PipeRequest struct {
	Namespace    string
	ChangeStream bool
}

type PipeResponse

type PipeResponse struct {
	Stages []bson.M
}

type Plugin

type Plugin struct {
	Events   []EventHandler
	Schemas  SchemaHandler
	Pipeline PipeBuilder
}

Plugin is the type returned by the intializer function. It contains a slice of event handlers and a schema handler. The event handlers respond to create, update, and delete events in MongoDB. The schema handlers are invoked when a MongoDB namespace event requires building a new index with schema in RediSearch.

type PluginInitializer

type PluginInitializer interface {
	Get() Plugin
}

PluginInitializer is the interface your plugin must expose as a var named "InitPlugin" to get initialized

type SchemaEvent

type SchemaEvent struct {
	Namespace string
}

SchemaEvent is the type of event passed to schema handlers. The event contains the namespace, i.e. db.collection, of the MongoDB event that occurred. Schema handlers can use the namespace to return information about the corresponding RediSearch index to use and the schema to use when creating the RediSearch index.

type SchemaHandler

type SchemaHandler interface {
	Name() string
	Handles(*SchemaEvent) bool
	Schema(*SchemaEvent) (*SchemaResponse, error)
}

type SchemaResponse

type SchemaResponse struct {
	Schema *redisearch.Schema
	Index  string
}

type UpdateEvent

type UpdateEvent struct {
	EventBase
}

UpdateEvent is the type of event passed to the OnUpdate function of the event handler

Jump to

Keyboard shortcuts

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