Members
(constant) got
Methods
(async) cdn_preheating(token, preHeatArray, MAX_TRY, QUERY_BREAK, chunk_size, got_instance)
cdn preHeating task
Parameters:
Name | Type | Default | Description |
---|---|---|---|
token |
String | huaweicloud IAM TOKEN | |
preHeatArray |
Array | pre-heating url array | |
MAX_TRY |
Maximum attempts | ||
QUERY_BREAK |
Number | setTimeout time unit | |
chunk_size |
10 | ||
got_instance |
null | Got instance, default null
As we know, one we commit the preHeatingTask, more than
one cdn node will get resource file from the source
site via public Internet.
So, the source site's traffic will be very busy after we commit the task. If too many URLs are submitted in a short time, most tasks will fail. huaweicloud will retry once if connection time is more than 30s. |
(async) cdn_preheatingtasks(array, token, instance) → {JSON|Error}
huaweicloud cdn preheatingtasks
Parameters:
Name | Type | Default | Description |
---|---|---|---|
array |
Array | String | ||
token |
String | huaweicloud IAM TOKEN | |
instance |
null | Got instance, default null |
- Source:
- See:
Returns:
result
- Type
- JSON | Error
(async) cdn_refreshtasks(array, token, types, instance) → {JSON|Error}
huaweicloud cdn refreshtasks
Parameters:
Name | Type | Default | Description |
---|---|---|---|
array |
Array | String | ||
token |
String | huaweicloud IAM TOKEN | |
types |
'file' | 'directory' | file | refresh types, default 'file' |
instance |
null | Got instance, default null |
- Source:
- See:
Returns:
result
- Type
- JSON | Error
checkUrl(array) → {Array}
Give a string or array, get a compact array
Parameters:
Name | Type | Description |
---|---|---|
array |
String | Array | Input array or string |
- Source:
- See:
Returns:
Output array without null object
- Type
- Array
get_bytes(INTERFACE_NAME)
get previous break traffic state, only support linux
Parameters:
Name | Type | Default | Description |
---|---|---|---|
INTERFACE_NAME |
eth0 | network interface device name |
Returns:
unit: byte, previous break traffic state
(async) getToken() → {JSON}
Get huaweicloud IAM TOKEN
- Source:
- See:
Returns:
huaweicloud IAM TOKEN
- Type
- JSON
got_instance(prefixUrl, token, json_body) → {Got}
Simple packaging got
Parameters:
Name | Type | Default | Description |
---|---|---|---|
prefixUrl |
String | URL | got prefixUrl | |
token |
String | huaweicloud IAM Token | |
json_body |
null | POST BODY, NULL for GET Method |
- Source:
- See:
Returns:
Got instance
- Type
- Got
human_net_speed(bytes, pre_unit, bits) → {string}
Get human readable network speed
Parameters:
Name | Type | Default | Description |
---|---|---|---|
bytes |
bytes | ||
pre_unit |
number | 1024 | 1024 or 1000, default 1024 |
bits |
1 | Keep decimal places, default 1 |
Returns:
human readable network speed
- Type
- string
(async) hwc_common(prefixUrl, api_url, body, token, instance) → {JSON|Error}
huaweicloud common api operation
Parameters:
Name | Type | Default | Description |
---|---|---|---|
prefixUrl |
String | URL | prefixUrl got prefixUrl | |
api_url |
API URL which shouldn't start with '/' | ||
body |
request body | ||
token |
String | huaweicloud IAM TOKEN | |
instance |
null | Got instance, default null |
- Source:
- See:
Returns:
- Type
- JSON | Error
(async) live_net_speed(INTERFACE_NAME, sampling_break, human)
Get live network speed
Parameters:
Name | Type | Default | Description |
---|---|---|---|
INTERFACE_NAME |
eth0 | Interface name | |
sampling_break |
1000 | Sampling break | |
human |
false | Show human readable net speed |
(async) showHistoryTaskDetails(history_tasks_id, token, instance) → {JSON|Error}
huaweicloud cdn refreshtasks
Parameters:
Name | Type | Description |
---|---|---|
history_tasks_id |
TaskID | |
token |
String | huaweicloud IAM TOKEN |
instance |
Got instance, default null |
- Source:
- See:
Returns:
result
- Type
- JSON | Error
(async) sleep(ms)
sleep for a while
Parameters:
Name | Type | Description |
---|---|---|
ms |
ms |
(async) wait_for_low_traffic_usage(INTERFACE, break_time, TX_RX, MAX_RX_SPEED, MAX_TX_SPEED, usage,)
Wait for low traffic usage
Parameters:
Name | Type | Default | Description |
---|---|---|---|
INTERFACE |
eth0 | interface name, default eth0 | |
break_time |
5000 | query break,unit: millisecond, default 5000 | |
TX_RX |
TR | 'TX' | 'RX' | 'TR', listening on TX or RX or TX & RX traffic, default TR | |
MAX_RX_SPEED |
100 | Max Receive speed,unit: Mbit/s, default 100 | |
MAX_TX_SPEED |
30 | Max transmit speed,unit: Mbit/s, default 30 | |
usage, |
network usage limit, default 0.6 |
(async) waitForRefreshTaskDone(token, refreshTaskId, MAX_TRY, query_break, instance) → {Array|Number|Error}
wait for refresh task done
Parameters:
Name | Type | Description |
---|---|---|
token |
String | huaweicloud IAM TOKEN |
refreshTaskId |
Number | cdn refresh Task ID |
MAX_TRY |
Maximum attempts | |
query_break |
Number | setTimeout time unit |
instance |
Got instance, default null |
Returns:
Number for succeed task numbers
Array for failed task array
Error for other error
Array for failed task array
Error for other error
- Type
- Array | Number | Error