plugin

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.

Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.

Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.

Package plugin provides an easy way to create the required CLI for a plugin. It abstracts away all the command line and file parsing so users just need to implement the actual logic.

Please see the main BPM-SDK documentation for more details on how to implement a new plugin.

Index

Constants

View Source
const (
	ParameterTypeBool   = "bool"
	ParameterTypeString = "string"

	SupportsTest     = "test"
	SupportsUpgrade  = "upgrade"
	SupportsIdentity = "identity"
)
View Source
const (
	// ConfigsDirectory is the subdirectory under the node directory where configs are saved
	ConfigsDirectory = "configs"
)
View Source
const (
	// LogsDirectory is the subdirectory under the node directory where logs are saved
	LogsDirectory = "logs"
)

Variables

This section is empty.

Functions

func Initialize

func Initialize(plugin Plugin)

Initialize creates the CLI for a plugin

Types

type Configurator added in v0.10.0

type Configurator interface {
	// Function that creates the configuration for the node
	Configure(currentNode node.Node) error

	// Removes configuration related to the node
	RemoveConfig(currentNode node.Node) error
}

Configurator is the interface that wraps the Configure method

type DockerLifecycleHandler added in v0.10.0

type DockerLifecycleHandler struct {
	// contains filtered or unexported fields
}

DockerLifecycleHandler provides functions to manage a node using plain docker containers

func NewDockerLifecycleHandler added in v0.10.0

func NewDockerLifecycleHandler(containers []docker.Container) DockerLifecycleHandler

NewDockerLifecycleHandler creates an instance of DockerLifecycleHandler

func (DockerLifecycleHandler) RemoveData added in v0.10.0

func (d DockerLifecycleHandler) RemoveData(currentNode node.Node) error

RemoveData removes any data (typically the blockchain itself) related to the node

func (DockerLifecycleHandler) RemoveRuntime added in v0.10.0

func (d DockerLifecycleHandler) RemoveRuntime(currentNode node.Node) error

RemoveRuntime removes the docker network and containers

func (DockerLifecycleHandler) Start added in v0.10.0

func (d DockerLifecycleHandler) Start(currentNode node.Node) error

Start starts monitoring agents and delegates to another function to start blockchain containers

func (DockerLifecycleHandler) Status added in v0.10.0

func (d DockerLifecycleHandler) Status(currentNode node.Node) (string, error)

Status returns the status of the running blockchain client and monitoring containers

func (DockerLifecycleHandler) Stop added in v0.10.0

func (d DockerLifecycleHandler) Stop(currentNode node.Node) error

Stop removes all containers

type DockerPlugin

type DockerPlugin struct {
	ParameterValidator
	IdentityCreator
	Configurator
	LifecycleHandler
	Upgrader
	Tester
	// contains filtered or unexported fields
}

DockerPlugin is an implementation of the Plugin interface. It provides based functionality for a docker based plugin

func NewDockerPlugin

func NewDockerPlugin(name string, version string, description string, parameters []Parameter, templates map[string]string, containers []docker.Container) DockerPlugin

NewDockerPlugin creates a new instance of DockerPlugin

func (DockerPlugin) Meta

func (d DockerPlugin) Meta() MetaInfo

Meta returns the MetaInfo of a plugin

func (DockerPlugin) Name

func (d DockerPlugin) Name() string

Name returns the name of a plugin

type DockerUpgrader added in v0.10.0

type DockerUpgrader struct {
	// contains filtered or unexported fields
}

DockerUpgrader provides a default strategy for upgrading docker based nodes

The default upgrade strategy uses a LifecycleHandler to remove all containers. If they where running they get started again which will pull new container images.

This works as long as only the container versions change. If the the upgrade needs changes to the configs or migrations tasks it is recommended to provide a custom Upgrader.

func NewDockerUpgrader added in v0.10.0

func NewDockerUpgrader(containers []docker.Container) DockerUpgrader

NewDockerUpgrader instantiates DockerUpgrader

func (DockerUpgrader) Upgrade added in v0.10.0

func (d DockerUpgrader) Upgrade(currentNode node.Node) error

Upgrade upgrades all containers by removing and starting them again

