mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
All of the changes for func logs
This commit is contained in:
8
examples/tutorial/logging/Dockerfile
Normal file
8
examples/tutorial/logging/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM funcy/go:dev as build-stage
|
||||
WORKDIR /function
|
||||
ADD . /src
|
||||
RUN cd /src && go build -o func
|
||||
FROM funcy/go
|
||||
WORKDIR /function
|
||||
COPY --from=build-stage /src/func /function/
|
||||
ENTRYPOINT ["./func"]
|
||||
5
examples/tutorial/logging/func.yaml
Normal file
5
examples/tutorial/logging/func.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: funcy/stderr-logging
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /stderr-logging
|
||||
29
examples/tutorial/logging/main.go
Normal file
29
examples/tutorial/logging/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
const lBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
type OutputSize struct {
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
|
||||
func RandStringBytes(n int) string {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = lBytes[rand.Intn(len(lBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func main() {
|
||||
out := &OutputSize{Size: 64 * 1024}
|
||||
json.NewDecoder(os.Stdin).Decode(out)
|
||||
fmt.Fprintln(os.Stderr, RandStringBytes(out.Size))
|
||||
}
|
||||
3
examples/tutorial/logging/sample.payload.json
Normal file
3
examples/tutorial/logging/sample.payload.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"size": 8
|
||||
}
|
||||
Reference in New Issue
Block a user