client

package
v1.31.6 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 23 Imported by: 6

README

Client

Contains code to interact with Chainlink nodes, and other HTTP services.

Documentation

Index

Constants

View Source
const (
	QueryMemoryUsage          = `` /* 201-byte string literal not displayed */
	QueryAllCPUBusyPercentage = `100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[%s])) * 100)`
)

Query constants

View Source
const WITHOUT_TOKEN = ""

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterResponse

type AdapterResponse struct {
	Id    string        `json:"id"`
	Data  AdapterResult `json:"data"`
	Error interface{}   `json:"error"`
}

AdapterResponse represents a response from an adapter

type AdapterResult

type AdapterResult struct {
	Result interface{} `json:"result"`
}

AdapterResult represents an int result for an adapter

type AnvilContainer added in v1.28.3

type AnvilContainer struct {
	testcontainers.Container
	URL string
}

func StartAnvil added in v1.28.3

func StartAnvil(params []string) (*AnvilContainer, error)

type ContractInfoJSON

type ContractInfoJSON struct {
	ContractAddress string `json:"contractAddress"`
	ContractVersion int    `json:"contractVersion"`
	Path            string `json:"path"`
	Status          string `json:"status"`
}

ContractInfoJSON represents an element of the contracts array used to deliver configs to otpe

type CurrentBlockResponse added in v1.28.3

type CurrentBlockResponse struct {
	Result string `json:"result"`
}

type ExplorerClient

type ExplorerClient struct {
	APIClient *resty.Client
	Config    *ExplorerConfig
}

ExplorerClient is used to call Explorer API endpoints

func NewExplorerClient

func NewExplorerClient(cfg *ExplorerConfig) *ExplorerClient

NewExplorerClient creates a new explorer mock client

func (*ExplorerClient) PostAdminNodes

func (em *ExplorerClient) PostAdminNodes(nodeName string) (NodeAccessKeys, error)

PostAdminNodes is used to exercise the POST /api/v1/admin/nodes endpoint This endpoint is used to create access keys for nodes

type ExplorerConfig

type ExplorerConfig struct {
	URL           string
	AdminUsername string
	AdminPassword string
}

ExplorerConfig holds config information for ExplorerClient

type GethContainer added in v1.28.3

type GethContainer struct {
	testcontainers.Container
	URL string
}

type GithubClient added in v1.22.3

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

func NewGithubClient added in v1.22.3

func NewGithubClient(token string) *GithubClient

func (*GithubClient) ListLatestCLCoreReleases added in v1.22.3

func (g *GithubClient) ListLatestCLCoreReleases(count int) ([]*github.RepositoryRelease, error)

ListLatestCLCoreReleases lists the latest releases for the Chainlink core repository

func (*GithubClient) ListLatestCLCoreTags added in v1.22.3

func (g *GithubClient) ListLatestCLCoreTags(count int) ([]*github.RepositoryTag, error)

ListLatestCLCoreTags lists the latest tags for the Chainlink core repository

func (*GithubClient) ListLatestReleases added in v1.27.0

func (g *GithubClient) ListLatestReleases(org, repository string, count int) ([]*github.RepositoryRelease, error)

ListLatestReleases lists the latest releases for a given repository

type HttpInitializer

type HttpInitializer struct {
	Id       string       `json:"id"`
	Request  HttpRequest  `json:"httpRequest"`
	Response HttpResponse `json:"httpResponse"`
}

HttpInitializer represents an element of the initializer array used in the mockserver initializer

type HttpInitializerTemplate added in v1.9.10

type HttpInitializerTemplate struct {
	Id       string               `json:"id"`
	Request  HttpRequest          `json:"httpRequest"`
	Response HttpResponseTemplate `json:"httpResponseTemplate"`
}

HttpInitializer represents an element of the initializer array used in the mockserver initializer

type HttpRequest

type HttpRequest struct {
	Path string `json:"path"`
}

HttpRequest represents the httpRequest json object used in the mockserver initializer

type HttpResponse

type HttpResponse struct {
	Body interface{} `json:"body"`
}

HttpResponse represents the httpResponse json object used in the mockserver initializer

type HttpResponseTemplate added in v1.9.10

type HttpResponseTemplate struct {
	Template     string `json:"template"`
	TemplateType string `json:"templateType"`
}

HttpResponse represents the httpResponse json object used in the mockserver initializer

type KafkaRestClient

type KafkaRestClient struct {
	APIClient *resty.Client
	Config    *KafkaRestConfig
}

KafkaRestClient kafka-rest client

