Skip to content

Document common function patterns and examples - #436

Open
welteki wants to merge 1 commit into
openfaas:masterfrom
welteki:docs/function-patterns
Open

Document common function patterns and examples#436
welteki wants to merge 1 commit into
openfaas:masterfrom
welteki:docs/function-patterns

Conversation

@welteki

@welteki welteki commented Sep 1, 2026

Copy link
Copy Markdown
Member

Description

Document common function patterns and add examples for each pattern.

Motivation and Context

Provide a concise reference for common function patterns and demonstrate them with examples.

  • I have raised an issue to propose this change (required)

How Has This Been Tested?

Verified the pages render correctly and the examples have been tested end-to-end.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

@reviewfn

This comment has been minimized.

@welteki
welteki force-pushed the docs/function-patterns branch from dbdd46a to d42b2a1 Compare September 1, 2026 14:46
@reviewfn

This comment has been minimized.

@welteki
welteki force-pushed the docs/function-patterns branch 2 times, most recently from 7865ffc to 4645b26 Compare September 1, 2026 15:23
@reviewfn

This comment has been minimized.

@welteki
welteki force-pushed the docs/function-patterns branch from 4645b26 to dcc9c5c Compare September 1, 2026 15:51
@reviewfn

This comment has been minimized.

@welteki
welteki force-pushed the docs/function-patterns branch from dcc9c5c to 0316aa8 Compare September 1, 2026 17:24
@reviewfn

This comment has been minimized.

@welteki
welteki marked this pull request as ready for review September 1, 2026 17:28
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
@welteki
welteki force-pushed the docs/function-patterns branch from 0316aa8 to e9bdba0 Compare September 2, 2026 13:00
@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 a new common function patterns section covering Director, async invocation, Fan-out, and Singleton.
  • Adds long-form Director, Fan-out, and Singleton examples with Go, Python, and Node.js snippets where applicable.
  • Updates language overview and language-specific examples lists to surface the new pattern docs.
  • Moves the Go language page to docs/languages/go/index.md and updates navigation accordingly.
  • Enables linked content tabs in MkDocs so language tabs stay synchronized across examples.
  • The content is useful and well structured, but two example-level issues should be fixed before publication.

Approval rating (1-10)

7/10. Strong addition overall, with copy/paste risks in the Singleton and Fan-out examples that should be addressed before merge.

Summary per file

Summary per file
File path Summary
docs/languages/go/index.md Renames Go page and adds pattern example links.
docs/languages/node.md Adds Director and Fan-out pattern links.
docs/languages/overview.md Adds entry point to common function patterns.
docs/languages/patterns/director.md Adds multi-language telemetry workflow Director example.
docs/languages/patterns/fan-out.md Adds multi-language async URL health-check Fan-out example.
docs/languages/patterns/index.md Adds overview of Director, async, Fan-out, and Singleton patterns.
docs/languages/patterns/singleton.md Adds Go and Python SSE singleton notification hub example.
docs/languages/python/index.md Adds pattern example links to Python docs.
mkdocs.yml Adds pattern pages to nav and enables linked tabs.

Overall Assessment

The PR adds a coherent pattern reference with practical examples and generally good warnings around timeouts, retries, scaling, and SSRF. The main risk is that these pages are tutorial material readers will copy directly. The Go singleton example lacks the heartbeat behavior that the Python example includes, which makes it fragile for long-lived SSE subscriptions. The Fan-out cancellation wording also points readers at cancelling already accepted work without explaining the race with queue-worker execution, which can make the documented behavior look reliable when it is inherently best-effort.

Detailed Review

Detailed Review

Findings

Medium: Add keep-alive writes to the Go SSE singleton example

docs/languages/patterns/singleton.md:117

The Go SSE example writes : connected once and then only writes again when a notification is published. The same page correctly notes that long-lived connections require suitable gateway, ingress, and load-balancer timeouts, and the Python version sends periodic : keep-alive comments every 15 seconds. Without equivalent heartbeats, an idle Go subscriber can be closed by the watchdog path, gateway, ingress, or load balancer before the next notification arrives, so a reader copying the Go example gets a singleton hub that appears to work only while messages are frequent. Add a time.Ticker case to subscribe that periodically writes an SSE comment and flushes it.

Low: Make async cancellation wording best-effort rather than deterministic

docs/languages/patterns/fan-out.md:930

The "Track and cancel checks" section says each call ID identifies one queued check and then shows DELETE /async-function/<call-id>. In this example the queue-worker may already have dequeued or completed a short URL check by the time the caller receives and uses the call ID, so readers can interpret the cancellation as a reliable way to stop each accepted check. Please clarify that cancellation is best-effort and only applies while the async request is still pending or cancellable in the queue lifecycle. For example: "If a check is still pending, request cancellation with...".

Content review

No blocking findings beyond the two issues above.

The new pattern overview has a clear audience fit: it gives readers a short decision table before sending them into full examples. The Director page has the strongest narrative, moving from validation to parallel checks and then to timeout planning. The Fan-out page usefully calls out SSRF risk and callback ordering, but the cancellation section needs more precise lifecycle language. The Singleton page explains the one-replica tradeoff well and appropriately warns that in-memory state is not durable; adding Go heartbeats would make the implementation match that operational advice.

AI agent details.

Agent processing time: 1m50.111s
Environment preparation time: 3.535s
Total time from webhook: 1m58.638s

Comment thread mkdocs.yml
- Readiness checks for slow start-up: ./languages/python/examples/readiness.md
- Node: ./languages/node.md
- Go: ./languages/go.md
- Go: ./languages/go/index.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks breaking.. same for Python?

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.

2 participants