pluggable

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MPL-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PluginHandshakeConfig holds configuration for plugin.GRPCPlugin.
	PluginHandshakeConfig = plugin.HandshakeConfig{
		MagicCookieKey:   "BASIC_PLUGIN",
		MagicCookieValue: "Hello",
	}
)

Functions

func Consume

func Consume(logger hclog.Logger, queue <-chan common.Pair[[]*proto.CoverageItem, error]) ([]*proto.CoverageItem, error)

Consume aggregates CoverageItems from multi publishers.

func Publish

func Publish(wg *sync.WaitGroup, logger hclog.Logger, p Pluggable, filenames []string, excluded filepath.ExcludeFileSet, queue chan<- common.Pair[[]*proto.CoverageItem, error])

Publish receive a list of target files and call the plugin MeasureCoverage logic.

Types

type CommentcovPlugin

type CommentcovPlugin struct {
	plugin.Plugin

	Impl Pluggable
}

CommentcovPlugin implements plugin.GRPCPlugin.

func (*CommentcovPlugin) GRPCClient

func (p *CommentcovPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, conn *grpc.ClientConn) (interface{}, error)

GRPCClient is a part of plugin.GRPCPlugin interface.

func (*CommentcovPlugin) GRPCServer

func (p *CommentcovPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer is a part of plugin.GRPCPlugin interface.

type GRPCClient

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

GRPCClient is the interface to be called from the host.

func (*GRPCClient) MeasureCoverage

func (c *GRPCClient) MeasureCoverage(files []string) ([]*proto.CoverageItem, error)

MeasureCoverage implements Pluggable.

type GRPCServer

type GRPCServer struct {
	proto.UnimplementedCommentcovPluginServer

	Impl Pluggable
}

GRPCServer Dependency(Plugin Implementation) Injected Object.

func (*GRPCServer) MeasureCoverage

MeasureCoverage calls the Pluggable implementation via gRPC.

type Pluggable

type Pluggable interface {
	MeasureCoverage(files []string) ([]*proto.CoverageItem, error)
}

Pluggable is the interface. Each plugin implements Pluggable interface via gRPC.

func GetPluginFromClient

func GetPluginFromClient(client *plugin.Client, pluginName string) (Pluggable, error)

GetPluginFromClient returns Pluggable object.

type PluginConfig

type PluginConfig struct {
	Extension      string
	InstallCommand string `mapstructure:"install_command"`
	ExecuteCommand string `mapstructure:"execute_command"`
}

PluginConfig represents commentcov plugin info.

func FindPluginConfig

func FindPluginConfig(pcs []PluginConfig, ext string) *PluginConfig

FindPluginConfig returns the first matched plugin's PluginConfig by the extension.

func (*PluginConfig) GetExecuteCommand

func (pc *PluginConfig) GetExecuteCommand() *exec.Cmd

GetExecuteCommand returns *exec.Cmd to execute the plugin.

func (*PluginConfig) GetInstallCommand

func (pc *PluginConfig) GetInstallCommand() *exec.Cmd

GetInstallCommand returns *exec.Cmd to install the plugin.

func (*PluginConfig) Install

func (pc *PluginConfig) Install() error

Install installs the plugin for setup.

func (*PluginConfig) Name

func (pc *PluginConfig) Name() string

Name returns the name.

Jump to

Keyboard shortcuts

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