plugins

package
v2.2.0-mercury-20230527 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 16 Imported by: 0

README

LOOP Plugins

⚠ Experimental ⚠

This directory supports Local-Out-Of-Process (LOOP) Plugins, an alternative node runtime where some systems execute in separate processes, plug-in via github.com/hashicorp/go-plugin, and communicate via GRPC.

There are currently two kinds of plugins, and one implementation of each: a Solana Relayer plugin, and a Median Reporting plugin. The cmd directory contains their package mains for now. These can be built via make install-solana and make install-median.

How to use

chainlink.Dockerfile extends the regular core/chainlink.Dockerfile to include the plugin binaries, and enables support by setting CL_SOLANA_CMD and CL_MEDIAN_CMD. Either plugin can be disabled by un-setting the environment variable, which will revert to the original in-process runtime. Images built from this Dockerfile can otherwise be used normally, provided that the pre-requisites have been met.

Pre-requisites
Timeouts

LOOPPs communicate over GRPC, which always includes a context.Context and requires realistic timeouts. Placeholder/dummy values (e.g. MaxDurationQuery = 0) will not work and must be updated to realistic values.

Prometheus

TODO how to preserve metrics https://smartcontract-it.atlassian.net/browse/BCF-2202

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("plugin already registered")

Functions

func NewLogger

func NewLogger(cfg LoggingConfig) (logger.Logger, func())

func SetCmdEnvFromConfig

func SetCmdEnvFromConfig(cmd *exec.Cmd, cfg EnvConfig)

SetCmdEnvFromConfig sets LOOP-specific vars in the env of the given cmd.

Types

type EnvConfig

type EnvConfig interface {
	LoggingConfig
	PrometheusPort() int
}

EnvConfig is the configuration interface between the application and the LOOP executable. The values are fully resolved and static and passed via the environment.

func GetEnvConfig

func GetEnvConfig() (EnvConfig, error)

GetEnvConfig deserializes LOOP-specific environment variables to an EnvConfig

func NewEnvConfig

func NewEnvConfig(lc LoggingConfig, prometheusPort int) EnvConfig

type LoggingConfig

type LoggingConfig interface {
	LogLevel() zapcore.Level
	JSONConsole() bool
	LogUnixTimestamps() bool
}

LoggingConfig controls static logging related configuration that is inherited from the chainlink application to the given LOOP executable.

func NewLoggingConfig

func NewLoggingConfig(level zapcore.Level, jsonConsole bool, unixTimestamps bool) LoggingConfig

type LoopRegistry

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

LoopRegistry is responsible for assigning ports to plugins that are to be used for the plugin's prometheus HTTP server

func NewLoopRegistry

func NewLoopRegistry() *LoopRegistry

func (*LoopRegistry) Get

func (m *LoopRegistry) Get(id string) (*RegisteredLoop, bool)

func (*LoopRegistry) List

func (m *LoopRegistry) List() []*RegisteredLoop

func (*LoopRegistry) Register

func (m *LoopRegistry) Register(id string, staticCfg LoggingConfig) (*RegisteredLoop, error)

Register creates a port of the plugin. It is idempotent. Duplicate calls to Register will return the same port

type PromServer

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

func NewPromServer

func NewPromServer(port int, lggr logger.Logger, opts ...PromServerOpt) *PromServer

func (*PromServer) Close

func (p *PromServer) Close() error

Close shutdowns down the underlying HTTP server. See http.Server.Close for details

func (*PromServer) Name

func (p *PromServer) Name() string

Name of the server

func (*PromServer) Port

func (p *PromServer) Port() int

Port is the resolved port and is only known after Start(). returns -1 before it is resolved or if there was an error during resolution.

func (*PromServer) Start

func (p *PromServer) Start() error

Start start HTTP server on specified port to handle metrics requests

type PromServerOpt

type PromServerOpt func(*PromServer)

func WithRegistry

func WithRegistry(r *prometheus.Registry) PromServerOpt

type RegisteredLoop

type RegisteredLoop struct {
	Name   string
	EnvCfg EnvConfig
}

type RegistrarConfig

type RegistrarConfig interface {
	LoggingConfig
	RegisterLOOP(loopId string) (*RegisteredLoop, error)
}

RegistrarConfig generates contains static configuration inher

func NewRegistrarConfig

func NewRegistrarConfig(lc LoggingConfig, loopRegistrationFn func(loopId string, loopStaticCfg LoggingConfig) (*RegisteredLoop, error)) RegistrarConfig

NewRegistrarConfig creates a RegistarConfig loopRegistrationFn must act as a global registry function of LOOPs and must be idempotent. The EnvConfig for a LOOP should be generated by calling [RegistrarConfig.RegisterLOOP]

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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