Skip to content

Add OpenFaaS function pattern examples in Go, Python, and Node.js - #1

Draft
welteki wants to merge 1 commit into
openfaas:masterfrom
welteki:add-function-pattern-examples
Draft

Add OpenFaaS function pattern examples in Go, Python, and Node.js#1
welteki wants to merge 1 commit into
openfaas:masterfrom
welteki:add-function-pattern-examples

Conversation

@welteki

@welteki welteki commented Sep 2, 2026

Copy link
Copy Markdown
Member

Description

Adds self-contained example functions for the three OpenFaaS function patterns : Director, Fan-out, and Singleton, in Go, Python, and Node.js. Each example ships with its own stack.yaml and function directories so it can be built and deployed independently with faas-cli up.

  • Director (Go, Python, Node.js) — telemetry-workflow validates a sensor reading, invokes temperature and battery checks in parallel, and combines the results into an ok or alert response.
  • Fan-out (Go, Python, Node.js) — fan-out submits each URL in a batch as an async url-check invocation and returns a summary immediately.
  • Singleton (Go, Python) — notification-hub broadcasts to all open SSE clients while scaling labels keep a single replica running.

Motivation and context

Adds example functions for the Director, Fan-out, and Singleton patterns, as referenced in the OpenFaaS docs.

How has this been tested

All example functions have been built and deployed to an OpenFaaS cluster and tested with the invocation instructions described in the corresponding OpenFaaS docs pages.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
@welteki
welteki force-pushed the add-function-pattern-examples branch from 55ba65b to 2d3c904 Compare September 2, 2026 12:51
@reviewfn

This comment has been minimized.

@reviewfn

reviewfn Bot commented Sep 2, 2026

Copy link
Copy Markdown

AI Pull Request Overview

Disclaimer: This review was generated by automated AI and may contain errors. Do not trust its outputs without human verification.

Summary

  • Adds OpenFaaS Director examples for Go, Python, and Node.js.
  • Adds OpenFaaS Fan-out examples for Go, Python, and Node.js.
  • Adds Singleton SSE notification-hub examples for Go and Python.
  • Includes per-example stack.yaml, handler code, tests, and README material.
  • The main handler logic is generally straightforward and consistent across languages.
  • One reproducibility issue blocks the documented Go quickstarts on clean machines.

Approval rating (1-10)

7/10. The examples are mostly coherent, but the Go documentation misses a required template setup step for first-time users.

Summary per file

Summary per file
File path Summary
.gitignore Adds common local build and editor ignores.
README.md Introduces examples and root build instructions.
go/director/* Adds Go Director stack, handlers, tests, and usage docs.
go/fan-out/* Adds Go async fan-out stack, handlers, tests, and usage docs.
go/singleton/* Adds Go SSE singleton stack, handler, tests, and usage docs.
node/director/* Adds Node.js Director stack, handlers, tests, and docs.
node/fan-out/* Adds Node.js async fan-out stack, handlers, tests, and docs.
python/director/* Adds Python Director stack, handlers, tests, tox config, and docs.
python/fan-out/* Adds Python async fan-out stack, handlers, tests, tox config, and docs.
python/singleton/* Adds Python Flask SSE singleton stack, handler, tests, tox config, and docs.

Overall Assessment

The PR is close to mergeable from a code-structure perspective: the examples are self-contained, validate inputs, set downstream timeouts, and include tests around the main control-flow paths. The main issue is documentation reproducibility for the Go examples. The Go stacks use lang: golang-middleware, but the root quickstart and Go example READMEs invoke faas-cli up without first pulling that template. Python and Node examples include their template pull commands, so Go users following the documented clean-machine path are likely to fail before the examples build.

Detailed Review

Detailed Review

Medium: Go quickstarts omit the required template pull step

The root README starts the example flow with cd go/director and faas-cli up --tag=digest (README.md:24), and each Go README repeats faas-cli up --tag=digest without pulling the Go template first (go/director/README.md:21, go/fan-out/README.md:11, go/singleton/README.md:21). Those stacks all use lang: golang-middleware (go/director/stack.yaml:7, go/fan-out/stack.yaml:7, go/singleton/stack.yaml:7). On a clean workstation, faas-cli up depends on the language template already being present locally; otherwise the build path fails before users can deploy or try the examples.

The Python and Node READMEs already include the corresponding faas-cli template store pull ... command, so the Go docs should match that pattern. For example:

faas-cli template store pull golang-middleware
faas-cli up --tag=digest

Apply the same setup step to the root Go quickstart or add a shared prerequisite that explicitly covers the Go template.

AI agent details.

Agent processing time: 2m52.566s
Environment preparation time: 3.205s
Total time from webhook: 2m59.009s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant