Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

Node.js libraries for FunctionGraph on T Cloud Public.

> [!Note]
> <pre>
> ###############################################
> Work in progress....
> !! SUBJECT TO CHANGE WITHOUT NOTICE !!
> ###############################################
> </pre>
>

## Documentation

For documentation see: [otc-functiongraph-nodejs-runtime](https://opentelekomcloud-community.github.io/otc-functiongraph-nodejs-runtime/)
Expand Down
4 changes: 2 additions & 2 deletions doc/doc-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Requires src-fg/index.js installed as FunctionGraph with:
- Function type: event-function from scratch
- Name: ``getNodeJSRuntimeInfo``
- Runtime: nodejs20.15
- Project: OTC_SDK_PROJECT_ID
- Project: OTC_SDK_PROJECTID
- Region: OTC_SDK_REGION

To run, following environment variables must be set on client side:

- Project: OTC_SDK_PROJECT_ID
- Project: OTC_SDK_PROJECTID
- Region: OTC_SDK_REGION
- Access Key: OTC_SDK_AK
- Secret key: OTC_SDK_SK
Expand Down
4 changes: 2 additions & 2 deletions doc/doc-utils/src/createLibraryDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* Following environment variables are required for this script:
* - OTC_SDK_REGION: The region where your FunctionGraph service is hosted (default is "eu-de").
* - OTC_SDK_PROJECT_ID: Your 'T Cloud Public' project ID.
* - OTC_SDK_PROJECTID: Your 'T Cloud Public' project ID.
* - OTC_SDK_AK: Your 'T Cloud Public' Access Key.
* - OTC_SDK_SK: Your 'T Cloud Public' Secret Key.
*******************************************************************/
Expand All @@ -36,7 +36,7 @@ const { type } = require("os");
const region = process.env.OTC_SDK_REGION || "eu-de";

const fgEndpoint = `https://functiongraph.${region}.otc.t-systems.com`;
const projectId = process.env.OTC_SDK_PROJECT_ID;
const projectId = process.env.OTC_SDK_PROJECTID;
const ak = process.env.OTC_SDK_AK;
const sk = process.env.OTC_SDK_SK;

Expand Down
2 changes: 1 addition & 1 deletion doc/doc-utils/src/fg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* - Function type: event-function from scratch
* - Name: getNodeJSRuntimeInfo
* - Runtime: nodejs20.15
* - Project: OTC_SDK_PROJECT_ID
* - Project: OTC_SDK_PROJECTID
* - Region: OTC_SDK_REGION
*************************************************************************/
const fs = require("fs");
Expand Down
4 changes: 2 additions & 2 deletions doc/doc-utils/src/getPublicFGDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Following environment variables are required for this script:
* - OTC_SDK_REGION: The region where your FunctionGraph service is hosted (default is "eu-de").
* - OTC_SDK_PROJECT_ID: Your 'T Cloud Public' project ID.
* - OTC_SDK_PROJECTID: Your 'T Cloud Public' project ID.
* - OTC_SDK_AK: Your 'T Cloud Public' Access Key.
* - OTC_SDK_SK: Your 'T Cloud Public' Secret Key.
*
Expand All @@ -33,7 +33,7 @@ const { Signer, HttpRequest } = require("otc-api-sign-sdk-nodejs");
const region = process.env.OTC_SDK_REGION || "eu-de";

const fgEndpoint = `https://functiongraph.${region}.otc.t-systems.com`;
const projectId = process.env.OTC_SDK_PROJECT_ID;
const projectId = process.env.OTC_SDK_PROJECTID;
const ak = process.env.OTC_SDK_AK;
const sk = process.env.OTC_SDK_SK;

Expand Down
18 changes: 15 additions & 3 deletions doc/source/devguide/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,26 @@ for building functions from scratch:
- Node.js16.17
- /opt/function/runtime/nodejs16.17/rtsp/nodejs/bin/node

* - NodeJS 18.20
- Node.js18.20
- /opt/function/runtime/nodejs18.20/rtsp/nodejs/bin/node
* - NodeJS 18.15
- Node.js18.15
- /opt/function/runtime/nodejs18.15/rtsp/nodejs/bin/node

* - NodeJS 20.15
- Node.js20.15
- /opt/function/runtime/nodejs20.15/rtsp/nodejs/bin/node

For supported runtimes see also: :otc_fg_umn:`Runtimes <service_overview/product_features.html>` in User Guide.

.. note::

If you need newer Node.js runtimes, use custom container images
to build your functions.

For more information, see

- :ref:`devguide_event_function_container_index`
- :ref:`devguide_http_function_container_index`

Bundled third-party components integrated in the Node.js runtime
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion doc/source/devguide/bestpractices/coldstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ two methods:

* Use reserved instances to avoid cold starts. For detailed usage instructions, please refer to
the :docs_otc:`Reserved Instance Management <function-graph/umn/configuring_reserved_instances.html>`
section .
section.
8 changes: 4 additions & 4 deletions doc/source/devguide/bestpractices/packaging_node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ Adapt your package.json file to include the necessary scripts and dependencies f
},