func NewKafkaRestClient

func NewKafkaRestClient(cfg *KafkaRestConfig) *KafkaRestClient

NewKafkaRestClient creates a new KafkaRestClient

func (*KafkaRestClient) GetTopics

func (krc *KafkaRestClient) GetTopics() ([]string, error)

GetTopics Get a list of Kafka topics.

type KafkaRestConfig

type KafkaRestConfig struct {
	URL string
}

KafkaRestConfig holds config information for KafkaRestClient

type MockserverClient

type MockserverClient struct {
	APIClient *resty.Client
	Config    *MockserverConfig
}

MockserverClient mockserver client

func ConnectMockServer

func ConnectMockServer(e *environment.Environment) (*MockserverClient, error)

ConnectMockServer creates a connection to a deployed mockserver in the environment

func ConnectMockServerURL added in v1.15.0

func ConnectMockServerURL(url string) (*MockserverClient, error)

ConnectMockServerURL creates a connection to a mockserver at a given url, should only be used for inside K8s tests

func NewMockserverClient

func NewMockserverClient(cfg *MockserverConfig) *MockserverClient

NewMockserverClient returns a mockserver client

func (*MockserverClient) ClearExpectation

func (em *MockserverClient) ClearExpectation(body interface{}) error

ClearExpectation clears expectations

func (*MockserverClient) LocalURL added in v1.15.0

func (em *MockserverClient) LocalURL() string

LocalURL returns the local url of the mockserver

func (*MockserverClient) PutExpectations

func (em *MockserverClient) PutExpectations(body interface{}) error

PutExpectations sets the expectations (i.e. mocked responses)

func (*MockserverClient) SetAnyValuePath added in v1.6.0

func (em *MockserverClient) SetAnyValuePath(path string, v interface{}) error

SetAnyValuePath sets any type of value for a path

func (*MockserverClient) SetAnyValueResponse added in v1.22.7

func (em *MockserverClient) SetAnyValueResponse(path string, v interface{}) error

func (*MockserverClient) SetRandomValuePath added in v1.9.10

func (em *MockserverClient) SetRandomValuePath(path string) error

SetRandomValuePath sets a random int value for a path

func (*MockserverClient) SetStringValuePath added in v1.17.3

func (em *MockserverClient) SetStringValuePath(path string, stringValue string) error

SetStringValuePath sets a string value for a path and returns it as a raw string

func (*MockserverClient) SetValuePath

func (em *MockserverClient) SetValuePath(path string, v int) error

SetValuePath sets an int for a path

type MockserverConfig

type MockserverConfig struct {
	LocalURL   string
	ClusterURL string
}

MockserverConfig holds config information for MockserverClient

type Name

type Name struct {
	Name string `json:"name"`
}

Name is the body of the request

type NodeAccessKeys

type NodeAccessKeys struct {
	ID        string `json:"id"`
	AccessKey string `json:"accessKey"`
	Secret    string `json:"secret"`
}

NodeAccessKeys is the body of the response

type NodeInfoJSON

type NodeInfoJSON struct {
	ID          string   `json:"id"`
	NodeAddress []string `json:"nodeAddress"`
}

NodeInfoJSON represents an element of the nodes array used to deliver configs to otpe

type PathSelector

type PathSelector struct {
	Path string `json:"path"`
}

PathSelector represents the json object used to find expectations by path

type PostgresConfig

type PostgresConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

PostgresConfig postgres config for connection string

type PostgresConnector

type PostgresConnector struct {
	*sqlx.DB
	Cfg *PostgresConfig
}

PostgresConnector sqlx postgres connector

func ConnectDB added in v1.6.3

func ConnectDB(nodeNum int, e *environment.Environment) (*PostgresConnector, error)

func NewPostgresConnector

func NewPostgresConnector(cfg *PostgresConfig) (*PostgresConnector, error)

NewPostgresConnector creates new sqlx postgres connector

type Prometheus

type Prometheus struct {
	v1.API
}

Prometheus ease of use for v1.API

func NewPrometheusClient

func NewPrometheusClient(url string) (*Prometheus, error)

NewPrometheusClient returns a prometheus client

func (*Prometheus) CPUBusyPercentage

func (p *Prometheus) CPUBusyPercentage() (float64, error)

CPUBusyPercentage host CPU busy percentage

func (*Prometheus) GetAlerts

func (p *Prometheus) GetAlerts() (v1.AlertsResult, error)

GetAlerts returns all firing alerts

func (*Prometheus) GetQuery

