Run Prettier

This commit is contained in:
Philipp Muens 2019-11-04 12:25:26 +01:00
parent 5e600cfc2e
commit 1eefbb0fef
28 changed files with 125 additions and 154 deletions

View File

@ -1,4 +1,3 @@
# Tencent-scf - Create
Creates a new service in the current working directory based on the provided template.
@ -20,6 +19,7 @@ serverless create --template tencent-nodejs --path myService
```bash
serverless create --template-url https://github.com/serverless/serverless/tree/master/lib/plugins/create/templates/tencent-nodejs --path myService
```
## Options
- `--template` or `-t` The name of one of the available templates. **Required if --template-url and --template-path are not present**.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Deploy Function
The `sls deploy function` command deploys an individual SCF function when there is any change in the function. This is a much faster way of deploying changes in code.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Deploy List
The `sls deploy list [functions]` command will list information about your deployments.

View File

@ -1,4 +1,3 @@
# Tencent-scf - deploy
The `sls deploy` command deploys your entire service. Run this command when you have made infrastructure changes (i.e., you edited `serverless.yml`). Use `serverless deploy function -f myFunction` when you have made code changes and you want to quickly upload your updated code to Tencent SCF (Serverless Cloud Functions) or just change function configuration.
@ -31,7 +30,6 @@ serverless deploy
This is the simplest deployment usage possible. With this command Serverless will deploy your service to the defined
provider in the default stage (`dev`) to the default region (`ap-guangzhou`).
### Deployment with stage and region options
```bash

View File

@ -1,4 +1,3 @@
# Tencent-scf - Info
Displays information about the deployed service, such as runtime, region, stage and function list.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Install
Installs a service from a GitHub URL in the current working directory.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Invoke
Invokes deployed function. It allows to send event data to the function, read logs and display other important information of the function invocation.
@ -12,7 +11,7 @@ serverless invoke --function functionName
- `--function` or `-f` The name of the function in your service that you want to invoke. **Required**.
- `--stage` or `-s` The stage in your service you want to invoke your function in.
- `--region` or `-r` The region in your stage that you want to invoke your function in.
- `--data` or `-d` String data to be passed as an event to your function.
- `--data` or `-d` String data to be passed as an event to your function.
- `--path` or `-p` The path to a json file with input data to be passed to the invoked function. This path is relative to the root directory of the service.
## Examples

View File

@ -1,4 +1,3 @@
# Tencent-scf - Logs
Lets you watch the logs of a specific function deployed in Tencent Cloud.
@ -15,13 +14,12 @@ serverless logs -f hello -t
- `--function` or `-f` The function you want to fetch the logs for. **Required**
- `--stage` or `-s` The stage you want to view the function logs for. If not provided, the plugin will use the default stage listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `dev` stage.
- `--region` or `-r` The region you want to view the function logs for. If not provided, the plugin will use the default region listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `ap-guangzhou` region.
- `--startTime` A specific unit in time to start fetching logs from (ie: `2019-7-12 00:00:00` ).
- `--startTime` A specific unit in time to start fetching logs from (ie: `2019-7-12 00:00:00` ).
- `--tail` or `-t` You can optionally tail the logs and keep listening for new logs in your terminal session by passing this option.
- `--interval` or `-i` If you choose to tail the output, you can control the interval at which the framework polls the logs with this option. The default is `1000`ms.
## Examples
**Note:** There's a small lag between invoking the function and actually having the log event registered in Tencent Cloud Log Service. So it takes a few seconds for the logs to show up right after invoking the function.
```bash
@ -30,10 +28,8 @@ serverless logs -f hello
This will fetch the logs from last 10 minutes as startTime was not given.
```bash
serverless logs -f hello -t
```
Serverless will tail the function log output and print new log messages coming in starting from 10 seconds ago.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Metrics
Lets you watch the metrics of a specific function.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Remove
The `sls remove` command will remove the deployed service, defined in your current working directory, from the provider.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Rollback
Rollback a service to a specific deployment.
@ -16,7 +15,6 @@ If `timestamp` is not specified, Framework will show your existing deployments.
## Examples
At first you want to run `serverless deploy list` to show your existing deployments. This will provide you with a list of the deployments stored in your COS bucket. You can then use the timestamp of one of these deployments to rollback to this specific deployment.
**Example:**

View File

