Skip to main content

HuaweiContext

@h4ad/serverless-adapter > HuaweiContext

(interface) HuaweiContext

The interface that represents methods sent by huawei to get information about the function graph. See more in Context Methods

Signature:

export interface HuaweiContext 

(method) getAccessKey

Obtains the AK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.

Signature:

getAccessKey(): GetAccessKeyReturn;

Returns:

GetAccessKeyReturn

(method) getCPUNumber

Number of CPU millicores used by the function (1 core = 1000 millicores).

The value of this field is proportional to that of MemorySize. By default, 100 CPU millicores are required for 128 MB memory. The number of CPU millicores is calculated as follows: Memory/128 x 100 + 200 (basic CPU millicores).

Signature:

getCPUNumber(): GetCPUNumberReturn;

Returns:

GetCPUNumberReturn

(method) getFunctionName

Obtains the name of a function.

Signature:

getFunctionName(): GetFunctionNameReturn;

Returns:

GetFunctionNameReturn

(method) getLogger

Obtains the logger method provided by the context and returns a log output class. Logs are output in the format of Time-Request ID-Content by using the info method.

For example, use the info method to output logs:

Signature:

getLogger(): GetLoggerReturn;

Returns:

GetLoggerReturn

Example

logg = context.getLogger()

logg.info("hello")

(method) getMemorySize

Obtains the allocated memory.

Signature:

getMemorySize(): GetMemorySizeReturn;

Returns:

GetMemorySizeReturn

(method) getPackage

Obtains a function group, that is, an app.

Signature:

getPackage(): GetPackageReturn;

Returns:

GetPackageReturn

(method) getProjectID

Obtains a project ID.

Signature:

getProjectID(): GetProjectIdReturn;

Returns:

GetProjectIdReturn

(method) getRemainingTimeInMilliSeconds

Obtains the remaining running time of a function.

Signature:

getRemainingTimeInMilliSeconds(): GetRemainingTimeInMilliSecondsReturn;

Returns:

GetRemainingTimeInMilliSecondsReturn

(method) getRequestID

Obtains a request ID.

Signature:

getRequestID(): GetRequestIDSecondsReturn;

Returns:

GetRequestIDSecondsReturn

(method) getRunningTimeInSeconds

Obtains the timeout of a function.

Signature:

getRunningTimeInSeconds(): GetRunningTimeInSecondsReturn;

Returns:

GetRunningTimeInSecondsReturn

(method) getSecretKey

Obtains the SK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.

Signature:

getSecretKey(): GetSecretKeyReturn;

Returns:

GetSecretKeyReturn

(method) getToken

Obtains the token (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.

Signature:

getToken(): GetTokenReturn;

Returns:

GetTokenReturn

(method) getUserData

Uses keys to obtain the values passed by environment variables.

Signature:

getUserData(key: GetUserDataKeyParameter): GetUserDataReturn;

Parameters

Parameter

Type

Description

key

GetUserDataKeyParameter

The key to get environment variables values

Returns:

GetUserDataReturn

(method) getVersion

Obtains the version of a function.

Signature:

getVersion(): GetVersionReturn;

Returns:

GetVersionReturn