type DummyTester added in v0.10.0

type DummyTester struct{}

DummyTester does nothing except panicking

This Tester can be used if the plugin doesn't support testing

func NewDummyTester added in v0.10.0

func NewDummyTester() DummyTester

func (DummyTester) Test added in v0.10.0

func (t DummyTester) Test(currentNode node.Node) (bool, error)

type FileConfigurator added in v0.10.0

type FileConfigurator struct {
	// contains filtered or unexported fields
}

FileConfigurator creates configuration files from templates

func NewFileConfigurator added in v0.10.0

func NewFileConfigurator(configFilesAndTemplates map[string]string) FileConfigurator

NewFileConfigurator creates an instance of FileConfigurator

func (FileConfigurator) Configure added in v0.10.0

func (d FileConfigurator) Configure(currentNode node.Node) error

Configure creates configuration files for the blockchain client

func (FileConfigurator) RemoveConfig added in v0.10.0

func (d FileConfigurator) RemoveConfig(currentNode node.Node) error

RemoveConfig removes configuration files related to the node

type IdentityCreator added in v0.10.0

type IdentityCreator interface {
	// Function that creates the identity of a node
	CreateIdentity(currentNode node.Node) error

	// Removes identity related to the node
	RemoveIdentity(currentNode node.Node) error
}

IdentityCreator provides functions to create and remove the identity (e.g. private keys) of a node

type LifecycleHandler added in v0.10.0

type LifecycleHandler interface {
	// Function to start a node
	Start(currentNode node.Node) error
	// Function to stop a running node
	Stop(currentNode node.Node) error
	// Function to return the status (running, incomplete, stopped) of a node
	Status(currentNode node.Node) (string, error)
	// Removes any data (typically the blockchain itself) related to the node
	RemoveData(currentNode node.Node) error
	// Removes everything other than data and configuration related to the node
	RemoveRuntime(currentNode node.Node) error
}

LifecycleHandler provides functions to manage a node

type MetaInfo

type MetaInfo struct {
	Name            string
	Version         string
	Description     string
	ProtocolVersion string `yaml:"protocol_version"`
	Parameters      []Parameter
	Supported       []string
}

func (MetaInfo) String

func (p MetaInfo) String() string

func (MetaInfo) Supports added in v0.10.0

func (p MetaInfo) Supports(supported string) bool

Supports returns bool if a particular method is supported

type Parameter

type Parameter struct {
	Type        string
	Name        string
	Description string
	Mandatory   bool
	Default     string
}

type ParameterValidator added in v0.10.0

type ParameterValidator interface {
	// ValidateParameters validates the ndoe parameters
	ValidateParameters(currentNode node.Node) error
}

ParameterValidator provides a function to validate the node parameters

type Plugin

type Plugin interface {
	// Returns the name of the plugin
	Name() string
	// Return plugin meta information such as: What's supported, possible parameters
	Meta() MetaInfo

	ParameterValidator
	IdentityCreator
	Configurator
	LifecycleHandler
	Upgrader
	Tester
}

Plugin describes and provides the functionality for a plugin

type SimpleParameterValidator added in v0.10.0

type SimpleParameterValidator struct {
	// contains filtered or unexported fields
}

SimpleParameterValidator is a simple validator

It checks if all parameters exist and if mandatory parameters have a value

func NewSimpleParameterValidator added in v0.10.0

func NewSimpleParameterValidator(pluginParameters []Parameter) SimpleParameterValidator

NewSimpleParameterValidator creates an instance of SimpleParameterValidator

func (SimpleParameterValidator) ValidateParameters added in v0.10.0

func (m SimpleParameterValidator) ValidateParameters(currentNode node.Node) error

ValidateParameters checks if mandatory parameters are passed in

type Tester added in v0.10.0

type Tester interface {
	// Function to test a node
	Test(currentNode node.Node) (bool, error)
}

Tester is the interface that wraps the Test method

type Upgrader added in v0.10.0

type Upgrader interface {
	// Function to upgrade a node with a new plugin version
	Upgrade(currentNode node.Node) error
}

Upgrader is the interface that wraps the Upgrade method

Jump to

Keyboard shortcuts

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