@ -1,4 +1,3 @@
# CKafka (Cloud Kafka)
## Using a pre-existing CKafka topic
@ -11,14 +10,14 @@ functions:
handler: index.main_handler
runtime: Nodejs8.9
events:
- ckafka:
name: ckafka_trigger
parameters:
name: ckafka-2o10hua5 # ckafka-id
topic: test
maxMsgNum: 999
offset: latest
enable: true
- ckafka:
name: ckafka_trigger
parameters:
name: ckafka-2o10hua5 # ckafka-id
topic: test
maxMsgNum: 999
offset: latest
enable: true
```
**Note:** CKafka triggers are enabled by default, and the consumer of CKafka will start to get the message from the `latest` offset.
@ -33,8 +32,8 @@ When the specified CKafka topic receives a message, the backend consumer module
{
"Ckafka": {
"topic": "test-topic",
"partition":1,
"offset":36,
"partition": 1,
"offset": 36,
"msgKey": "None",
"msgBody": "Hello from Ckafka!"
}
@ -42,12 +41,12 @@ When the specified CKafka topic receives a message, the backend consumer module
{
"Ckafka": {
"topic": "test-topic",
"partition":1,
"offset":37,
"partition": 1,
"offset": 37,
"msgKey": "None",
"msgBody": "Hello from Ckafka again!"
}
}
]
}
```
```

View File

@ -1,4 +1,3 @@
# CMQ (Cloud Message Queue)
## Using a pre-existing topic
@ -11,11 +10,11 @@ functions:
handler: index.main_handler
runtime: Nodejs8.9
events:
- cmq:
name: cmq_trigger
parameters:
name: test-topic
enable: true
- cmq:
name: cmq_trigger
parameters:
name: test-topic
enable: true
```
**Note:** CMQ triggers are enabled by default.
@ -42,4 +41,4 @@ When receiving a message, the specified CMQ Topic sends the following event data
}
]
}
```
```

View File

