pluginregistry

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicRegistry

type BasicRegistry struct {
	logger.Logger
	// contains filtered or unexported fields
}

BasicRegistry is the basic implementation of pluginRegistry

func (*BasicRegistry) MatchPlugins

func (b *BasicRegistry) MatchPlugins() []MatchPlugin

RegisterMatchPlugins is used to register match plugins

func (*BasicRegistry) MockPlugins

func (b *BasicRegistry) MockPlugins() []MockPlugin

MockPlugins is used to return all registered mock plugins

func (*BasicRegistry) RegisterMatchPlugins

func (b *BasicRegistry) RegisterMatchPlugins(plugins ...MatchPlugin) error

MockPlugins is used to return all registered match plugins

func (*BasicRegistry) RegisterMockPlugins

func (b *BasicRegistry) RegisterMockPlugins(plugins ...MockPlugin) error

RegisterMockPlugins is used to register mock plugins

func (*BasicRegistry) RegisterStoragePlugin

func (b *BasicRegistry) RegisterStoragePlugin(plugin StoragePlugin) error

RegisterStoragePlugin is used to register storage plugins

func (*BasicRegistry) StoragePlugin

func (b *BasicRegistry) StoragePlugin() StoragePlugin

MockPlugins is used to return storage plugins

type Config

type Config struct{}

Config defines the config structure

func NewConfig

func NewConfig() *Config

NewConfig is used to init config with default values

func (*Config) RegisterFlagsWithPrefix

func (c *Config) RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet)

RegisterFlagsWithPrefix is used to register flags

func (*Config) Validate

func (c *Config) Validate() error

Validate is used to validate config and returns error on failure

type MatchPlugin

type MatchPlugin interface {
	Plugin
	Match(ctx context.Context, request *interact.Request, condition *v1alpha1.MockAPI_Condition) (match bool, err error)
}

MatchPlugin defines matching plugins It is used to determine whether interact.Request satisfies the matching condition of MockAPI_Condition

type MockPlugin

type MockPlugin interface {
	Plugin
	MockResponse(ctx context.Context, mock *v1alpha1.MockAPI_Response, request *interact.Request, response *interact.Response) (abort bool, err error)
}

MockPlugin defines the Mock plugin It is used to generate interact.Response according to the given MockAPI_Response and interact.Request

type Plugin

type Plugin interface {
	Name() string
}

Plugin defines the most basic requirements for plug-ins All plugins should implement this interface

type Registry

type Registry interface {
	// MockPlugins is used to return all registered mock plugins
	MockPlugins() []MockPlugin
	// RegisterMockPlugins is used to register mock plugins
	RegisterMockPlugins(...MockPlugin) error

	// MockPlugins is used to return all registered match plugins
	MatchPlugins() []MatchPlugin
	// RegisterMatchPlugins is used to register match plugins
	RegisterMatchPlugins(...MatchPlugin) error

	// MockPlugins is used to return storage plugins
	StoragePlugin() StoragePlugin
	// RegisterStoragePlugin is used to register storage plugin
	RegisterStoragePlugin(StoragePlugin) error
}

Registry defines the management center of Plugins

func New

func New(cfg *Config, logger logger.Logger, registerer prometheus.Registerer) (Registry, error)

New is used to init service

type StoragePlugin

type StoragePlugin interface {
	Plugin
	// Set is used to set key-val pair
	Set(ctx context.Context, key string, val string) error
	// Delete is used to delete specified key
	Delete(ctx context.Context, key string) error
	// List is used to list all key-val pairs in storage
	List(ctx context.Context) (map[string]string, error)
	// GetAnnouncement is used to get announcement
	// When events such as DELETE/SET are monitored,
	// the chan returned by GetAnnouncement will be able to read the event.
	// GetAnnouncement can only be called once
	GetAnnouncement() chan struct{}
	// Start is used to start the storage plugin
	Start(ctx context.Context, cancelFunc context.CancelFunc) error
}

StoragePlugin defines the storage plugin

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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