Documentation
¶
Overview ¶
Package api defines the interfaces that are implemented by plugins. Some of them are optional - see comments below.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constraints ¶ added in v0.9.3
type Constraints struct {
// Min is the minimum number of plugins required of a specific type. If
// zero, there is no lower bound (i.e. the plugin type is optional).
Min int
// Max is the maximum number of plugins required of a specific type. If
// zero, there is no upper bound.
Max int
}
func AtLeastOne ¶ added in v0.9.3
func AtLeastOne() Constraints
func ExactlyOne ¶ added in v0.9.3
func ExactlyOne() Constraints
func MaybeOne ¶ added in v0.9.3
func MaybeOne() Constraints
func ZeroOrMore ¶ added in v0.9.3
func ZeroOrMore() Constraints
func (Constraints) Check ¶ added in v0.9.3
func (c Constraints) Check(count int) error
type Facade ¶ added in v0.9.3
type Facade interface {
// ServiceClient is used to initialize the service client with the
// connection to the plugin providing the service server.
ServiceClient
// InitInfo is used to initialize the facade with information for the
// loaded plugin providing the service server.
InitInfo(info Info)
// InitLog initializes the facade with the logger for the loaded plugin
// that provides the service server.
InitLog(log *slog.Logger)
Version() uint
}
Facade is a facade for a specific plugin or service version.
type Info ¶ added in v0.9.3
type Info interface {
// The name of the plugin
Name() string
// The type of the plugin
Type() string
// Tags associated with the plugin
Tags() []string
// Build of the plugin
Build() string
// Version of the plugin
Version() uint
}
Info provides the information for the loaded plugin.
type NeedsHostServices ¶
type NeedsHostServices interface {
// BrokerHostServices is invoked by the plugin loader and provides a broker
// that can be used by plugins/services to initialize clients to host
// services. If an error is returned, plugin loading will fail.
// This gives server implementations control over whether or not the
// absence of a particular host service is a catastrophic failure.
BrokerHostServices(ServiceBroker) error
}
NeedsHostServices enables a plugin implementation to receive a service broker from the plugin loader during plugin initialization. The implementation is optional.
type NeedsLogger ¶
NeedsLogger enables a plugin implementation to receive a logger from the plugin loader during plugin initialization. The implementation is optional.
type PluginClient ¶
type PluginClient interface {
ServiceClient
// Type returns the type of plugin
Type() string
}
PluginClient defines the server side of a plugin. The necessary code is generated by protoc-gen-go-extension. See proto/plugin/authz/v1 for an example.
type PluginRepo ¶ added in v0.9.3
type PluginRepo interface {
ServiceRepo
// Constraints returns the constraints required by the plugin repository.
// The Load function will ensure that these constraints are satisfied before
// returning successfully.
Constraints() Constraints
}
PluginRepo is a repository of plugin facades for a given plugin type.
type PluginServer ¶
type PluginServer interface {
ServiceServer
// Type returns the type of plugin
Type() string
}
PluginServer defines the server side of a plugin. The necessary code is generated by protoc-gen-go-extension. See proto/plugin/authz/v1 for an example.
type Repository ¶ added in v0.9.3
type Repository interface {
// Plugins returns a map of plugin repositories, keyed by the plugin type.
Plugins() map[string]PluginRepo
// Services returns service repositories.
Services() []ServiceRepo
}
Repository is a set of plugin and service repositories.
type ServiceBroker ¶
type ServiceBroker interface {
// BrokerClient initializes the passed in host service client. If the
// host service is not available, the host service client will
// remain uninitialized and the function will return false.
BrokerClient(ServiceClient) bool
}
type ServiceClient ¶
type ServiceClient interface {
// GRPCServiceName returns the full gRPC service name (e.g.
GRPCServiceName() string
// InitClient initializes the client using the given gRPC client
// connection. It returns the client implementation that was initialized.
InitClient(conn grpc.ClientConnInterface) any
}
ServiceClient defines the client side of a service, which can be embedded by a PluginClient. It is used to define shared functionality in a proto definition, which does not make up a plugin on its own. The necessary code is generated by protoc-gen-go-extension. See proto/service/common/config/v1 for an example.
type ServiceRepo ¶ added in v0.9.3
type ServiceRepo interface {
// Binder returns a function that is used by the catalog system to "bind"
// the facade returned by selected version to the repository. It MUST
// return void and take a single argument of type X, where X can be
// assigned to by any of the facade implementation types returned by the
// provided versions (see Versions).
Binder() any
// Versions returns the versions supported by the repository, ordered by
// most to least preferred. The first version supported by the plugin will
// be used. When a deprecated version is bound, warning messaging will
// recommend the first version in the list as a replacement, unless it is
// also deprecated.
Versions() []Version
// Clear is called when loading fails to clear the repository of any
// previously bound facades.
Clear()
}
ServiceRepo is a repository for service facades for a given service.
type ServiceServer ¶
type ServiceServer interface {
// GRPCServiceName returns the full gRPC service name (e.g.
GRPCServiceName() string
// RegisterServer registers the server implementation with the given gRPC server.
// It returns the implementation that was registered.
RegisterServer(server *grpc.Server) any
}
ServiceServer defines the server side of a service, which can be embedded by a PluginServer. It is used to define shared functionality in a proto definition, which does not make up a plugin on its own. The necessary code is generated by protoc-gen-go-extension. See proto/service/common/config/v1 for an example.
type Version ¶ added in v0.9.3
type Version interface {
// New returns a new facade for this version. Instantiated facades are only
// bound via the repo binder when they match a gRPC service name provided
// by the plugin.
New() Facade
Deprecated() bool
}
Version represents a plugin or service version. It is used to instantiate facades for the versions that are bound to the plugin or service repositories (see the Binder method on the ServiceRepo).