@ -1,7 +1,5 @@
## COS (Cloud Object Storage)
## Event Definition
This example sets up a `COS` event which will trigger the `function_one` function whenever an object is uploaded to the `cli-appid.cos.ap-beijing.myqcloud.com` under your account.
@ -15,22 +13,21 @@ functions:
runtime: Nodejs8.9
events:
- cos:
name: cli-appid.cos.ap-beijing.myqcloud.com
parameters:
bucket: cli-appid.cos.ap-beijing.myqcloud.com
filter:
prefix: filterdir/
suffix: .jpg
events: cos:ObjectCreated:*
enable: true
- cos:
name: cli-appid.cos.ap-beijing.myqcloud.com
parameters:
bucket: cli-appid.cos.ap-beijing.myqcloud.com
filter:
prefix: filterdir/
suffix: .jpg
events: cos:ObjectCreated:*
enable: true
```
- Use `events` in COS trigger to set the specific trigger event. In the example, the function is called whenever an object is uploaded to the bucket.
- Use filter rules to configure COS trigger, In the example, the function is called whenever an image with `.jpg` extension is uploaded to folder `filterdir` in the bucket.
See the documentation about the [COS Trigger](https://intl.cloud.tencent.com/document/product/583/9707) to get more detail.
## Event Message Structure for COS Trigger
@ -39,41 +36,43 @@ When an object creation or deletion event occurs in the specified COS bucket, ev
```json
{
"Records": [{
"cos": {
"cosSchemaVersion": "1.0",
"cosObject": {
"url": "http://testpic-1253970026.cos.ap-chengdu.myqcloud.com/testfile",
"meta": {
"x-cos-request-id": "NWMxOWY4MGFfMjViMjU4NjRfMTUyMV8yNzhhZjM=",
"Content-Type": ""
},
"vid": "",
"key": "/1253970026/testpic/testfile",
"size": 1029
},
"cosBucket": {
"region": "cd",
"name": "testpic",
"appid": "1253970026"
},
"cosNotificationId": "unkown"
"Records": [
{
"cos": {
"cosSchemaVersion": "1.0",
"cosObject": {
"url": "http://testpic-1253970026.cos.ap-chengdu.myqcloud.com/testfile",
"meta": {
"x-cos-request-id": "NWMxOWY4MGFfMjViMjU4NjRfMTUyMV8yNzhhZjM=",
"Content-Type": ""
},
"vid": "",
"key": "/1253970026/testpic/testfile",
"size": 1029
},
"event": {
"eventName": "cos:ObjectCreated:*",
"eventVersion": "1.0",
"eventTime": 1545205770,
"eventSource": "qcs::cos",
"requestParameters": {
"requestSourceIP": "192.168.15.101",
"requestHeaders": {
"Authorization": "q-sign-algorithm=sha1&q-ak=AKIDQm6iUh2NJ6jL41tVUis9KpY5Rgv49zyC&q-sign-time=1545205709;1545215769&q-key-time=1545205709;1545215769&q-header-list=host;x-cos-storage-class&q-url-param-list=&q-signature=098ac7dfe9cf21116f946c4b4c29001c2b449b14"
}
},
"eventQueue": "qcs:0:lambda:cd:appid/1253970026:default.printevent.$LATEST",
"reservedInfo": "",
"reqid": 179398952
}
}]
"cosBucket": {
"region": "cd",
"name": "testpic",
"appid": "1253970026"
},
"cosNotificationId": "unkown"
},
"event": {
"eventName": "cos:ObjectCreated:*",
"eventVersion": "1.0",
"eventTime": 1545205770,
"eventSource": "qcs::cos",
"requestParameters": {
"requestSourceIP": "192.168.15.101",
"requestHeaders": {
"Authorization": "q-sign-algorithm=sha1&q-ak=AKIDQm6iUh2NJ6jL41tVUis9KpY5Rgv49zyC&q-sign-time=1545205709;1545215769&q-key-time=1545205709;1545215769&q-header-list=host;x-cos-storage-class&q-url-param-list=&q-signature=098ac7dfe9cf21116f946c4b4c29001c2b449b14"
}
},
"eventQueue": "qcs:0:lambda:cd:appid/1253970026:default.printevent.$LATEST",
"reservedInfo": "",
"reqid": 179398952
}
}
]
}
```
```

View File

@ -1,4 +1,3 @@
# API Gateway
Tencent Serverless Cloud Functions can create function based API endpoints through API Gateway.
@ -18,13 +17,13 @@ functions:
runtime: Nodejs8.9
events:
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId: # if you don't specify an exsiting serviceId, a new service will be created by default.
httpMethod: POST
integratedResponse: true # enable integrated response
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId: # if you don't specify an exsiting serviceId, a new service will be created by default.
httpMethod: POST
integratedResponse: true # enable integrated response
```
```javascript
@ -35,9 +34,9 @@ exports.main_handler = async (event, context, callback) => {
isBase64Encoded: false,
statusCode: 200,
headers: { 'Content-Type': 'text/html' },
body: 'hello world'
}
}
body: 'hello world',
};
};
```
## Event message structures of integration request for API Gateway trigger
@ -70,7 +69,7 @@ When an API Gateway trigger receives a request, it sends the event data to the b
"queryStringParameters": {
"foo": "bar"
},
"headerParameters":{
"headerParameters": {
"Refer": "10.0.2.14"
},
"stageVariables": {
@ -78,8 +77,8 @@ When an API Gateway trigger receives a request, it sends the event data to the b
},
"path": "/test/value",
"queryString": {
"foo" : "bar",
"bob" : "alice"
"foo": "bar",
"bob": "alice"
},
"httpMethod": "POST"
}

View File

@ -1,4 +1,3 @@
# Timer
The following config will attach a timer trigger and causes the function `function_one` to be called every 5 seconds. The configuration allows you to attach multiple timer triggers to the same function. You can use the `cron` syntax. Take a look at the [Timer documentation](https://intl.cloud.tencent.com/document/product/583/9708) for more details.
@ -39,7 +38,7 @@ functions:
## Specify Name of Timer
Name can be specified for a timer.
Name can be specified for a timer.
```yaml
events:
@ -53,9 +52,9 @@ When a timer trigger triggers a function, the following data structures are enca
```json
{
"Type":"timer",
"TriggerName":"EveryDay",
"Time":"2019-02-21T11:49:00Z",
"Message":"user define msg body"
"Type": "timer",
"TriggerName": "EveryDay",
"Time": "2019-02-21T11:49:00Z",
"Message": "user define msg body"
}
```

View File

