Skip to content

Commit 58b2caa

Browse files
committed
Updated Kafka docs and Go examples move to new template
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 40ff9b5 commit 58b2caa

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

docs/deployment/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ You can usually do one of the following:
238238
Example:
239239

240240
```bash
241-
faas-cli new --lang go test-this
241+
faas-cli new --lang golang-middleware test-this
242242

243243
faas-cli build -f test-this.yml
244244

docs/openfaas-pro/dashboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Example snippet from stack.yml:
6969
```yaml
7070
functions:
7171
cows:
72-
lang: go
72+
lang: golang-middleware
7373
handler: ./cows
7474
image: alexellis2/cows:0.1
7575
labels:

docs/openfaas-pro/kafka-events.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The topics you need to connect to functions are set on a connector.
2727

2828
A single connector can have either a single topic, or a comma-separated list of topics.
2929

30-
Customers tend to prefer to deploy a single copy of the connector for each topic, so that they can be scaled to match the number of consumers set on the partition.
30+
It is recommended to deploy one connector per topic, so that it can be scaled to match the number of consumers set on the partition. I.e. a topic named `payment.created` which has a partition size of 3, should have three replicas of the configured connector deployed.
3131

3232
But it's also possible to use a single connector and pass in multiple topics i.e. `payment.created,customer.onboarded,invoice.generate`.
3333

@@ -36,8 +36,8 @@ Your function(s) can then subscribe to one or more topics by setting the topic a
3636
Create a new function:
3737

3838
```bash
39-
export OPENFAAS_PREFIX=ghcr.io/openfaas
40-
faas-cli new --lang go provision-customer
39+
export OPENFAAS_PREFIX=docker.io/alexellis2
40+
faas-cli new --lang golang-middleware provision-customer
4141
```
4242

4343
Now add an annotation for the `payment.created` topic, so that the `provision-customer` function is invoked for any message received:
@@ -52,9 +52,9 @@ functions:
5252
provision-customer:
5353
annotations:
5454
topic: payment.created
55-
lang: go
55+
lang: golang-middleware
5656
handler: ./provision-customer
57-
image: ghcr.io/openfaas:provision-customer
57+
image: docker.io/alexellis2/provision-customer:latest
5858
```
5959
6060
Now deploy your function, and publish an event to your Kafka broker on the `payment.created` topic.
@@ -71,17 +71,31 @@ For headers and metadata:
7171
* `X-Kafka-Offset` - the offset in Kafka that the message was received on
7272
* `X-Kafka-Key` - if set on the message, the key of the message in Kafka
7373

74-
The default content-type is configured as `text/plain`, but can be changed to another content-type such as `application/json` or `application/octet-stream` by the [values.yaml file](https://github.com/openfaas/faas-netes/blob/master/chart/kafka-connector/values.yaml) for the connector.
74+
If a binary message key is submitted to a Kafka topic, then the value will be base64-encoded and passed to the function as the `X-Kafka-Key` header, along with an additional header `X-Kafka-Key-Enc` with a value of `b64` to indicate that the value is base64-encoded.
7575

76-
Most templates make these variables available through their request or context object, for example:
76+
The connector will invoke functions using the default content type of `text/plain`, however [this can be overridden in the Helm chart](https://github.com/openfaas/faas-netes/blob/master/chart/kafka-connector/values.yaml) to i.e. `application/json or whatever is required.
77+
78+
Most templates make HTTP headers sent by the connector available through their request or context object, for example:
7779

7880
* [golang-middleware](/languages/go/)
7981
* [python3-http](/languages/python/)
8082
* [node22](/languages/node/)
8183

8284
For detailed examples with Node.js, see: [Serverless For Everyone Else](http://store.openfaas.com/l/serverless-for-everyone-else)
8385

84-
For detailed examples with Go, see: [Everyday Golang (Premium Edition)](https://openfaas.gumroad.com/l/everyday-golang)
86+
For detailed examples with Go, see: [Everyday Golang (Premium Edition only)](https://openfaas.gumroad.com/l/everyday-golang)
87+
88+
### Message lifecycle and retries
89+
90+
**Default synchronous invocation**
91+
92+
By default, the Kafka connector will invoke functions using the Gateway's synchronous invocation endpoint. If a response is returned by a function, then the message will be considered as processed and will be acknowledged on the topic.
93+
94+
**Automatic retries via the queue-worker**
95+
96+
If you would like to retry messages then you can switch the connector to use asynchronous invocations. Asynchronous invocations are executed using the queue-worker.
97+
98+
The queue-worker has a set of default retry values set via the Helm chart. They can also be overridden for each function using the documentation on the [Retries page](/openfaas-pro/retries).
8599

86100
## See also
87101

docs/openfaas-pro/scale-to-zero.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ This is achieved through adding a label to the stack.yml file:
5151

5252
The ttl.sh registry is a free service that can be used to publish a container image without needing to log into a registry.
5353

54-
Create a new function using the `go` template:
54+
Create a new function using the `golang-middleware` template:
5555

5656
```bash
5757
export OPENFAAS_PREFIX=ttl.sh/daily-job:1h
58-
faas-cli new --lang go daily-job
58+
faas-cli new --lang golang-middleware daily-job
5959
```
6060

6161
Now add the labels from above, we'll use a 15 minute timeout.
@@ -70,7 +70,7 @@ provider:
7070

7171
functions:
7272
daily-job:
73-
lang: go
73+
lang: golang-middleware
7474
handler: ./daily-job
7575
image: ttl.sh/daily-job:1h
7676
labels:

docs/reference/private-registries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The secret *must* be created in the `openfaas-fn` namespace or the equivalent if
115115
Create a sample function with a `--prefix` variable:
116116

117117
```sh
118-
faas-cli new --lang go private-fn --prefix=registry:port/repo
118+
faas-cli new --lang golang-middleware private-fn --prefix=registry:port/repo
119119
```
120120

121121
Update the `stack.yml` file and add a reference to the new secret:

docs/reference/yaml.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The YAML file can hold one to many functions separated by separate entries.
2121
Example:
2222

2323
```bash
24-
$ faas-cli new --lang go fn1
25-
$ faas-cli new --lang go fn2 --append=fn1.yml
24+
$ faas-cli new --lang golang-middleware fn1
25+
$ faas-cli new --lang golang-middleware fn2 --append=fn1.yml
2626
```
2727

2828
Produces:
@@ -34,11 +34,11 @@ provider:
3434

3535
functions:
3636
fn1:
37-
lang: go
37+
lang: golang-middleware
3838
handler: ./fn1
3939
image: fn1:latest
4040
fn2:
41-
lang: go
41+
lang: golang-middleware
4242
handler: ./fn2
4343
image: fn2:latest
4444
```
@@ -144,7 +144,7 @@ An example of a build argument may be for enabling Go modules, or a HTTP_PROXY a
144144
functions:
145145
with_go_modules:
146146
handler: ./with_go_modules
147-
lang: go
147+
lang: golang-middleware
148148
build_args:
149149
HTTP_PROXY: http://squid.corp.ad.example.com
150150
GO111MODULE: on
@@ -235,7 +235,7 @@ provider:
235235
gateway: http://127.0.0.1:8080
236236
functions:
237237
low:
238-
lang: go
238+
lang: golang-middleware
239239
handler: ./low
240240
image: alexellis2/low:latest
241241
constraints:

0 commit comments

Comments
 (0)