client

package
v0.0.0-...-5955844 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package client provides the core functionality to Run an External Initiator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Run enters into the cobra command to start the external initiator.

func RunWebserver

func RunWebserver(
	accessKey, secret string,
	store subscriptionStorer,
	port int,
)

RunWebserver starts a new web server using the access key and secret as provided on protected routes.

Types

type Config

type Config struct {
	// The port for the EI API to listen on
	Port int
	// The URL of the ChainlinkURL Core Service
	ChainlinkURL string
	// InitiatorToChainlinkAccessKey is the access key to identity the node to ChainlinkURL
	InitiatorToChainlinkAccessKey string
	// InitiatorToChainlinkSecret is the secret to authenticate the node to ChainlinkURL
	InitiatorToChainlinkSecret string
	// DatabaseURL Configures the URL for chainlink to connect to. This must be
	// a properly formatted URL, with a valid scheme (postgres://).
	DatabaseURL string
	// The External Initiator access key, used for traffic flowing from Chainlink to this Service
	ChainlinkToInitiatorAccessKey string
	// The External Initiator secret, used for traffic flowing from Chainlink to this Service
	ChainlinkToInitiatorSecret string
	// ExpectsMock is true if the External Initiator should expect mock events from the blockchains
	ExpectsMock bool
	// ChainlinkTimeout sets the timeout for job run triggers to the Chainlink node
	ChainlinkTimeout time.Duration
	// ChainlinkRetryAttempts sets the maximum number of attempts that will be made for job run triggers
	ChainlinkRetryAttempts uint
	// ChainlinkRetryDelay sets the delay between attempts for job run triggers
	ChainlinkRetryDelay time.Duration
	// KeeperBlockCooldown sets a number of blocks to cool down before triggering a new run for a job.
	KeeperBlockCooldown int64
}

Config contains the startup configuration parameters.

type CreateSubscriptionReq

type CreateSubscriptionReq struct {
	JobID  string            `json:"jobId"`
	Type   string            `json:"type"`
	Params blockchain.Params `json:"params"`
}

CreateSubscriptionReq holds the payload expected for job POSTs from the Chainlink node.

type HttpService

type HttpService struct {
	Router    *gin.Engine
	AccessKey string
	Secret    string
	Store     subscriptionStorer
}

HttpService encapsulates router, EI service and access credentials.

func NewHTTPService

func NewHTTPService(
	accessKey, secret string,
	store subscriptionStorer,
) *HttpService

NewHTTPService creates a new HttpService instance with the default router.

func (*HttpService) CreateEndpoint

func (srv *HttpService) CreateEndpoint(c *gin.Context)

CreateEndpoint saves the endpoint configuration provided as payload.

func (*HttpService) CreateSubscription

func (srv *HttpService) CreateSubscription(c *gin.Context)

CreateSubscription expects a CreateSubscriptionReq payload, validates the request and subscribes to the job.

func (*HttpService) DeleteSubscription

func (srv *HttpService) DeleteSubscription(c *gin.Context)

DeleteSubscription deletes any job with the jobid provided as parameter in the request.

func (*HttpService) ServeHTTP

func (srv *HttpService) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP calls ServeHTTP on the underlying router, which conforms to the http.Handler interface.

func (*HttpService) ShowHealth

func (srv *HttpService) ShowHealth(c *gin.Context)

ShowHealth returns the following when online:

{"chainlink": true}

type Service

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

Service holds the main process for running the external initiator.

func NewService

func NewService(
	dbClient storeInterface,
	clNode chainlink.Node,
	runtimeConfig store.RuntimeConfig,
) *Service

NewService returns a new instance of Service, using the provided database client and Chainlink node config.

func (*Service) Close

func (srv *Service) Close()

Close shuts down any open subscriptions and closes the database client.

func (*Service) DeleteJob

func (srv *Service) DeleteJob(jobid string) error

DeleteJob unsubscribes (if applicable) and deletes the subscription associated with the jobId provided.

func (*Service) GetEndpoint

func (srv *Service) GetEndpoint(name string) (*store.Endpoint, error)

GetEndpoint returns an instance of store.Endpoint that matches the endpoint name provided.

func (*Service) Run

func (srv *Service) Run() error

Run loads subscriptions, validates and subscribes to them.

func (*Service) SaveEndpoint

func (srv *Service) SaveEndpoint(e *store.Endpoint) error

SaveEndpoint validates and stores the store.Endpoint provided.

func (*Service) SaveSubscription

func (srv *Service) SaveSubscription(arg *store.Subscription) error

SaveSubscription tests, stores and subscribes to the store.Subscription provided.

Jump to

Keyboard shortcuts

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