Skip to content

Commit cbca669

Browse files
committed
rename
1 parent 08aadb2 commit cbca669

21 files changed

+188
-150
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ curl --header "X-tinyFaaS-Async: true" "http://localhost:8000/sieve"
145145

146146
#### gRPC
147147

148-
To use the gRPC endpoint, compile the `api` protocol buffer (included in [`./cmd/rproxy/api`](./cmd/rproxy/api)) and import it into your application.
148+
To use the gRPC endpoint, compile the `tinyfaas` protocol buffer (included in [`./pkg/grpc/tinyfaas`](./pkg/grpc/tinyfaas)) for your programming language and import it into your application.
149+
We already provide compiled versions for Go and Python in that directory.
149150
Specify the tinyFaaS host and port (default is `9000`) for the GRPC endpoint and use the `Request` function with the `functionIdentifier` being your function's name and the `data` field including data in any form you want.
150151

151152
### Removing tinyFaaS

cmd/rproxy/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"os"
1010
"strings"
1111

12+
"github.com/pfandzelter/tinyFaaS/pkg/coap"
13+
"github.com/pfandzelter/tinyFaaS/pkg/grpc"
14+
tfhttp "github.com/pfandzelter/tinyFaaS/pkg/http"
1215
"github.com/pfandzelter/tinyFaaS/pkg/rproxy"
13-
"github.com/pfandzelter/tinyFaaS/pkg/tfcoap"
14-
"github.com/pfandzelter/tinyFaaS/pkg/tfgrpc"
15-
"github.com/pfandzelter/tinyFaaS/pkg/tfhttp"
1616
)
1717

1818
func main() {
@@ -52,7 +52,7 @@ func main() {
5252
// CoAP
5353
if listenAddr, ok := listenAddrs["coap"]; ok {
5454
log.Printf("starting coap server on %s", listenAddr)
55-
go tfcoap.Start(r, listenAddr)
55+
go coap.Start(r, listenAddr)
5656
}
5757
// HTTP
5858
if listenAddr, ok := listenAddrs["http"]; ok {
@@ -62,7 +62,7 @@ func main() {
6262
// GRPC
6363
if listenAddr, ok := listenAddrs["grpc"]; ok {
6464
log.Printf("starting grpc server on %s", listenAddr)
65-
go tfgrpc.Start(r, listenAddr)
65+
go grpc.Start(r, listenAddr)
6666
}
6767

6868
server := http.NewServeMux()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/google/uuid v1.3.0
88
github.com/pfandzelter/go-coap v0.1.0
99
google.golang.org/grpc v1.53.0
10-
google.golang.org/protobuf v1.29.1
10+
google.golang.org/protobuf v1.31.0
1111
)
1212

1313
require (

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOEl
33
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
44
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
55
github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek=
6+
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
7+
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
68
github.com/containerd/containerd v1.7.2 h1:UF2gdONnxO8I6byZXDi5sXWiWvlW3D/sci7dTQimEJo=
79
github.com/containerd/containerd v1.7.2/go.mod h1:afcz74+K10M/+cjGHIVQrCt3RAQhUSCAjJ9iMYhhkuI=
810
github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI=
11+
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
912
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1013
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1114
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -38,6 +41,7 @@ github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
3841
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
3942
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
4043
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
44+
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
4145
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
4246
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
4347
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8=
@@ -50,11 +54,14 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
5054
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
5155
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5256
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
57+
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
58+
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
5359
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
5460
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
5561
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5662
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5763
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
64+
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
5865
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
5966
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
6067
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -106,6 +113,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
106113
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
107114
google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM=
108115
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
116+
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
117+
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
109118
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
110119
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
111120
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

pkg/tfcoap/tfcoap.go renamed to pkg/coap/coap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tfcoap
1+
package coap
22

33
import (
44
"log"

pkg/tfdocker/handler.go renamed to pkg/docker/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tfdocker
1+
package docker
22

33
import (
44
"bufio"

pkg/tfgrpc/tfgrpc.go renamed to pkg/grpc/grpc.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package tfgrpc
1+
package grpc
22

33
import (
44
"context"
55
"fmt"
66
"log"
77
"net"
88

9+
"github.com/pfandzelter/tinyFaaS/pkg/grpc/tinyfaas"
910
"github.com/pfandzelter/tinyFaaS/pkg/rproxy"
10-
"github.com/pfandzelter/tinyFaaS/pkg/tfgrpc/api"
1111
"google.golang.org/grpc"
1212
)
1313

@@ -17,33 +17,33 @@ type GRPCServer struct {
1717
}
1818

1919
// Request handles a request to the GRPC endpoint of the reverse-proxy of this tinyFaaS instance.
20-
func (gs *GRPCServer) Request(ctx context.Context, d *api.Data) (*api.Response, error) {
20+
func (gs *GRPCServer) Request(ctx context.Context, d *tinyfaas.Data) (*tinyfaas.Response, error) {
2121

2222
log.Printf("have request for path: %s (async: %v)", d.FunctionIdentifier, false)
2323

2424
s, res := gs.r.Call(d.FunctionIdentifier, []byte(d.Data), false)
2525

2626
switch s {
2727
case rproxy.StatusOK:
28-
return &api.Response{
28+
return &tinyfaas.Response{
2929
Response: string(res),
3030
}, nil
3131
case rproxy.StatusAccepted:
32-
return &api.Response{}, nil
32+
return &tinyfaas.Response{}, nil
3333
case rproxy.StatusNotFound:
3434
return nil, fmt.Errorf("function %s not found", d.FunctionIdentifier)
3535
case rproxy.StatusError:
3636
return nil, fmt.Errorf("error calling function %s", d.FunctionIdentifier)
3737
}
38-
return &api.Response{
38+
return &tinyfaas.Response{
3939
Response: string(res),
4040
}, nil
4141
}
4242

4343
func Start(r *rproxy.RProxy, listenAddr string) {
4444
gs := grpc.NewServer()
4545

46-
api.RegisterTinyFaaSServer(gs, &GRPCServer{
46+
tinyfaas.RegisterTinyFaaSServer(gs, &GRPCServer{
4747
r: r,
4848
})
4949

pkg/grpc/tinyfaas/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.PHONY: all
2+
3+
PROTO = tinyfaas
4+
5+
all: ${PROTO}_pb2.py ${PROTO}_pb2.pyi ${PROTO}_pb2_grpc.py ${PROTO}.pb.go ${PROTO}_grpc.pb.go
6+
7+
# requires protoc, protoc-gen-go and protoc-gen-go-grpc
8+
# install from your package manager, e.g.:
9+
# brew install protobuf
10+
# brew install protoc-gen-go
11+
# brew install protoc-gen-go-grpc
12+
${PROTO}.pb.go ${PROTO}_grpc.pb.go: ${PROTO}.proto
13+
@protoc -I . $< --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false,paths=source_relative
14+
15+
# requires grpcio-tools and mypy-protobuf
16+
# python3 -m pip install -r requirements.txt
17+
${PROTO}_pb2.py ${PROTO}_pb2.pyi ${PROTO}_pb2_grpc.py: ${PROTO}.proto
18+
@python3 -m grpc_tools.protoc -I . --python_out=. --grpc_python_out=. --mypy_out=. $<

pkg/grpc/tinyfaas/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
grpcio==1.56.0
2+
grpcio-tools==1.56.0
3+
protobuf==4.23.3
4+
mypy-protobuf==3.4.0

pkg/tfgrpc/api/api.pb.go renamed to pkg/grpc/tinyfaas/tinyfaas.pb.go

Lines changed: 58 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)