func icon indicating copy to clipboard operation
func copied to clipboard

Go Instanced functions

Open matzew opened this issue 11 months ago • 3 comments

Currently we have zero documentation how to create an instanced Go-lang function, on our developer guide:

  • https://github.com/knative/func/blob/main/docs/function-templates/golang.md

Perhaps it would also make sense to change the default to be instanced, and than just document how to get the static handler, in case folks want that.

matzew avatar Dec 18 '24 10:12 matzew

Building the func (e.g. via main) branch, I see this:

./func create --help                                         

NAME
	func create - Create a function

SYNOPSIS
	func create [-l|--language] [-t|--template] [-r|--repository]
	            [-c|--confirm]  [-v|--verbose]  [path]

DESCRIPTION
	Creates a new function project.

	  $ func create -l node

	Creates a function in the current directory '.' which is written in the
	language/runtime 'node' and handles HTTP events.

	If [path] is provided, the function is initialized at that path, creating
	the path if necessary.

	To complete this command interactively, use --confirm (-c):
	  $ func create -c

	Available Language Runtimes and Templates:
	  Language     Template
	  --------     --------
	  go           cloudevents
	  go           http
	  node         cloudevents
	  node         http
	  ...
	  some more
	  ...
	  typescript   cloudevents
	  typescript   http
	  

	To install more language runtimes and their templates see 'func repository'.


EXAMPLES
	o Create a Node.js function in the current directory (the default path) which
	  handles http events (the default template).
	  $ func create -l node

	o Create a Node.js function in the directory 'myfunc'.
	  $ func create -l node myfunc

	o Create a Go function which handles CloudEvents in ./myfunc.
	  $ func create -l go -t cloudevents myfunc
		

Usage:
  func create [flags]

Aliases:
  create, init

Flags:
  -c, --confirm             Prompt to confirm options interactively ($FUNC_CONFIRM)
  -l, --language string     Language Runtime (see help text for list) ($FUNC_LANGUAGE)
  -r, --repository string   URI to a Git repository containing the specified template ($FUNC_REPOSITORY)
  -t, --template string     Function template. (see help text for list) ($FUNC_TEMPLATE) (default "http")
  -v, --verbose             Print verbose logs ($FUNC_VERBOSE)

I do not see any statement on how to get the instanced func. Or is that not possible yet?

matzew avatar Jan 13 '25 16:01 matzew

Hi Matthias,

Thank you this is in progress. Here's a quick update on the status: We now have full support for the instanced-base method signatures across all builders, so we can transition to the Instanced template, which includes inline documentation for how they work.

To be clear, this is just a documentation issue, as the new method signatures work in tandem with the legacy "static" handlers without needing to recreate the Function.

lkingland avatar Feb 04 '25 11:02 lkingland

My 2 cents: It would at least be convenient to have the possibility to scaffold an instanced function. I can look into that for a PR, but I guess we should first decide whether to have an additional coordinate to language and template, e.g. kind with a default being non-instanced to maintain compatibility OR wether it should simply be a different kind of template. Personally, I'd say the latter makes more sense, as it is the more flexible approach.

mwmahlberg avatar Mar 11 '25 07:03 mwmahlberg

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

github-actions[bot] avatar Jun 10 '25 01:06 github-actions[bot]