Skip to content

Module hb_http_client.erl

A wrapper library for gun.

Behaviours: gen_server.

Description

This module originates from the Arweave project, and has been modified for use in HyperBEAM.

Function Index

await_response/2*
dec_prometheus_gauge/1*Safe wrapper for prometheus_gauge:dec/2.
download_metric/2*
get_status_class/1*Return the HTTP status class label for cowboy_requests_total and gun_requests_total metrics.
gun_req/3*
handle_call/3
handle_cast/2
handle_info/2
httpc_req/3*
inc_prometheus_counter/3*
inc_prometheus_gauge/1*Safe wrapper for prometheus_gauge:inc/2.
init/1
init_prometheus/1*
log/5*
maybe_invoke_monitor/2*Invoke the HTTP monitor message with AO-Core, if it is set in the node message key.
method_to_bin/1*
open_connection/2*
parse_peer/2*
record_duration/2*Record the duration of the request in an async process.
record_response_status/3*
reply_error/2*
req/2
req/3*
request/3*
start_link/1
terminate/2
upload_metric/1*

Function Details

await_response/2 *

await_response(Args, Opts) -> any()

dec_prometheus_gauge/1 *

dec_prometheus_gauge(Name) -> any()

Safe wrapper for prometheus_gauge:dec/2.

download_metric/2 *

download_metric(Data, X2) -> any()

get_status_class/1 *

get_status_class(Data) -> any()

Return the HTTP status class label for cowboy_requests_total and gun_requests_total metrics.

gun_req/3 *

gun_req(Args, ReestablishedConnection, Opts) -> any()

handle_call/3

handle_call(Request, From, State) -> any()

handle_cast/2

handle_cast(Cast, State) -> any()

handle_info/2

handle_info(Message, State) -> any()

httpc_req/3 *

httpc_req(Args, X2, Opts) -> any()

inc_prometheus_counter/3 *

inc_prometheus_counter(Name, Labels, Value) -> any()

inc_prometheus_gauge/1 *

inc_prometheus_gauge(Name) -> any()

Safe wrapper for prometheus_gauge:inc/2.

init/1

init(Opts) -> any()

init_prometheus/1 *

init_prometheus(Opts) -> any()

log/5 *

log(Type, Event, X3, Reason, Opts) -> any()

maybe_invoke_monitor/2 *

maybe_invoke_monitor(Details, Opts) -> any()

Invoke the HTTP monitor message with AO-Core, if it is set in the node message key. We invoke the given message with the body set to a signed version of the details. This allows node operators to configure their machine to record duration statistics into customized data stores, computations, or processes etc. Additionally, we include the http_reference value, if set in the given opts.

We use hb_ao:get rather than hb_opts:get, as settings configured by the ~router@1.0 route opts key are unable to generate atoms.

method_to_bin/1 *

method_to_bin(X1) -> any()

open_connection/2 *

open_connection(X1, Opts) -> any()

parse_peer/2 *

parse_peer(Peer, Opts) -> any()

record_duration/2 *

record_duration(Details, Opts) -> any()

Record the duration of the request in an async process. We write the data to prometheus if the application is enabled, as well as invoking the http_monitor if appropriate.

record_response_status/3 *

record_response_status(Method, Path, Response) -> any()

reply_error/2 *

reply_error(PendingRequests, Reason) -> any()

req/2

req(Args, Opts) -> any()

req/3 *

req(Args, ReestablishedConnection, Opts) -> any()

request/3 *

request(PID, Args, Opts) -> any()

start_link/1

start_link(Opts) -> any()

terminate/2

terminate(Reason, State) -> any()

upload_metric/1 *

upload_metric(X1) -> any()