Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 0108da9

Browse files
authored
cronjob sample (#25)
1 parent 651978e commit 0108da9

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

samples/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Launching a KLR based function with `tm`
2+
3+
Check the `serverless.yaml` file which describes the function deployment.
4+
5+
See how the Cron Job trigger is defined
6+
7+
```
8+
tm deploy
9+
```
10+
11+
This will do the build of the function in the Knative cluster, deploy it as a Service and create a CronJob event source.

samples/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"context"
6+
"github.com/aws/aws-lambda-go/lambda"
7+
)
8+
9+
type MyEvent struct {
10+
Name string `json:"name"`
11+
}
12+
13+
func HandleRequest(ctx context.Context, name MyEvent) (string, error) {
14+
return fmt.Sprintf("Hello %s!", name.Name ), nil
15+
}
16+
17+
func main() {
18+
lambda.Start(HandleRequest)
19+
}

samples/serverless.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
service: serverless-foo
2+
description: "cron test with KLR"
3+
4+
provider:
5+
name: triggermesh
6+
7+
functions:
8+
goklr:
9+
source: main.go
10+
runtime: https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/go-1.x/buildtemplate.yaml
11+
description: "klr go"
12+
environment:
13+
FUNCTION: go-klr
14+
events:
15+
- schedule:
16+
rate: "*/1 * * * *"
17+
data: '{"Name":"sebgoa"}'

0 commit comments

Comments
 (0)