Skip to content

Plugin Developer

Ben McClelland edited this page Jun 6, 2025 · 1 revision

Plugins Need to implement the plugins.BackendPlugin interface.

// BackendPlugin defines an interface for creating backend
// implementation instances.
// Plugins implementing this interface can be built as shared
// libraries using Go's plugin system (to build use `go build -buildmode=plugin`).
// The shared library should export an instance of
// this interface in a variable named `Backend`.
type BackendPlugin interface {
	// New creates and initializes a new backend.Backend instance.
	// The config parameter specifies the path of the file containing
	// the configuration for the backend.
	//
	// Implementations of this method should perform the necessary steps to
	// establish a connection to the underlying storage system or service
	// (e.g., network storage system, distributed storage system, cloud storage)
	//  and configure it according to the provided configuration.
	New(config string) (backend.Backend, error)
}

https://github.com/versity/versitygw/blob/main/plugins/plugins.go

The New() function takes a string that can be used as the location of a config file needed to configure options specific to the plugin. The New() function must match the above function signature exactly, including the returned backend.Backend type for the version of the gateway trying to load the plugin. If any changes are made to backend.Backend in newer versitygw releases, the older plugins will no longer be compatible. The teams makes an effort to minimize changes to this interface, but minor changes are sometimes required for AWS S3 compatibility.

See https://pkg.go.dev/plugin for details on the GO plugin system.

See Also Adding-A-New-Backend for details on implementing the backend.Backend interface within the plugin.

Clone this wiki locally