@ -1,4 +1,3 @@
# Tencent Cloud - Credentials
The Serverless Framework needs access to account credentials for your Tencent Cloud account so that it can create and manage resources on your behalf.
@ -8,26 +7,30 @@ The Serverless Framework needs access to account credentials for your Tencent Cl
If you already have a Tencent Cloud account, skip to the next step to [create an CAM User and Access Key](#create-an-cam-user-and-access-key)
To create a Tencent Cloud account:
1. Open https://cloud.tencent.com/, and then choose Sign up.
2. Follow the online instructions.
- Part of the sign-up procedure involves entering a PIN using the phone keypad.
- Part of the sign-up procedure involves entering a PIN using the phone keypad.
## Create an IAM User and Access Key
Services in Tencent Cloud, such as SCF, require that you provide credentials when you access them to ensure that you have permission to access the resources owned by that service. To accomplish this Tencent Cloud recommends that you use Cloud Access Management (CAM).
You need to create credentials Serverless can use to create resources in your Project.
1. Login to your account and go to the [Cloud Access Management (CAM) page](https://console.cloud.tencent.com/cam/capi).
2. Click on **Access Key** and then **Create Key**.
3. View and copy the **APPID**, **SecretId** & **SecretKey** to a temporary place. (To get the SecretKey, you may need to enter a PIN using the phone keypad.)
4. Create a file named `credentials` containing the credentials that you have collected.
```ini
[default]
tencent_appid = 1251000000
tencent_secret_id = AKIDteBxxxxxxxxxxnZfk
tencent_secret_key = AKID2qsxxxxxxxxxxxxxtTo
```
Save the credentials file to a folder like`~/.tencent/credentials`. Copy the path of the file you saved.
## Update `serverless.yml` (optional)

View File

@ -1,4 +1,3 @@
# Tencent-SCF - Deploying
The Serverless Framework was designed to provision your Serverless Cloud Functions, Events and infrastructure Resources safely and quickly. It does this via a couple of methods designed for different types of deployments.
@ -15,7 +14,6 @@ Use this method when you have updated your Function, Event or Resource configura
**Note:** You can always enforce a deployment using the `--force` option, or specify a different configuration file name with the the `--config` option.
### Tips
- Use this in your CI/CD systems, as it is the safest method of deployment.
@ -44,7 +42,6 @@ Use this method when you have updated your Function, Event or Resource configura
- You can specify your own COS bucket which should be used to store all the deployment artifacts.
The `cosBucket` config which is nested under `provider` lets you e.g. set the `name` for this bucket. If you don't provide your own bucket, Serverless will create a bucket which by default.
## Deploy Function
This deployment method simply overwrites the zip file of the current function on Tencent Cloud.
@ -58,4 +55,4 @@ serverless deploy function --function myFunction
- Use this when you are developing and want to test because it's much faster.
- During development, people will often run this command several times, as opposed to `serverless deploy` which is only run when larger infrastructure provisioning is required.
Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options.
Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options.

View File

@ -1,4 +1,3 @@
# Tencent-SCF - Events
Simply put, events are the things that trigger your functions to run.

View File

@ -1,4 +1,3 @@
# Tencent-SCF - Functions
If you are using Tencent as a provider, all _functions_ inside the service are Tencent Serverless Cloud Functions.
@ -33,7 +32,7 @@ plugins:
functions:
function_one:
handler: index.main_handler
# description: Tencent Serverless Cloud Function
# description: Tencent Serverless Cloud Function
runtime: Nodejs8.9
# memorySilsze: 256
# timeout: 10
@ -81,7 +80,7 @@ service: myService
provider: # provider information
name: tencent
runtime: Nodejs8.9
memorySize: 512 # will be inherited by all functions
memorySize: 512 # will be inherited by all functions
functions:
functionOne:
@ -134,7 +133,7 @@ provider: # provider information
name: tencent
runtime: Nodejs8.9
credentials: ~/credentials
role: QCS_SCFExcuteRole # SCF default role to interact with other services.
role: QCS_SCFExcuteRole # SCF default role to interact with other services.
functions:
functionOne:
@ -145,6 +144,7 @@ functions:
The executing role `QCS_SCFExcuteRole` is used to grant the function code permissions to read and operate resources during execution.
Currently, this role has the following policies:
- QcloudSCFFullAccess
- QcloudCLSFullAccess
@ -191,4 +191,4 @@ functions:
TABLE_NAME: tableName2
```
Check out the [Environment Variables](./variables.md) for all the details and options.
Check out the [Environment Variables](./variables.md) for all the details and options.

View File

@ -1,4 +1,3 @@
# Tencent-scf - Installation
### Installing Node.js

View File

@ -1,4 +1,3 @@
# Tencent SCF - Introduction
The Serverless Framework helps you develop and deploy your Tencent SCF (Serverless Cloud Function), along with the Tencent infrastructure resources they require. It's a CLI that offers structure, automation and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events).
@ -64,10 +63,10 @@ functions: # Your "Functions"
function_two:
events:
- apigw:
name: hello_world_apigw
parameters:
stageName: release
httpMethod: ANY
name: hello_world_apigw
parameters:
stageName: release
httpMethod: ANY
```
When you deploy with the Framework by running `serverless deploy`, everything in `serverless.yml` is deployed at once.

View File

@ -1,4 +1,3 @@
# Tencent-SCF - Packaging
## Package CLI Command
@ -70,4 +69,4 @@ package:
exclude:
- tmp/**
- .git/**
```
```

View File

@ -1,4 +1,3 @@
# Plugins
A Plugin is custom Javascript code that creates new or extends existing commands within the Serverless Framework. The Serverless Framework is merely a group of Plugins that are provided in the core. If you or your organization have a specific workflow, install a pre-written Plugin or write a plugin to customize the Framework to your needs. External Plugins are written exactly the same way as the core Plugins.

View File

@ -1,4 +1,3 @@
# Quick Start
Complete the steps in this guide to install the Serverless Framework open-source CLI and deploy a sample Service on Tencent Cloud that reports deployment information and operational metrics to the Serverless Framework.
@ -52,7 +51,7 @@ Now that youve completed your setup, lets create and deploy a serverless S
1. Use the Serverless Framework open-source CLI to create a new Service with `tencent-nodejs`template.
```sh
````sh
# Create a new Serverless service/project
$ serverless create --template tencent-nodejs --path my-service
@ -62,7 +61,7 @@ $ serverless create --template tencent-nodejs --path my-service
# Change into the newly created directory
$ cd my-service
$ npm install
```
````
### Set up the credentials
@ -88,13 +87,13 @@ functions:
handler: index.main_handler
runtime: Nodejs8.9
events:
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId:
integratedResponse: true
httpMethod: ANY
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId:
integratedResponse: true
httpMethod: ANY
```
### Deploy the Service
@ -104,6 +103,7 @@ Use this command to deploy your service for the first time and after you make ch
```bash
serverless deploy
```
More information in [deploy command](../cli-reference/deploy.md)
### Test your Service
@ -121,6 +121,7 @@ Invokes a Function and returns logs.
```bash
serverless invoke -f hello
```
More information in [invoke command](../cli-reference/invoke.md)
### Fetch the Function Logs
@ -135,7 +136,7 @@ serverless logs -f hello -t
### Remove your Service
If at any point you no longer need your Service, you can run the following command to remove the Functions, Events and Resources that were created. This will delete the resources you created and ensure that you don't incur any unexpected charges.
If at any point you no longer need your Service, you can run the following command to remove the Functions, Events and Resources that were created. This will delete the resources you created and ensure that you don't incur any unexpected charges.
```sh
serverless remove

View File

@ -1,4 +1,3 @@
# Tencnet SCF - Services
A `service` is like a project. It's where you define your Tencent Serverless Cloud Functions and the `events` that trigger them, all in a file called `serverless.yml`.
@ -43,7 +42,6 @@ Here are the available runtimes for Tencent Serverless Cloud Function:
- tencent-php
- tencent-go
Check out the [create command docs](../cli-reference/create) for all the details and options.
## Contents
@ -83,13 +81,13 @@ functions:
handler: index.main_handler
runtime: Nodejs8.9
events:
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId:
integratedResponse: true
httpMethod: ANY
- apigw:
name: hello_world_apigw
parameters:
stageName: release
serviceId:
integratedResponse: true
httpMethod: ANY
```
### index.js

View File

@ -1,4 +1,3 @@
# Tencent-SCF Variables
Variables allow users to dynamically replace config values in `serverless.yml` config. They are especially useful when providing secrets for your service to use and when you are working with multiple stages.
@ -24,5 +23,3 @@ provider:
variables:
ENV_FIRST: ${env:TENCENTCLOUD_APPID}
```

View File

@ -1,4 +1,3 @@
# Tencent-SCF Workflow Tips
Quick recommendations and tips for various processes.
@ -6,7 +5,7 @@ Quick recommendations and tips for various processes.
### Development Workflow
1. Write your functions
2. Use `serverless deploy` only when you've made changes to `serverless.yml` and in CI/CD systems.
2. Use `serverless deploy` only when you've made changes to `serverless.yml` and in CI/CD systems.
3. Use `serverless deploy function -f myFunction` to rapidly deploy changes when you are working on a specific Serverless Cloud Function.
4. Use `serverless invoke -f myFunction` to test your functions on Tencent Cloud.
5. Open up a separate tab in your console and stream logs in there via `serverless logs -f myFunction -t`.
@ -77,8 +76,9 @@ serverless logs -f [FUNCTION NAME] -s [STAGE NAME] -r [REGION NAME]
```
##### Info
See information about your deployed/undeployed functions by running the info command in your service directory.
```
serverless info
```
```