CoinGecko_Task
extends Task
in package
Iterate over all currencies with a CoinGecko ID assigned to them and retrieve exchange rates.
The exchange rates for the enabled VS Currencies are retrieved.
Tags
Table of Contents
- $name : mixed
- $priority : mixed
- $task_start_time : mixed
- $timeout : mixed
- $verbose : mixed
- $batch_size : int
- How many currencies to process per run.
- $currencies_per_run : mixed
- $current_batch : mixed
- $start_memory : mixed
- $start_time : mixed
- $vs_currencies : array<string|int, mixed>
- VS currencies from CoinGecko. An array of lowercase ticker symbols.
- __construct() : mixed
- Constructor hooks this task into the cron job action.
- log() : void
- Cron task logging.
- register() : void
- run() : void
- Do the task.
- get_cron_interval() : int
- get_supported_vs_currencies() : mixed
- Retrieve all the CoinGecko VS Currencies.
- update_exchange_rates_for() : mixed
Properties
$name
protected
mixed
$name
string The name of this task.
$priority
protected
mixed
$priority
= 10
int The priority with which to attach to cron action.
$task_start_time
protected
mixed
$task_start_time
= 0
int Timestamp at which this task is starting execution.
$timeout
protected
mixed
$timeout
= DEFAULT_CRON_TASK_TIMEOUT
How many seconds this task is allowed to run. The task's run() method must respect this limit.
$verbose
protected
mixed
$verbose
= false
boolean Whether to write all log() output to debug log.
$batch_size
How many currencies to process per run.
private
int
$batch_size
= 8
$currencies_per_run
private
mixed
$currencies_per_run
= 0
$current_batch
private
mixed
$current_batch
= 0
$start_memory
private
static mixed
$start_memory
= 0
int Memory used at start of tasks batch execution, measured in bytes.
$start_time
private
static mixed
$start_time
= 0
int Timestamp at which tasks batch starts execution.
$vs_currencies
VS currencies from CoinGecko. An array of lowercase ticker symbols.
private
array<string|int, mixed>
$vs_currencies
= []
Methods
__construct()
Constructor hooks this task into the cron job action.
public
__construct() : mixed
Call this after your sub-class constructor.
This way, any changes you make to $this->priority will have an effect.
WARNING: If you forget to call parent::__construct();
, your task will not run.
Return values
mixed —log()
Cron task logging.
public
final log(string $message[, bool $force = false ]) : void
Migration task is always logged.
Parameters
- $message : string
-
The string to log.
- $force : bool = false
-
Whether to force log the string, even if no verbose logging is checked.
Return values
void —register()
public
final static register() : void
Return values
void —run()
Do the task.
public
run() : void
Concrete implementations must do the work here in chuncks. The max execution time, usually about 15 or 30 secs must be eenough for all the tasks. So be careful!
Return values
void —get_cron_interval()
private
static get_cron_interval() : int
Return values
int —get_supported_vs_currencies()
Retrieve all the CoinGecko VS Currencies.
private
get_supported_vs_currencies() : mixed
This is used to display options to the admin and is saved in the wallets_rates_vs transient. The transient is refreshed weekly.
The option will then put their selection in the wallets_rates_vs option.
Return values
mixed —update_exchange_rates_for()
private
update_exchange_rates_for(array<string|int, mixed> $currencies) : mixed
Parameters
- $currencies : array<string|int, mixed>