plugins

package
v1.0.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

plugin package contains interfaces for storage plugins.

Index

Constants

View Source
const PluginInterface = "storage"

PluginInterface for the data storage. This first part of the three-part plugin key is only seen/used by the plugins when the host is communicating with the plugin and is not exposed to users.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateOptions

type AggregateOptions struct {
	// Collection to query.
	Collection string

	// Pipeline document to aggregate, filter, and shape the results.
	// See https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/
	Pipeline interface{}
}

AggregateOptions is the set of options available to the StorageProtocol.Aggregate operation.

type CountOptions

type CountOptions struct {
	// Collection to query.
	Collection string

	// Query is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter interface{}
}

CountOptions is the set of options available to the StorageProtocol.Count operation.

type EnsureIndexOptions

type EnsureIndexOptions struct {
	// Indices to create if not found.
	Indices []Index
}

EnsureIndexOptions is the set of options available to the StorageProtocol.EnsureIndex operation.

type FindOptions

type FindOptions struct {
	// Collection to query.
	Collection string

	// Sort is a list of field names by which the results should be sorted.
	Sort interface{}

	// Skip is the number of results to skip past and exclude from the results.
	Skip int64

	// Limit is the number of results to return.
	Limit int64

	// Select is a projection document
	// See https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/
	Select interface{}

	// Filter specifies how to filter the results.
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter interface{}

	// Group specifies how to group the results.
	// See https://docs.mongodb.com/manual/reference/operator/aggregation/group/
	Group interface{}
}

FindOptions is the set of options available to the StorageProtocol.Find operation.

type Index

type Index struct {
	// Collection name to which the index applies.
	Collection string

	// Keys describes the fields and their sort order.
	// Example: {"namespace": 1, "name": 1}
	Keys interface{}

	// Unique specifies if the index should enforce that the indexed fields for each document are unique.
	Unique bool
}

Index on a collection.

type InsertOptions

type InsertOptions struct {
	// Collection to query.
	Collection string

	// Documents is a set of documents to insert.
	Documents []interface{}
}

InsertOptions is the set of options for the StorageProtocol.Insert operation.

type PatchOptions

type PatchOptions struct {
	// Collection to query.
	Collection string

	// Query is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	QueryDocument interface{}

	// Transformation is set of instructions to modify matching
	// documents.
	Transformation interface{}
}

PatchOptions is the set of options for the StorageProtocol.Patch operation.

type RemoveOptions

type RemoveOptions struct {
	// Collection to query.
	Collection string

	// Filter is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter interface{}

	// All matching documents should be removed. Defaults to false, which only
	// removes the first matching document.
	All bool
}

RemoveOptions is the set of options for the StorageProtocol.Remove operation.

type StoragePlugin

type StoragePlugin interface {
	plugins.Plugin
	StorageProtocol
}

StoragePlugin is the interface used to wrap a storage plugin. It is not meant to be used directly.

type StorageProtocol

type StorageProtocol interface {
	// EnsureIndex makes sure that the specified index exists as specified.
	// If it does exist with a different definition, the index is recreated.
	EnsureIndex(opts EnsureIndexOptions) error

	// Aggregate executes a pipeline and returns the results.
	Aggregate(opts AggregateOptions) ([]bson.Raw, error)

	// Count the number of results that match an optional query.
	// When the query is omitted, the entire collection is counted.
	Count(opts CountOptions) (int64, error)

	// Find queries a collection, optionally projecting a subset of fields, and
	// then returns the results as a list of bson documents.
	Find(opts FindOptions) ([]bson.Raw, error)

	// Insert a set of documents into a collection.
	Insert(opts InsertOptions) error

	// Patch applies a transformation to matching documents.
	Patch(opts PatchOptions) error

	// Remove matching documents from a collection.
	Remove(opts RemoveOptions) error

	// Update matching documents with the specified replacement document.
	Update(opts UpdateOptions) error
}

StorageProtocol is the interface that storage plugins must implement. This defines the protocol used to communicate with storage plugins.

type UpdateOptions

type UpdateOptions struct {
	// Collection to query.
	Collection string

	// Filter is a query filter document
	// See https://docs.mongodb.com/manual/core/document/#std-label-document-query-filter
	Filter interface{}

	// Upsert indicates that the document should be inserted if not found
	Upsert bool

	// Document is the replacement document.
	Document interface{}
}

UpdateOptions is the set of options for the StorageProtocol.Update operation.

Directories

Path Synopsis
Package mongodb_docker implements the plugins.StorageProtocol interface, storing data using an instance of mongodb running in a container, with the data stored in a docker volume.
Package mongodb_docker implements the plugins.StorageProtocol interface, storing data using an instance of mongodb running in a container, with the data stored in a docker volume.

Jump to

Keyboard shortcuts

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