module

package
v0.15.10 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteRequest

type ExecuteRequest struct {
	// Params are the invocation parameters specific to the module
	Params interface{}

	// Providers is the list of providers to process
	Providers []*cqproto.GetProviderSchemaResponse
	// Conn is the db connection to use
	Conn *pgxpool.Conn
}

type ExecutionResult

type ExecutionResult struct {
	Result   interface{} `json:"result"`
	Error    error       `json:"-"`
	ErrorMsg string      `json:"error,omitempty"`
}

type Manager

type Manager interface {
	// RegisterModule is used to register a module into the manager.
	RegisterModule(mod Module)

	// ExecuteModule executes the given module, validating the given module name and config first.
	ExecuteModule(ctx context.Context, modName, modConfigPath string, execReq *ExecuteRequest) (*ExecutionResult, error)

	// ReadConfig reads the given module's default/builtin config
	ReadConfig(modName string) ([]byte, error)
}

Manager is the interface that describes the interaction with the module manager. Implemented by ManagerImpl.

type ManagerImpl

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

ManagerImpl is the manager implementation struct.

func NewManager

func NewManager(pool *pgxpool.Pool, logger hclog.Logger) *ManagerImpl

NewManager returns a new manager instance.

func (*ManagerImpl) ExecuteModule

func (m *ManagerImpl) ExecuteModule(ctx context.Context, modName, modConfigPath string, execReq *ExecuteRequest) (*ExecutionResult, error)

ExecuteModule executes the given module, validating the given module name and config first.

func (*ManagerImpl) ReadConfig

func (m *ManagerImpl) ReadConfig(modName string) ([]byte, error)

ReadConfig reads the given module's default/builtin config

func (*ManagerImpl) RegisterModule

func (m *ManagerImpl) RegisterModule(mod Module)

RegisterModule is used to register a module into the manager.

type Module

type Module interface {
	// ID returns the name of the module
	ID() string
	// Configure configures the module to run
	Configure(context.Context, hcl.Body) error
	// Execute executes the module, using given args in ExecuteRequest
	Execute(context.Context, *ExecuteRequest) *ExecutionResult
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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