console v0.4.5: русификация UI, Go/TF предупреждения, handler.go в preferred
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module github.com/user/fn
|
||||
|
||||
go 1.23
|
||||
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Handler — точка входа для Fission go-env.
|
||||
// Go builder компилирует этот файл в .so плагин,
|
||||
// go-env загружает его через plugin.Open().
|
||||
func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
fmt.Fprintf(w, "Hello from real Go in Fission (builder pipeline)")
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Handler используется binary-env: binary получает HTTP request через stdin,
|
||||
// stdout является HTTP response body.
|
||||
//
|
||||
// Для деплоя нужно скомпилировать перед terraform apply:
|
||||
// CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o ../dist/handler .
|
||||
//
|
||||
// Compiled size: ~1.6MB (слишком велико для literal deployment).
|
||||
// Используется shell-based handler в dist/handler (см. ниже).
|
||||
func main() {
|
||||
fmt.Print("Hello from Go in Fission")
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
fmt.Fprintf(w, "Hello from Go in Fission")
|
||||
}
|
||||
+14
-10
@@ -12,26 +12,30 @@ provider "fission" {
|
||||
namespace = "default"
|
||||
}
|
||||
|
||||
# Go использует binary-env: функция является скомпилированным Linux-бинарником.
|
||||
# Перед apply необходимо скомпилировать:
|
||||
# CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o dist/handler code/
|
||||
# Настоящий Go через builder pipeline:
|
||||
# go-builder компилирует handler.go → .so плагин
|
||||
# go-env загружает .so через plugin.Open()
|
||||
resource "fission_environment" "go" {
|
||||
name = "tf-go-hello-env"
|
||||
image = "ghcr.io/fission/binary-env"
|
||||
version = 3
|
||||
name = "tf-go-hello-env"
|
||||
image = "ghcr.io/fission/go-env"
|
||||
builder_image = "ghcr.io/fission/go-builder"
|
||||
builder_command = "build"
|
||||
version = 3
|
||||
}
|
||||
|
||||
resource "fission_package" "pkg" {
|
||||
name = "tf-go-hello-pkg"
|
||||
environment = fission_environment.go.name
|
||||
code_path = "${path.module}/dist/handler"
|
||||
name = "tf-go-hello-pkg"
|
||||
environment = fission_environment.go.name
|
||||
source_dir = "${path.module}/code"
|
||||
deploy_type = "source"
|
||||
build_command = "build"
|
||||
}
|
||||
|
||||
resource "fission_function" "fn" {
|
||||
name = "tf-go-hello-fn"
|
||||
environment = fission_environment.go.name
|
||||
package_name = fission_package.pkg.name
|
||||
entrypoint = "handler"
|
||||
entrypoint = "Handler"
|
||||
}
|
||||
|
||||
resource "fission_http_trigger" "route" {
|
||||
|
||||
Reference in New Issue
Block a user