plugins

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 9 Imported by: 0

README

plugins

Plugins are an interface into the command handling pipeline. These plugins allow you to add, change, modify, remove, etc. commands in and out of the system.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = make(map[string]PluginFunc)

Registry contains all the registered plugins

Functions

func Register

func Register(f PluginFunc)

Register adds a given plugin to the registry

Types

type ChainFunc

type ChainFunc func(PipelineFunc) PipelineFunc

type ClientConnection

type ClientConnection struct {
	// Address of client connection
	Addr net.Addr
	// According to the docs (https://docs.mongodb.com/manual/core/authentication/#authentication-methods) multiple logins should
	// have the credentials for all until a logout happens; for now we aren't doing that.
	Identities []ClientIdentity

	// Map is storage that resets on cursor change
	Map map[interface{}]interface{}
}

func NewClientConnection

func NewClientConnection() *ClientConnection

func (*ClientConnection) Close

func (c *ClientConnection) Close()

func (*ClientConnection) GetAddr

func (c *ClientConnection) GetAddr() string

type ClientIdentity

type ClientIdentity interface {
	Type() string // Where the identity came from
	User() string
	Roles() []string
}

type CursorCache

type CursorCache interface {
	GetCursor(cursorID int64) *CursorCacheEntry
	CloseCursor(cursorID int64)
}

type CursorCacheEntry

type CursorCacheEntry struct {
	ID             int64
	CursorConsumed int

	// Map is storage that resets on cursor change
	Map map[interface{}]interface{}
}

func NewCursorCacheEntry

func NewCursorCacheEntry(id int64) *CursorCacheEntry

type PipelineFunc

type PipelineFunc func(context.Context, *Request) (bson.D, error)

PipelineFunc is the function type for the built pipeline, and is called to begin the pipeline.

func BuildPipeline

func BuildPipeline(m []Plugin, base PipelineFunc) PipelineFunc

BuildPipeline takes a plugin chain and creates a pipeline, returning a PipelineFunc that starts the pipeline when called.

type Plugin

type Plugin interface {
	// Name returns the name for the given plugin
	Name() string

	// Configure configures this plugin with the given configuration object. Returns
	// an error if the configuration is invalid for the plugin.
	Configure(bson.D) error

	// Process is the function executed when a message is called in the pipeline.
	Process(context.Context, *Request, PipelineFunc) (bson.D, error)
}

func GetPlugin

func GetPlugin(n string) (Plugin, bool)

GetPlugin returns an instance of the requested plugin

type PluginFunc

type PluginFunc func() Plugin

PluginFunc returns a new instance of a Plugin

type Request

type Request struct {
	CC *ClientConnection
	CursorCache

	CommandName string
	Command     command.Command

	// Map of arbitrary data for plugins to store stuff in
	Map map[string]interface{}
}

Request encapsulates a mongo request

func (*Request) Close

func (r *Request) Close()

type StaticIdentity

type StaticIdentity struct {
	T  string   `bson"type"`
	U  string   `bson:"user"`
	RS []string `bson:"roles"`
}

func NewStaticIdentity

func NewStaticIdentity(t, u string, rs ...string) *StaticIdentity

func (*StaticIdentity) Roles

func (i *StaticIdentity) Roles() []string

func (*StaticIdentity) Type

func (i *StaticIdentity) Type() string

func (*StaticIdentity) User

func (i *StaticIdentity) User() string

Jump to

Keyboard shortcuts

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