Documentation ¶
Index ¶
- Constants
- type AddressInfo
- type Gateways
- type Host
- func (host *Host) GetDataByMetric(method enums.RPCMethod) error
- func (host *Host) GetMetrics() error
- func (host *Host) GetPrometheusMetrics() error
- func (host *Host) SetIPInfo() error
- func (host *Host) SetPctProgress(metricType enums.MetricType, rpc *Host) error
- func (host *Host) SetStatus(rpc *Host)
Constants ¶
const (
ErrInvalidIPAddressProvided = "invalid IP address: %v"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressInfo ¶
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 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 ¶
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 ¶
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 ¶
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 ¶
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.