fnproject / fdk-go Goto Github PK
View Code? Open in Web Editor NEWGo language helper funcs for fn
License: Apache License 2.0
Go language helper funcs for fn
License: Apache License 2.0
I am trying to get the request URL and parameters. But I am unable to get it. What is the method I can use to get the request params?
What is a recommended way to manage multiple functions from code base perspective? My company want to move around 80 functionalities as OCI functions and I am wondering about the best way to organize these projects in a repository. Having 80 different git repos seems like an overkill. Do you have some best practices to organize multiple functions under same repo?
then they get tested and compile and look good in godoc ;)
i may not actually be working on this, just assigning so it pops up to remind me when i'm scouring for work... feel free to take this
cat payload.json | fn call app route
{"error":{"message":"container exit code 2"}}
ERROR: error calling function: status 502
❯ fn logs g app last
panic: interface conversion: interface {} is map[string]interface {}, not string
goroutine 1 [running]:
func/vendor/github.com/fnproject/fdk-go/utils.DoCloudEventOnce(0x7f86bdad2fd0, 0x6ad9c8, 0x6ced40, 0xc420074d50, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018, 0xc420104000, 0xc420074d80, ...)
/go/src/func/vendor/github.com/fnproject/fdk-go/utils/cloudevent.go:88 +0x6b9
func/vendor/github.com/fnproject/fdk-go/utils.DoCloudEvent(0x7f86bdad2fd0, 0x6ad9c8, 0x6ced40, 0xc420074d50, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018)
/go/src/func/vendor/github.com/fnproject/fdk-go/utils/cloudevent.go:102 +0xd9
func/vendor/github.com/fnproject/fdk-go/utils.Do(0x7f86bdad2fd0, 0x6ad9c8, 0xc42001606a, 0xa, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018)
/go/src/func/vendor/github.com/fnproject/fdk-go/utils/utils.go:47 +0x1f6
func/vendor/github.com/fnproject/fdk-go.Handle(0x6ccc60, 0x6ad9c8)
/go/src/func/vendor/github.com/fnproject/fdk-go/fdk.go:81 +0xce
main.main()
/go/src/func/func.go:20 +0x39
FDK-python context: https://github.com/fnproject/fdk-python/blob/master/fdk/context.py#L51
FDK-ruby context: https://github.com/fnproject/fdk-ruby/blob/master/lib/fdk/context.rb#L10
What else?
Hi there,
I'm trying to use fn and Golang to build an API that is callable from a browser. Within my function, I'd like to be able to handle CORS headers on the HTTP response, but I'm finding that fdk.setHeader()
is prepending text to my header name, but it doesn't do it for the Content-Type
examples provided.
So if I do this in my function:
fdk.SetHeader(out, "Access-Control-Allow-Origin", "*")
fdk.SetHeader(out, "Content-Type", "application/json")
I see this if you hit the function with curl -v
< Content-Type: application/json
< Fn-Http-H-Access-Control-Allow-Origin: *
So, I can set Content-Type
directly but not add CORS headers to the response so that the browser will handle it correctly.
Any guidance?
This repo should have some developer information including:
Currently the Go FDK doesn't handle errors in a user's function. As part of the FDK contract, the FDK should emit a 502 on a detectable error from the function. Not sure what the most idiomatic way of doing this from a user's perspective is. It could possibly involve the user setting a response status (500?) which the FDK then interprets as an error and gives a 502?
I am getting errors when working with some newer SDKs complaining that at least Go 1.12 is needed when trying to deploy my function. Can somebody do an update to the fnproject/go image on dockerhub to have a newer version included?
At this moment most of the officially supported FDKs have a different understanding of what the context is. The bigger difference is in the context API. This issue is all about standardizing the context across FDKs that Fn officially supports.
Some of the docs links need updating to the new repo.
Add a link to repo description text at the top of the page that links to https://fnproject.io. See the Fn, Docs, or Tutorials repo for an example.
See fnproject/fn#662 (issue) and fnproject/fn#724 (implementation).
Information that was previously stored in FN-prefixed headers has been promoted to first-class JSON fields. Details in the references above.
in order to be able to find the http method which was used to invocate a function of format json, the context passed into a handler method in fdk-go should contain the protocol part of the JSON payload (https://github.com/fnproject/fn/blob/master/docs/developers/function-format.md).
Using the following code for a json-format function shows that this information is not passed into the handler:
func main() {
fdk.Handle(fdk.HandlerFunc(testHandler))
}
func testHandler(ctx context.Context, in io.Reader, out io.Writer) {
fnctx := fdk.Context(ctx)
log.Println(fmt.Sprintf("%v", ctx))
log.Println(fmt.Sprintf("%v", fnctx.Config))
log.Println(fmt.Sprintf("%v", fnctx.Header))
}
Docker uses: http://tldp.org/LDP/abs/html/exitcodes.html
Make sure FDK does not allow functions to exit with these codes.
For example, 137 exit code is currently flagged as OOM in fn-agent, therefore functions should not be allowed to exit with 137 themselves.
It's really annoying that this project gets picked up and added:
require (
github.com/fnproject/fdk-go v0.0.0-20190102214815-bd24a5aa63cf
)
$ go mod why github.com/fnproject/fdk-go
# github.com/fnproject/fdk-go
github.com/kounta/superfluid/v6/node_modules/serverless/lib/plugins/create/templates/fn-go/hello
github.com/fnproject/fdk-go
At least tag it so the go.sum file has a version.
# fn init --runtime go hello
# go run func.go
panic: unknown format (fdk-go):
goroutine 1 [running]:
github.com/fnproject/fdk-go/utils.Do(0x14b3070, 0x128e178, 0x0, 0x0, 0x1380fe0, 0xc42000e010, 0x1381020, 0xc42000e018)
/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/utils/utils.go:51 +0x193
github.com/fnproject/fdk-go.Handle(0x1381a60, 0x128e178)
/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/fdk.go:81 +0xce
main.main()
/Users/jude/Working/Oracle/Fn/apps/hello/func.go:14 +0x39
exit status 2
Fixing this issue is simple:
# export FN_FORMAT="default"
# echo '{"name": "Johnny"}' | ./func
{"message":"Hello Johnny"}
However for users who are totally new to the fn project they usually have no idea about what is going wrong there . They just wanna make sure their function works properly locally before building a fn app.
Shall we develop a patch in go FDK side for telling user what is going wrong there and how to fix it rather that a panic without any prompt ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.