feeds

package
v2.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobTypeFluxMonitor        = "fluxmonitor"
	JobTypeOffchainReporting  = "ocr"
	JobTypeOffchainReporting2 = "ocr2"
)

Variables

View Source
var (
	ErrOCR2Disabled         = errors.New("ocr2 is disabled")
	ErrOCRDisabled          = errors.New("ocr is disabled")
	ErrSingleFeedsManager   = errors.New("only a single feeds manager is supported")
	ErrJobAlreadyExists     = errors.New("a job for this contract address already exists - please use the 'force' option to replace it")
	ErrFeedsManagerDisabled = errors.New("feeds manager is disabled")
)

Functions

func FromPluginTypeInput

func FromPluginTypeInput(pt PluginType) string

func NewORM

func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig) *orm

func NewService

func NewService(
	orm ORM,
	jobORM job.ORM,
	db *sqlx.DB,
	jobSpawner job.Spawner,
	keyStore keystore.Master,
	cfg Config,
	chainSet evm.ChainSet,
	lggr logger.Logger,
	version string,
) *service

NewService constructs a new feeds service

Types

type ChainConfig

type ChainConfig struct {
	ID                int64
	FeedsManagerID    int64
	ChainID           string
	ChainType         ChainType
	AccountAddress    string
	AdminAddress      string
	FluxMonitorConfig FluxMonitorConfig
	OCR1Config        OCR1Config
	OCR2Config        OCR2Config
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

ChainConfig defines the chain configuration for a Feeds Manager.

type ChainType

type ChainType string
const (
	ChainTypeUnknown ChainType = "UNKNOWN"
	ChainTypeEVM     ChainType = "EVM"
)

func NewChainType

func NewChainType(s string) (ChainType, error)

type Config

type Config interface {
	pg.QConfig
	config.OCR2Config
	Dev() bool
	FeatureOffchainReporting() bool
	FeatureOffchainReporting2() bool
	DefaultHTTPTimeout() models.Duration
	JobPipelineResultWriteQueueDepth() uint64
	JobPipelineMaxSuccessfulRuns() uint64
}

type ConnectOpts

type ConnectOpts struct {
	FeedsManagerID int64

	// URI is the URI of the feeds manager
	URI string

	// Privkey defines the local CSA private key
	Privkey []byte

	// Pubkey defines the Feeds Manager Service's public key
	Pubkey []byte

	// Handlers defines the wsrpc Handlers
	Handlers pb.NodeServiceServer

	// OnConnect defines a callback for when the dial succeeds
	OnConnect func(pb.FeedsManagerClient)
}

ConnectOpts defines the required options to connect to an FMS server

type ConnectionsManager

type ConnectionsManager interface {
	Connect(opts ConnectOpts)
	Disconnect(id int64) error
	Close()
	GetClient(id int64) (pb.FeedsManagerClient, error)
	IsConnected(id int64) bool
}

type DeleteJobArgs

type DeleteJobArgs struct {
	FeedsManagerID int64
	RemoteUUID     uuid.UUID
}

DeleteJobArgs are the arguments to provide to the DeleteJob method.

type FeedsManager

type FeedsManager struct {
	ID                 int64
	Name               string
	URI                string
	PublicKey          crypto.PublicKey
	IsConnectionActive bool
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

FeedsManager defines a registered Feeds Manager Service and the connection information.

type FluxMonitorConfig

type FluxMonitorConfig struct {
	Enabled bool `json:"enabled"`
}

FluxMonitorConfig defines configuration for FluxMonitorJobs.

func (*FluxMonitorConfig) Scan

func (c *FluxMonitorConfig) Scan(value interface{}) error

func (FluxMonitorConfig) Value

func (c FluxMonitorConfig) Value() (driver.Value, error)

type JobProposal

type JobProposal struct {
	ID             int64
	Name           null.String
	RemoteUUID     uuid.UUID // RemoteUUID is the uuid of the proposal in FMS.
	Status         JobProposalStatus
	ExternalJobID  uuid.NullUUID // ExternalJobID is the external job id in the job spec.
	FeedsManagerID int64
	Multiaddrs     pq.StringArray
	PendingUpdate  bool
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

JobProposal represents a proposal which has been sent by a Feeds Manager.

A job proposal has multiple spec versions which are created each time the Feeds Manager sends a new proposal version.

type JobProposalCounts

type JobProposalCounts struct {
	Pending   int64
	Cancelled int64
	Approved  int64
	Rejected  int64
}

JobProposalCounts defines the counts for job proposals of each status.

type JobProposalSpec

type JobProposalSpec struct {
	ID              int64
	Definition      string
	Status          SpecStatus
	Version         int32
	JobProposalID   int64
	StatusUpdatedAt time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

JobProposalSpec defines a versioned proposed spec for a JobProposal.

func (*JobProposalSpec) CanEditDefinition

func (s *JobProposalSpec) CanEditDefinition() bool

CanEditDefinition checks if the spec definition can be edited.

type JobProposalStatus

type JobProposalStatus string

JobProposalStatus are the status codes that define the stage of a proposal

const (
	JobProposalStatusPending   JobProposalStatus = "pending"
	JobProposalStatusApproved  JobProposalStatus = "approved"
	JobProposalStatusRejected  JobProposalStatus = "rejected"
	JobProposalStatusCancelled JobProposalStatus = "cancelled"
	JobProposalStatusDeleted   JobProposalStatus = "deleted"
	JobProposalStatusRevoked   JobProposalStatus = "revoked"
)

type NullService

type NullService struct{}

NullService defines an implementation of the Feeds Service that is used when the Feeds Service is disabled.

func (NullService) ApproveSpec

func (ns NullService) ApproveSpec(ctx context.Context, id int64, force bool) error

func (NullService) CancelSpec

func (ns NullService) CancelSpec(ctx context.Context, id int64) error

func (NullService) Close

func (ns NullService) Close() error

func (NullService) CountJobProposalsByStatus

func (ns NullService) CountJobProposalsByStatus() (*JobProposalCounts, error)

func (NullService) CountManagers

func (ns NullService) CountManagers() (int64, error)

func (NullService) CreateChainConfig

func (ns NullService) CreateChainConfig(ctx context.Context, cfg ChainConfig) (int64, error)

func (NullService) DeleteChainConfig

func (ns NullService) DeleteChainConfig(ctx context.Context, id int64) (int64, error)

func (NullService) DeleteJob

func (ns NullService) DeleteJob(ctx context.Context, args *DeleteJobArgs) (int64, error)

func (NullService) GetChainConfig

func (ns NullService) GetChainConfig(id int64) (*ChainConfig, error)

func (NullService) GetJobProposal

func (ns NullService) GetJobProposal(id int64) (*JobProposal, error)

func (NullService) GetManager

func (ns NullService) GetManager(id int64) (*FeedsManager, error)

func (NullService) GetSpec

func (ns NullService) GetSpec(id int64) (*JobProposalSpec, error)

func (NullService) IsJobManaged

func (ns NullService) IsJobManaged(ctx context.Context, jobID int64) (bool, error)

func (NullService) ListChainConfigsByManagerIDs

func (ns NullService) ListChainConfigsByManagerIDs(mgrIDs []int64) ([]ChainConfig, error)

func (NullService) ListJobProposals

func (ns NullService) ListJobProposals() ([]JobProposal, error)

func (NullService) ListJobProposalsByManagersIDs

func (ns NullService) ListJobProposalsByManagersIDs(ids []int64) ([]JobProposal, error)

func (NullService) ListManagers

func (ns NullService) ListManagers() ([]FeedsManager, error)

func (NullService) ListManagersByIDs

func (ns NullService) ListManagersByIDs(ids []int64) ([]FeedsManager, error)

func (NullService) ListSpecsByJobProposalIDs

func (ns NullService) ListSpecsByJobProposalIDs(ids []int64) ([]JobProposalSpec, error)

func (NullService) ProposeJob

func (ns NullService) ProposeJob(ctx context.Context, args *ProposeJobArgs) (int64, error)

func (NullService) RegisterManager

func (ns NullService) RegisterManager(ctx context.Context, params RegisterManagerParams) (int64, error)

func (NullService) RejectSpec

func (ns NullService) RejectSpec(ctx context.Context, id int64) error

func (NullService) RevokeJob

func (ns NullService) RevokeJob(ctx context.Context, args *RevokeJobArgs) (int64, error)

func (NullService) Start

func (ns NullService) Start(ctx context.Context) error

func (NullService) SyncNodeInfo

func (ns NullService) SyncNodeInfo(ctx context.Context, id int64) error

func (NullService) Unsafe_SetConnectionsManager

func (ns NullService) Unsafe_SetConnectionsManager(_ ConnectionsManager)

func (NullService) UpdateChainConfig

func (ns NullService) UpdateChainConfig(ctx context.Context, cfg ChainConfig) (int64, error)

func (NullService) UpdateManager

func (ns NullService) UpdateManager(ctx context.Context, mgr FeedsManager) error

func (NullService) UpdateSpecDefinition

func (ns NullService) UpdateSpecDefinition(ctx context.Context, id int64, spec string) error

type OCR1Config

type OCR1Config struct {
	Enabled     bool        `json:"enabled"`
	IsBootstrap bool        `json:"is_bootstrap"`
	Multiaddr   null.String `json:"multiaddr"`
	P2PPeerID   null.String `json:"p2p_peer_id"`
	KeyBundleID null.String `json:"key_bundle_id"`
}

OCR1Config defines configuration for OCR1 Jobs.

func (*OCR1Config) Scan

func (c *OCR1Config) Scan(value interface{}) error

func (OCR1Config) Value

func (c OCR1Config) Value() (driver.Value, error)

type OCR2Config

type OCR2Config struct {
	Enabled     bool        `json:"enabled"`
	IsBootstrap bool        `json:"is_bootstrap"`
	Multiaddr   null.String `json:"multiaddr"`
	P2PPeerID   null.String `json:"p2p_peer_id"`
	KeyBundleID null.String `json:"key_bundle_id"`
	Plugins     Plugins     `json:"plugins"`
}

OCR2Config defines configuration for OCR2 Jobs.

func (*OCR2Config) Scan

func (c *OCR2Config) Scan(value interface{}) error

func (OCR2Config) Value

func (c OCR2Config) Value() (driver.Value, error)

type ORM

type ORM interface {
	CountManagers() (int64, error)
	CreateManager(ms *FeedsManager, qopts ...pg.QOpt) (int64, error)
	GetManager(id int64) (*FeedsManager, error)
	ListManagers() (mgrs []FeedsManager, err error)
	ListManagersByIDs(ids []int64) ([]FeedsManager, error)
	UpdateManager(mgr FeedsManager, qopts ...pg.QOpt) error

	CreateBatchChainConfig(cfgs []ChainConfig, qopts ...pg.QOpt) ([]int64, error)
	CreateChainConfig(cfg ChainConfig, qopts ...pg.QOpt) (int64, error)
	DeleteChainConfig(id int64) (int64, error)
	GetChainConfig(id int64) (*ChainConfig, error)
	ListChainConfigsByManagerIDs(mgrIDs []int64) ([]ChainConfig, error)
	UpdateChainConfig(cfg ChainConfig) (int64, error)

	CountJobProposals() (int64, error)
	CountJobProposalsByStatus() (counts *JobProposalCounts, err error)
	CreateJobProposal(jp *JobProposal) (int64, error)
	DeleteProposal(id int64, qopts ...pg.QOpt) error
	GetJobProposal(id int64, qopts ...pg.QOpt) (*JobProposal, error)
	GetJobProposalByRemoteUUID(uuid uuid.UUID) (*JobProposal, error)
	ListJobProposals() (jps []JobProposal, err error)
	ListJobProposalsByManagersIDs(ids []int64, qopts ...pg.QOpt) ([]JobProposal, error)
	UpdateJobProposalStatus(id int64, status JobProposalStatus, qopts ...pg.QOpt) error // NEEDED?
	UpsertJobProposal(jp *JobProposal, qopts ...pg.QOpt) (int64, error)

	ApproveSpec(id int64, externalJobID uuid.UUID, qopts ...pg.QOpt) error
	CancelSpec(id int64, qopts ...pg.QOpt) error
	CreateSpec(spec JobProposalSpec, qopts ...pg.QOpt) (int64, error)
	ExistsSpecByJobProposalIDAndVersion(jpID int64, version int32, qopts ...pg.QOpt) (exists bool, err error)
	GetApprovedSpec(jpID int64, qopts ...pg.QOpt) (*JobProposalSpec, error)
	GetLatestSpec(jpID int64) (*JobProposalSpec, error)
	GetSpec(id int64, qopts ...pg.QOpt) (*JobProposalSpec, error)
	ListSpecsByJobProposalIDs(ids []int64, qopts ...pg.QOpt) ([]JobProposalSpec, error)
	RejectSpec(id int64, qopts ...pg.QOpt) error
	RevokeSpec(id int64, qopts ...pg.QOpt) error
	UpdateSpecDefinition(id int64, spec string, qopts ...pg.QOpt) error

	IsJobManaged(jobID int64, qopts ...pg.QOpt) (bool, error)
}

type PluginType

type PluginType string
const (
	PluginTypeCommit  PluginType = "COMMIT"
	PluginTypeExecute PluginType = "EXECUTE"
	PluginTypeMedian  PluginType = "MEDIAN"
	PluginTypeMercury PluginType = "MERCURY"
	PluginTypeUnknown PluginType = "UNKNOWN"
)

func ToPluginType

func ToPluginType(s string) (PluginType, error)

type Plugins

type Plugins struct {
	Commit  bool `json:"commit"`
	Execute bool `json:"execute"`
	Median  bool `json:"median"`
	Mercury bool `json:"mercury"`
}

func (*Plugins) Scan

func (p *Plugins) Scan(value interface{}) error

func (Plugins) Value

func (p Plugins) Value() (driver.Value, error)

type ProposeJobArgs

type ProposeJobArgs struct {
	FeedsManagerID int64
	RemoteUUID     uuid.UUID
	Multiaddrs     pq.StringArray
	Version        int32
	Spec           string
}

ProposeJobArgs are the arguments to provide to the ProposeJob method.

type RPCHandlers

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

RPCHandlers define handlers for RPC method calls from the Feeds Manager

func NewRPCHandlers

func NewRPCHandlers(svc Service, feedsManagerID int64) *RPCHandlers

func (*RPCHandlers) DeleteJob

DeleteJob deletes a job proposal record.

func (*RPCHandlers) ProposeJob

ProposeJob creates a new job proposal record for the feeds manager

func (*RPCHandlers) RevokeJob

RevokeJob revokes a pending job proposal record.

type RegisterManagerParams

type RegisterManagerParams struct {
	Name         string
	URI          string
	PublicKey    crypto.PublicKey
	ChainConfigs []ChainConfig
}

type RevokeJobArgs

type RevokeJobArgs struct {
	FeedsManagerID int64
	RemoteUUID     uuid.UUID
}

RevokeJobArgs are the arguments to provide the RevokeJob method

type Service

type Service interface {
	Start(ctx context.Context) error
	Close() error

	CountManagers() (int64, error)
	GetManager(id int64) (*FeedsManager, error)
	ListManagers() ([]FeedsManager, error)
	ListManagersByIDs(ids []int64) ([]FeedsManager, error)
	RegisterManager(ctx context.Context, params RegisterManagerParams) (int64, error)
	UpdateManager(ctx context.Context, mgr FeedsManager) error

	CreateChainConfig(ctx context.Context, cfg ChainConfig) (int64, error)
	DeleteChainConfig(ctx context.Context, id int64) (int64, error)
	GetChainConfig(id int64) (*ChainConfig, error)
	ListChainConfigsByManagerIDs(mgrIDs []int64) ([]ChainConfig, error)
	UpdateChainConfig(ctx context.Context, cfg ChainConfig) (int64, error)

	DeleteJob(ctx context.Context, args *DeleteJobArgs) (int64, error)
	IsJobManaged(ctx context.Context, jobID int64) (bool, error)
	ProposeJob(ctx context.Context, args *ProposeJobArgs) (int64, error)
	RevokeJob(ctx context.Context, args *RevokeJobArgs) (int64, error)
	SyncNodeInfo(ctx context.Context, id int64) error

	CountJobProposalsByStatus() (*JobProposalCounts, error)
	GetJobProposal(id int64) (*JobProposal, error)
	ListJobProposals() ([]JobProposal, error)
	ListJobProposalsByManagersIDs(ids []int64) ([]JobProposal, error)

	ApproveSpec(ctx context.Context, id int64, force bool) error
	CancelSpec(ctx context.Context, id int64) error
	GetSpec(id int64) (*JobProposalSpec, error)
	ListSpecsByJobProposalIDs(ids []int64) ([]JobProposalSpec, error)
	RejectSpec(ctx context.Context, id int64) error
	UpdateSpecDefinition(ctx context.Context, id int64, spec string) error

	Unsafe_SetConnectionsManager(ConnectionsManager)
}

Service represents a behavior of the feeds service

type SpecStatus

type SpecStatus string

SpecStatus is the status of each proposed spec.

const (
	// SpecStatusPending defines a spec status which has been proposed by the
	// FMS.
	SpecStatusPending SpecStatus = "pending"
	// SpecStatusApproved defines a spec status which the node op has approved.
	// An approved spec is currently being run by the node.
	SpecStatusApproved SpecStatus = "approved"
	// SpecStatusRejected defines a spec status which was proposed, but was
	// rejected by the node op.
	SpecStatusRejected SpecStatus = "rejected"
	// SpecStatusCancelled defines a spec status which was previously approved,
	// but cancelled by the node op. A cancelled spec is not being run by the
	// node.
	SpecStatusCancelled SpecStatus = "cancelled"
	// SpecStatusRevoked defines a spec status which was revoked. A revoked spec cannot be
	// approved.
	SpecStatusRevoked SpecStatus = "revoked"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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