Documentation ¶
Index ¶
- type BasicRegistry
- func (b *BasicRegistry) MatchPlugins() []MatchPlugin
- func (b *BasicRegistry) MockPlugins() []MockPlugin
- func (b *BasicRegistry) RegisterMatchPlugins(plugins ...MatchPlugin) error
- func (b *BasicRegistry) RegisterMockPlugins(plugins ...MockPlugin) error
- func (b *BasicRegistry) RegisterStoragePlugin(plugin StoragePlugin) error
- func (b *BasicRegistry) StoragePlugin() StoragePlugin
- type Config
- type MatchPlugin
- type MockPlugin
- type Plugin
- type Registry
- type StoragePlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicRegistry ¶
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 (*Config) RegisterFlagsWithPrefix ¶
RegisterFlagsWithPrefix is used to register flags
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