host

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidIPAddressProvided = "invalid IP address: %v"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressInfo

type AddressInfo struct {
	Ports    map[enums.PortType]string
	Endpoint address.Endpoint
}

func (*AddressInfo) GetURLPrometheus added in v1.2.1

func (addr *AddressInfo) GetURLPrometheus() (string, error)

GetUrlPrometheus generates a URL for the Prometheus endpoint of the address. It constructs the URL using the protocol, host, port, and path components of the endpoint, as well as the default port and path values.

func (*AddressInfo) GetURLRPC added in v1.2.1

func (addr *AddressInfo) GetURLRPC() (string, error)

GetUrlRPC generates a URL for the RPC endpoint of the address. It constructs the URL using the protocol, host, port, and path components of the endpoint, as well as the default port value.

type Gateways

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

type Host

type Host struct {
	AddressInfo

	IPInfo *ports.IPResult

	TableType enums.TableType

	Status  enums.Status
	Metrics metrics.Metrics
	// contains filtered or unexported fields
}

func NewHost

func NewHost(
	tableType enums.TableType,
	addressInfo AddressInfo,
	rpcGW ports.RPCGateway,
	geoGW ports.GeoGateway,
	prometheusGW ports.PrometheusGateway,
	cliGW *cligw.Gateway,
) *Host

func (*Host) GetDataByMetric

func (host *Host) GetDataByMetric(method enums.RPCMethod) error

GetDataByMetric is a method of the Host struct that retrieves data for a given RPC method and stores it as a metric in the Metrics struct. It takes an RPCMethod input parameter and returns an error if the method is not supported.

func (*Host) GetMetrics

func (host *Host) GetMetrics() error

GetMetrics fetches data from the host by calling three different methods asynchronously: GetTotalTransactionNumber, GetLatestCheckpoint, and GetPrometheusMetrics. The function waits for all three methods to complete before returning. Returns an error if any of the three methods fail or return an error.

func (*Host) GetPrometheusMetrics

func (host *Host) GetPrometheusMetrics() error

GetPrometheusMetrics retrieves the Prometheus metrics for the host and processes them accordingly. It calls Prometheus for metrics, processes the result, and sets the values in the host's Metrics. Returns an error if there is an issue calling Prometheus or processing the metrics.

func (*Host) SetIPInfo

func (host *Host) SetIPInfo() error

SetIPInfo sets the IPInfo property of a Host struct by calling an external geolocation API with the host's IP address. It returns an error if the IP address is invalid or if the API call fails.

func (*Host) SetPctProgress

func (host *Host) SetPctProgress(metricType enums.MetricType, rpc *Host) error

SetPctProgress updates the value of the specified metric type for the Host instance with a percentage that reflects the Host's progress relative to the progress of the RPC Host. The function obtains the current metric value for the Host and RPC Host, calculates the percentage using the percent.PercentOf function, and sets the new percentage value for the Host's Metrics instance for the specified metric type. The second argument is the RPC Host to compare the progress against.

func (*Host) SetStatus

func (host *Host) SetStatus(rpc *Host)

SetStatus updates the status of the Host based on the provided RPC Host. It compares the metrics of the Host and RPC Host and sets the status to Red, Yellow, or Green based on specific conditions.

Jump to

Keyboard shortcuts

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