"dependencies": {
// add here dependencies of your function
// add dependencies of your function here
},
"devDependencies": {
// add here dev dependencies of your function
// add dev dependencies of your function here
},
"bundleDependencies": [
// add here bundle dependencies if needed
// add bundle dependencies if needed here
// these are dependencies from "dependencies" that will be included in the zip package
],
"files": [
// add here files to be included in the bundle, e.g.:
// add files to be included in the bundle here, e.g.:
"*.js",
"src/**/*",
"bootstrap" // for http functions
Expand Down
6 changes: 3 additions & 3 deletions doc/source/devguide/bestpractices/performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Performance testing of functions is a crucial step in ensuring the selection of
During function load testing, platform-provided metrics, logs, call chains, and other tools can be
used to further analyze function performance data, thereby optimizing function configuration selection.
For details on specific observable metrics, please refer to the
:docs_otc:`Function Monitoring Overview <https://docs.otc.t-systems.com/function-graph/umn/viewing_metrics_and_configuring_alarms/index.html>`.
:docs_otc:`Function Monitoring Overview <function-graph/umn/viewing_metrics_and_configuring_alarms/index.html>`.

Streamlined code and image slimming
---------------------------------------------------------------
Expand All @@ -65,9 +65,9 @@ Allocating more memory to functions can improve CPU performance, thereby speedin
startup and execution. You can evaluate the impact of different memory configurations on function
performance by monitoring function execution time, and then choose the optimal memory size.

For detailed monitoring information, please refer to the monitoring metric description.
For detailed monitoring information, please refer to the :docs_otc:`monitoring metrics description <function-graph/umn/viewing_metrics_and_configuring_alarms/metrics/viewing_functiongraph_metrics.html#metric-description>`.
For steps on configuring memory, please refer to the
:docs_otc:`configuration function information <function-graph/umn/configuring_functions/index.html>`.
:docs_otc:`function configuration information <function-graph/umn/configuring_functions/index.html>`.

Use common dependency packages to speed up
---------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/source/devguide/bestpractices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Configure a VPC for the function to prevent external attacks

When a user function needs to access resources within a Virtual Private
Cloud (VPC), such as RDS, it is recommended to
:docs_otc:`configure a VPC </function-graph/umn/configuring_functions/configuring_networks.html>`
:docs_otc:`configure a VPC <function-graph/umn/configuring_functions/configuring_networks.html>`
for the function to ensure that communication between the function and other cloud services takes
place in an isolated network environment.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/devguide/deployment/terraform/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ see following:
- :ref:`Deploy FunctionGraph Event Function from ZIP<ref_deploy_from_zip>`
- :ref:`Deploy FunctionGraph Event Function from OBS<ref_deploy_from_obs>`

For more complex deployment scenarios,see the "terraform" folder
For more complex deployment scenarios, see the "terraform" folder
in the other sample files, e.g.:

- Deploy FunctionGraph as container in: :github_repo_master:`container-event-express <samples-doc/container-event-express>`
41 changes: 22 additions & 19 deletions doc/source/devguide/deployment/terraform/deploy_from_obs/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Prerequisites
- running on Linux / Windows Subsystem for Linux (WSL)
- make installed
- curl installed
- Terraform installed and configured, see :ref:`terraform_setup<ref_terraform_setup>`.
- Terraform installed and configured, see :ref:`Terraform Setup<ref_terraform_setup>`.

What will be deployed
----------------------------------
Expand Down Expand Up @@ -78,18 +78,7 @@ The file ``provider.tf`` defines the provider configuration for this sample:
You might need to adapt the provider configuration to your needs,
especially the provider version and backend configuration for terraform state.

For variables used in provider.tf, see :ref:`terraform_setup<ref_terraform_setup>`.

.. note::
Currently the opentelekomcloud provider does not update FunctionGraph
function code after the code is uploaded to OBS,
so in this sample we also use the
`devops-rob/terracurl provider <https://registry.terraform.io/providers/devops-rob/terracurl/latest>`_
to update the function code using an API request to update FunctionGraph.
To use curl and the terracurl provider, the variable OTC_USER_NAME and OTC_PASSWORD
with your OTC credentials must be defined as environment variables.

See : `Feature request #3360 for opentelekomcloud provider <https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/issues/3360>`_.
For variables used in provider.tf, see :ref:`Terraform Setup<ref_terraform_setup>`.


variables.tf
Expand All @@ -112,9 +101,6 @@ The file ``code_from_obs_bucket.tf`` defines the obs bucket and obs bucket obje
:caption: code_from_obs_bucket.tf
:tab-width: 2

Additional to uploading the function code to OBS,
this will also call FunctionGraph API to update the function code after code changes.


function.tf
^^^^^^^^^^^^
Expand All @@ -129,15 +115,16 @@ The relevant part for deploying function code from zip file is:

.. code-block:: hcl

depends_on = [opentelekomcloud_obs_bucket_object.code_object]

###### relevant part for deploy function code from obs file ######
code_type = "obs"
code_url = format("https://%s/%s/%s",
opentelekomcloud_obs_bucket.codebucket.bucket_domain_name,
"code",
basename(var.zip_file_name)
)

# on change of the code object etag (hash) new code version will be deployed.
source_code_hash = opentelekomcloud_obs_bucket_object.code_object.etag
###### ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ######


Expand Down Expand Up @@ -217,7 +204,7 @@ Adapt the **BACKEND_CONFIG_*** variables in the Makefile
- endpoints={s3=\"https://obs.eu-de.otc.t-systems.com\"}


Adaptions in variables.tfv
Adaptions in variables.tf
""""""""""""""""""""""""""""""
Adapt the variables in the ``variables.tf``

Expand Down Expand Up @@ -269,9 +256,25 @@ FunctionGraph:
Testing the deployed function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For testing the deployed function, you will need to set the following
environment variables. These are used in "tokenFromUsername.sh" script to get Token
for Token-based authentication when calling FunctionGraph API.

.. list-table:: Environment Variables
:widths: 25 25
:header-rows: 1

* - Name
- Description
* - OTC_USER_NAME
- User name
* - OTC_USER_PASSWORD
- User password

Synchronous invocation
"""""""""""""""""""""""""""""
After the deployment is done, you can test the deployed function with the following command:

.. code-block:: bash

make test_deployed_sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Prerequisites
- running on Linux / Windows Subsystem for Linux (WSL)
- make installed
- curl installed
- Terraform/OpenTofu installed and Terraform/OpenTofu configured, see :ref:`terraform_setup<ref_terraform_setup>`.
- Terraform/OpenTofu installed and Terraform/OpenTofu configured, see :ref:`Terraform Setup<ref_terraform_setup>`.

What will be deployed
----------------------------------
Expand Down Expand Up @@ -76,7 +76,7 @@ The file ``provider.tf`` defines the provider configuration for this sample:
You might need to adapt the provider configuration to your needs,
especially the provider version and backend configuration for terraform state.

For variables used in provider.tf, see :ref:`terraform_setup<ref_terraform_setup>`.
For variables used in provider.tf, see :ref:`Terraform Setup<ref_terraform_setup>`.


variables.tf
Expand Down Expand Up @@ -240,6 +240,7 @@ Testing the deployed function
Synchronous invocation
"""""""""""""""""""""""""""""
After the deployment is done, you can test the deployed function with the following command:

.. code-block:: bash

make test_deployed_sync
Expand Down
2 changes: 2 additions & 0 deletions doc/source/devguide/deployment/terraform/setuptf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ See: `Terraform State <https://developer.hashicorp.com/terraform/language/state>
s3cmd \
--access_key=${OTC_SDK_AK} \
--secret_key=${OTC_SDK_SK} \
--host=https://obs.eu-de.otc.t-systems.com \
--host-bucket="%(bucket)s.obs.eu-de.otc.t-systems.com" \
--no-ssl \
mb s3://<bucket_name>
2 changes: 1 addition & 1 deletion doc/source/devguide/event_function/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FunctionGraph Event Functions

Event functions can be configured with event triggers and integrate
a variety of products (such as object storage service OBS,
distributed messaging service RabbitMQ version, cloud log service LTS, etc.).
distributed messaging service DMS, cloud log service LTS, etc.).

Types of Event Functions
------------------------------------
Expand Down
Loading