func (p *Prometheus) GetQuery(query string) (model.Value, error)

GetQuery returns the result of applying a PromQL query

func (*Prometheus) MemoryUsage

func (p *Prometheus) MemoryUsage() (float64, error)

MemoryUsage total memory used by interval

func (*Prometheus) ResourcesSummary

func (p *Prometheus) ResourcesSummary() (float64, float64, error)

ResourcesSummary returns a summary of memory and cpu used

type RPCClient added in v1.28.3

type RPCClient struct {
	URL string
	// contains filtered or unexported fields
}

RPCClient is an RPC client for various node simulators API Reference https://book.getfoundry.sh/reference/anvil/

func NewRPCClient added in v1.28.3

func NewRPCClient(url string) *RPCClient

NewRPCClient creates Anvil client

func (*RPCClient) AnvilDropTransaction added in v1.28.3

func (m *RPCClient) AnvilDropTransaction(params []interface{}) error

AnvilDropTransaction removes transaction from tx pool API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilMine added in v1.28.3

func (m *RPCClient) AnvilMine(params []interface{}) error

AnvilMine calls "evm_mine", mines one or more blocks, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetAutoMine added in v1.28.3

func (m *RPCClient) AnvilSetAutoMine(flag bool) error

AnvilSetAutoMine calls "evm_setAutomine", turns automatic mining on, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetBlockGasLimit added in v1.28.3

func (m *RPCClient) AnvilSetBlockGasLimit(params []interface{}) error

AnvilSetBlockGasLimit sets next block gas limit API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetMinGasPrice added in v1.28.3

func (m *RPCClient) AnvilSetMinGasPrice(params []interface{}) error

AnvilSetMinGasPrice sets min gas price (pre-EIP-1559 anvil is required) API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetNextBlockBaseFeePerGas added in v1.28.3

func (m *RPCClient) AnvilSetNextBlockBaseFeePerGas(params []interface{}) error

AnvilSetNextBlockBaseFeePerGas sets next block base fee per gas value API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilTxPoolStatus added in v1.28.3

func (m *RPCClient) AnvilTxPoolStatus(params []interface{}) (*TxStatusResponse, error)

AnvilTxPoolStatus calls "txpool_status", returns txpool status, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) BlockNumber added in v1.30.4

func (m *RPCClient) BlockNumber() (int64, error)

Call "eth_blockNumber" to get the current block number

func (*RPCClient) GethSetHead added in v1.28.3

func (m *RPCClient) GethSetHead(blocksBack int) error

func (*RPCClient) ModulateBaseFeeOverDuration added in v1.28.7

func (m *RPCClient) ModulateBaseFeeOverDuration(lggr zerolog.Logger, startingBaseFee int64, percentage float64, duration time.Duration, spike bool) error

ModulateBaseFeeOverDuration will cause the gas price to rise or drop to a certain percentage of the starting gas price over the duration specified. Minimum duration is 1 s if spike is true, the gas price will rise to the target price if spike is false, the gas price will drop to the target price

type RemoteAnvilMiner added in v1.27.7

type RemoteAnvilMiner struct {
	Client *RPCClient
	// contains filtered or unexported fields
}

RemoteAnvilMiner is a remote miner for Anvil node Allows to control blocks emission more precisely to mimic real networks workload

func NewRemoteAnvilMiner added in v1.27.7

func NewRemoteAnvilMiner(url string) *RemoteAnvilMiner

NewRemoteAnvilMiner creates a new remote miner client

func (*RemoteAnvilMiner) MineBatch added in v1.27.7

func (m *RemoteAnvilMiner) MineBatch(capacity int64, checkInterval time.Duration, sendInterval time.Duration)

MineBatch checks the pending transactions in the pool, if threshold is reached mines the block and repeat the process

func (*RemoteAnvilMiner) MinePeriodically added in v1.27.7

func (m *RemoteAnvilMiner) MinePeriodically(interval time.Duration)

MinePeriodically mines blocks with a specified interval should be used when Anvil mining is off

func (*RemoteAnvilMiner) Stop added in v1.27.7

func (m *RemoteAnvilMiner) Stop()

Stop stops the miner

type ResourcesSummary

type ResourcesSummary struct {
	MemoryUsage   float64
	CPUPercentage float64
}

ResourcesSummary Data for memory and cpu usage

type TxStatusResponse added in v1.27.7

type TxStatusResponse struct {
	Result struct {
		Pending string `json:"pending"`
	} `json:"result"`
}

TxStatusResponse common RPC response body

Jump to

Keyboard shortcuts

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