New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: init declarative functions go #92
Conversation
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some significant changes and added a handful of example functions.
) | ||
|
||
func init() { | ||
log.Print("Listening to function \"hello\" at http://localhost:8080/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration should be done in the function package conformance/function/function.go
, or a new one if you prefer. The GCP buildpacks ignore the main.go
, so this would not work in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the conformance main.go
s are just for testing – we're mirroring the existing testing main.go
s here.
I think we're going to need multiple conformance/function/function.go
packages to be able to test multiple different declarative functions if going that route.
TODO: Look at modifying test handlers in for _, tc := range tests {
h := http.NewServeMux()
if err := registerEventFunction("/", tc.fn, h); err != nil {
t.Fatalf("registerEventFunction(): %v", err)
}
srv := httptest.NewServer(h)
defer srv.Close() -> for _, tc := range tests {
handler = http.NewServeMux()
if err := RegisterEventFunctionContext(context.Background(), "/", tc.fn); err != nil {
t.Fatalf("registerEventFunction(): %v", err)
}
srv := httptest.NewServer(handler)
defer srv.Close() |
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! It's pretty much there. Mostly just nits and a couple of implementation details.
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you modify the PR description too so that the function registration happens in outside of main.go
?
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Done! |
🤖 I have created a release \*beep\* \*boop\* --- ## [1.4.0](https://www.github.com/GoogleCloudPlatform/functions-framework-go/compare/v1.3.0...v1.4.0) (2021-11-02) ### Features * init declarative functions go ([#92](https://www.github.com/GoogleCloudPlatform/functions-framework-go/issues/92)) ([ae1bf32](https://www.github.com/GoogleCloudPlatform/functions-framework-go/commit/ae1bf320be8ff6eef0863a5c5961ff9413d011a8)) ### Bug Fixes * use standard RFC3339 time formatting ([#89](https://www.github.com/GoogleCloudPlatform/functions-framework-go/issues/89)) ([8218243](https://www.github.com/GoogleCloudPlatform/functions-framework-go/commit/82182437506b131034137b7d6cbb24e522bd213e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Declarative functions interface for the Go Functions Framework.
Example usage
main.go
Sample main package used for local development only.
function.go
Sample declarative function, registered in
init
.Features
HTTP
andCloudEvent
that allows you to declaratively register a function with a given name.testdata
.README.md
.Example tests
go run testdata/declarative/http/main.go
2021/10/28 15:38:50 Listening to function "http" at http://localhost:8080/ Serving function...
go run testdata/declarative/cloudevent/main.go
2021/10/28 15:40:54 Listening to function "cloudevent" at http://localhost:8080/ Serving function...
Example conformance functions
I'm not an expert in Go, so feel free to suggest any changes!