Function service (#227)

This commit is contained in:
Janos Dobronszki
2021-10-11 11:54:53 +01:00
committed by GitHub
parent ee1674dda6
commit 599b418c20
36 changed files with 1988 additions and 41 deletions

2
function/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
function

3
function/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM alpine
ADD function /function
ENTRYPOINT [ "/function" ]

26
function/Makefile Normal file
View File

@@ -0,0 +1,26 @@
GOPATH:=$(shell go env GOPATH)
.PHONY: init
init:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
.PHONY: proto
proto:
protoc --proto_path=. --micro_out=. --go_out=:. proto/function.proto
.PHONY: api
api:
protoc --openapi_out=. --proto_path=. proto/function.proto
.PHONY: build
build:
go build -o function *.go
.PHONY: test
test:
go test -v ./... -cover
.PHONY: docker
docker:
docker build . -t function:latest

23
function/README.md Normal file
View File

@@ -0,0 +1,23 @@
# Function Service
This is the Function service
Generated with
```
micro new function
```
## Usage
Generate the proto code
```
make proto
```
Run the service
```
micro run .
```

55
function/examples.json Normal file
View File

@@ -0,0 +1,55 @@
{
"deploy": [
{
"title": "Deploy a function",
"request": {
"repo": "github.com/crufter/gcloud-nodejs-test",
"name": "my-first-func",
"entrypoint": "helloworld",
"project": "tests"
},
"response": {}
}
],
"call": [
{
"title": "Call a function",
"request": {
"name": "my-first-func",
"request": {}
},
"response": {
"response": {
"message": "Hello World!"
}
}
}
],
"list": [
{
"title": "List functions",
"request": {},
"response": {
"functions": [
{
"project": "a",
"name": "test4",
"entrypoint": "helloworld",
"repo": "github.com/crufter/gcloud-nodejs-test",
"subfolder": ""
}
]
}
}
],
"delete": [
{
"title": "Delete a function",
"request": {
"project": "tests",
"name": "my-first-func"
},
"response": {}
}
]
}

2
function/generate.go Normal file
View File

@@ -0,0 +1,2 @@
package main
//go:generate make proto

View File

@@ -0,0 +1,261 @@
package handler
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os/exec"
"path/filepath"
"strings"
"github.com/micro/micro/v3/service/config"
log "github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/runtime/source/git"
_struct "github.com/golang/protobuf/ptypes/struct"
db "github.com/micro/services/db/proto"
function "github.com/micro/services/function/proto"
"github.com/micro/services/pkg/tenant"
)
type Function struct {
project string
// eg. https://us-central1-m3o-apis.cloudfunctions.net/
address string
db db.DbService
}
type Func struct {
Name string `json:"name"`
Tenant string `json:"tenant"`
Project string `json:"project"`
}
func NewFunction(db db.DbService) *Function {
v, err := config.Get("function.service_account_json")
if err != nil {
log.Fatalf("function.service_account_json: %v", err)
}
keyfile := v.Bytes()
if len(keyfile) == 0 {
log.Fatalf("empty keyfile")
}
v, err = config.Get("function.address")
if err != nil {
log.Fatalf("function.address: %v", err)
}
address := v.String("")
if len(address) == 0 {
log.Fatalf("empty address")
}
v, err = config.Get("function.project")
if err != nil {
log.Fatalf("function.project: %v", err)
}
project := v.String("")
if len(project) == 0 {
log.Fatalf("empty project")
}
v, err = config.Get("function.service_account")
if err != nil {
log.Fatalf("function.service_account: %v", err)
}
accName := v.String("")
m := map[string]interface{}{}
err = json.Unmarshal(keyfile, &m)
if err != nil {
log.Fatalf("invalid json: %v", err)
}
// only root
err = ioutil.WriteFile("/acc.json", keyfile, 0700)
if err != nil {
log.Fatalf("function.service_account: %v", err)
}
// DO THIS STEP
// https://cloud.google.com/functions/docs/reference/iam/roles#additional-configuration
// https://cloud.google.com/sdk/docs/authorizing#authorizing_with_a_service_account
outp, err := exec.Command("gcloud", "auth", "activate-service-account", accName, "--key-file", "/acc.json").CombinedOutput()
if err != nil {
log.Fatalf(string(outp))
}
outp, err = exec.Command("gcloud", "auth", "list").CombinedOutput()
if err != nil {
log.Fatalf(string(outp))
}
log.Info(string(outp))
return &Function{project: project, address: address, db: db}
}
func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp *function.DeployResponse) error {
log.Info("Received Function.Deploy request")
gitter := git.NewGitter(map[string]string{})
err := gitter.Checkout(req.Repo, "master")
if err != nil {
return err
}
tenantId, ok := tenant.FromContext(ctx)
if !ok {
tenantId = "micro"
}
multitenantPrefix := strings.Replace(tenantId, "/", "-", -1)
if req.Entrypoint == "" {
req.Entrypoint = req.Name
}
project := req.Project
if project == "" {
project = "default"
}
readRsp, err := e.db.Read(ctx, &db.ReadRequest{
Table: "functions",
Query: fmt.Sprintf("tenantId == '%v' and project == '%v' and name == '%v'", tenantId, project, req.Name),
})
if err != nil {
return err
}
go func() {
// https://jsoverson.medium.com/how-to-deploy-node-js-functions-to-google-cloud-8bba05e9c10a
cmd := exec.Command("gcloud", "functions", "deploy", multitenantPrefix+"-"+req.Name, "--region", "europe-west1", "--allow-unauthenticated", "--entry-point", req.Entrypoint, "--trigger-http", "--project", e.project, "--runtime", "nodejs14")
cmd.Dir = filepath.Join(gitter.RepoDir(), req.Subfolder)
outp, err := cmd.CombinedOutput()
if err != nil {
log.Error(fmt.Errorf(string(outp)))
}
}()
s := &_struct.Struct{}
id := fmt.Sprintf("%v-%v-%v", tenantId, project, req.Name)
jso, _ := json.Marshal(map[string]interface{}{
"id": id,
"project": project,
"name": req.Name,
"tenantId": tenantId,
"repo": req.Repo,
"subfolder": req.Subfolder,
"entrypoint": req.Entrypoint,
})
err = s.UnmarshalJSON(jso)
if err != nil {
return err
}
if len(readRsp.Records) > 0 {
_, err = e.db.Update(ctx, &db.UpdateRequest{
Table: "functions",
Record: s,
Id: id,
})
if err != nil {
log.Error(err)
}
return err
}
_, err = e.db.Create(ctx, &db.CreateRequest{
Table: "functions",
Record: s,
})
if err != nil {
log.Error(err)
}
return err
}
func (e *Function) Call(ctx context.Context, req *function.CallRequest, rsp *function.CallResponse) error {
log.Info("Received Function.Call request")
tenantId, ok := tenant.FromContext(ctx)
if !ok {
tenantId = "micro"
}
multitenantPrefix := strings.Replace(tenantId, "/", "-", -1)
url := e.address + multitenantPrefix + "-" + req.Name
fmt.Println("URL:>", url)
js, _ := json.Marshal(req.Request)
if req.Request == nil || len(req.Request.Fields) == 0 {
js = []byte("{}")
}
r, err := http.NewRequest("POST", url, bytes.NewBuffer(js))
if err != nil {
return err
}
r.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(r)
if err != nil {
log.Errorf("error making request %v", err)
return err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Errorf("error reading body %v", string(body))
return err
}
err = json.Unmarshal(body, &rsp.Response)
if err != nil {
log.Errorf("error unmarshaling %v", string(body))
return err
}
return nil
}
func (e *Function) Delete(ctx context.Context, req *function.DeleteRequest, rsp *function.DeleteResponse) error {
log.Info("Received Function.Delete request")
return fmt.Errorf("not implemented yet")
}
func (e *Function) List(ctx context.Context, req *function.ListRequest, rsp *function.ListResponse) error {
log.Info("Received Function.List request")
tenantId, ok := tenant.FromContext(ctx)
if !ok {
tenantId = "micro"
}
project := req.Project
q := fmt.Sprintf(`tenantId == "%v"`, tenantId)
if project != "" {
q += fmt.Sprintf(` and project == "%v"`, project)
}
log.Infof("Making query %v", q)
readRsp, err := e.db.Read(ctx, &db.ReadRequest{
Table: "functions",
Query: q,
})
if err != nil {
return err
}
log.Info(readRsp.Records)
rsp.Functions = []*function.Func{}
for _, record := range readRsp.Records {
m := record.AsMap()
bs, _ := json.Marshal(m)
f := &function.Func{}
err = json.Unmarshal(bs, f)
if err != nil {
return err
}
rsp.Functions = append(rsp.Functions, f)
}
return nil
}

24
function/image/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM micro/cells:v3 as builder
RUN apk add curl
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
# https://stackoverflow.com/questions/28372328/how-to-install-the-google-cloud-sdk-in-a-docker-image
# Downloading gcloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
# Installing the package
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh
# Adding the package path to local
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin

26
function/main.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
db "github.com/micro/services/db/proto"
"github.com/micro/services/function/handler"
pb "github.com/micro/services/function/proto"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
)
func main() {
// Create service
srv := service.New(
service.Name("function"),
service.Version("latest"),
)
// Register handler
pb.RegisterFunctionHandler(srv.Server(), handler.NewFunction(db.NewDbService("db", srv.Client())))
// Run service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}

1
function/micro.mu Normal file
View File

@@ -0,0 +1 @@
service function

View File

@@ -0,0 +1,766 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.6.1
// source: proto/function.proto
package function
import (
_struct "github.com/golang/protobuf/ptypes/struct"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// Call a function
type CallRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Name of the function
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Request body that will be passed to the function
Request *_struct.Struct `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"`
}
func (x *CallRequest) Reset() {
*x = CallRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CallRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CallRequest) ProtoMessage() {}
func (x *CallRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CallRequest.ProtoReflect.Descriptor instead.
func (*CallRequest) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{0}
}
func (x *CallRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CallRequest) GetRequest() *_struct.Struct {
if x != nil {
return x.Request
}
return nil
}
type CallResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Response body that the function returned
Response *_struct.Struct `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"`
}
func (x *CallResponse) Reset() {
*x = CallResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CallResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CallResponse) ProtoMessage() {}
func (x *CallResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CallResponse.ProtoReflect.Descriptor instead.
func (*CallResponse) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{1}
}
func (x *CallResponse) GetResponse() *_struct.Struct {
if x != nil {
return x.Response
}
return nil
}
// Deploy a group of functions
type DeployRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// github url to repo
Repo string `protobuf:"bytes,1,opt,name=repo,proto3" json:"repo,omitempty"`
// optional subfolder path
Subfolder string `protobuf:"bytes,2,opt,name=subfolder,proto3" json:"subfolder,omitempty"`
// function name
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
// entry point, ie. handler name in the source code
// if not provided, defaults to the name parameter
Entrypoint string `protobuf:"bytes,4,opt,name=entrypoint,proto3" json:"entrypoint,omitempty"`
// project is used for namespacing your functions
// optional. defaults to "default".
Project string `protobuf:"bytes,5,opt,name=project,proto3" json:"project,omitempty"`
}
func (x *DeployRequest) Reset() {
*x = DeployRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeployRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeployRequest) ProtoMessage() {}
func (x *DeployRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeployRequest.ProtoReflect.Descriptor instead.
func (*DeployRequest) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{2}
}
func (x *DeployRequest) GetRepo() string {
if x != nil {
return x.Repo
}
return ""
}
func (x *DeployRequest) GetSubfolder() string {
if x != nil {
return x.Subfolder
}
return ""
}
func (x *DeployRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *DeployRequest) GetEntrypoint() string {
if x != nil {
return x.Entrypoint
}
return ""
}
func (x *DeployRequest) GetProject() string {
if x != nil {
return x.Project
}
return ""
}
type DeployResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *DeployResponse) Reset() {
*x = DeployResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeployResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeployResponse) ProtoMessage() {}
func (x *DeployResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeployResponse.ProtoReflect.Descriptor instead.
func (*DeployResponse) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{3}
}
type ListRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// optional
Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
}
func (x *ListRequest) Reset() {
*x = ListRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRequest) ProtoMessage() {}
func (x *ListRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead.
func (*ListRequest) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{4}
}
func (x *ListRequest) GetProject() string {
if x != nil {
return x.Project
}
return ""
}
type Func struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Entrypoint string `protobuf:"bytes,3,opt,name=entrypoint,proto3" json:"entrypoint,omitempty"`
Repo string `protobuf:"bytes,4,opt,name=repo,proto3" json:"repo,omitempty"`
Subfolder string `protobuf:"bytes,5,opt,name=subfolder,proto3" json:"subfolder,omitempty"`
}
func (x *Func) Reset() {
*x = Func{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Func) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Func) ProtoMessage() {}
func (x *Func) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Func.ProtoReflect.Descriptor instead.
func (*Func) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{5}
}
func (x *Func) GetProject() string {
if x != nil {
return x.Project
}
return ""
}
func (x *Func) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Func) GetEntrypoint() string {
if x != nil {
return x.Entrypoint
}
return ""
}
func (x *Func) GetRepo() string {
if x != nil {
return x.Repo
}
return ""
}
func (x *Func) GetSubfolder() string {
if x != nil {
return x.Subfolder
}
return ""
}
type ListResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Functions []*Func `protobuf:"bytes,1,rep,name=functions,proto3" json:"functions,omitempty"`
}
func (x *ListResponse) Reset() {
*x = ListResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListResponse) ProtoMessage() {}
func (x *ListResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListResponse.ProtoReflect.Descriptor instead.
func (*ListResponse) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{6}
}
func (x *ListResponse) GetFunctions() []*Func {
if x != nil {
return x.Functions
}
return nil
}
type DeleteRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *DeleteRequest) Reset() {
*x = DeleteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteRequest) ProtoMessage() {}
func (x *DeleteRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead.
func (*DeleteRequest) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteRequest) GetProject() string {
if x != nil {
return x.Project
}
return ""
}
func (x *DeleteRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type DeleteResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *DeleteResponse) Reset() {
*x = DeleteResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteResponse) ProtoMessage() {}
func (x *DeleteResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteResponse.ProtoReflect.Descriptor instead.
func (*DeleteResponse) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{8}
}
var File_proto_function_proto protoreflect.FileDescriptor
var file_proto_function_proto_rawDesc = []byte{
0x0a, 0x14, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x54,
0x0a, 0x0b, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x12, 0x31, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0a, 0x0c, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52,
0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x0d, 0x44, 0x65,
0x70, 0x6c, 0x6f, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72,
0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12,
0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18,
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e,
0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x44,
0x65, 0x70, 0x6c, 0x6f, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x27, 0x0a,
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07,
0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70,
0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x86, 0x01, 0x0a, 0x04, 0x46, 0x75, 0x6e, 0x63, 0x12,
0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a,
0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70,
0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x22,
0x3c, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x2c, 0x0a, 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x46, 0x75,
0x6e, 0x63, 0x52, 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x3d, 0x0a,
0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18,
0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x10, 0x0a, 0x0e,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xfa,
0x01, 0x0a, 0x08, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x04, 0x43,
0x61, 0x6c, 0x6c, 0x12, 0x15, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43,
0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x06, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x12, 0x17,
0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x66, 0x75,
0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x16, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x06,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x18, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x12, 0x5a, 0x10, 0x2e,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_function_proto_rawDescOnce sync.Once
file_proto_function_proto_rawDescData = file_proto_function_proto_rawDesc
)
func file_proto_function_proto_rawDescGZIP() []byte {
file_proto_function_proto_rawDescOnce.Do(func() {
file_proto_function_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_function_proto_rawDescData)
})
return file_proto_function_proto_rawDescData
}
var file_proto_function_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_proto_function_proto_goTypes = []interface{}{
(*CallRequest)(nil), // 0: function.CallRequest
(*CallResponse)(nil), // 1: function.CallResponse
(*DeployRequest)(nil), // 2: function.DeployRequest
(*DeployResponse)(nil), // 3: function.DeployResponse
(*ListRequest)(nil), // 4: function.ListRequest
(*Func)(nil), // 5: function.Func
(*ListResponse)(nil), // 6: function.ListResponse
(*DeleteRequest)(nil), // 7: function.DeleteRequest
(*DeleteResponse)(nil), // 8: function.DeleteResponse
(*_struct.Struct)(nil), // 9: google.protobuf.Struct
}
var file_proto_function_proto_depIdxs = []int32{
9, // 0: function.CallRequest.request:type_name -> google.protobuf.Struct
9, // 1: function.CallResponse.response:type_name -> google.protobuf.Struct
5, // 2: function.ListResponse.functions:type_name -> function.Func
0, // 3: function.Function.Call:input_type -> function.CallRequest
2, // 4: function.Function.Deploy:input_type -> function.DeployRequest
4, // 5: function.Function.List:input_type -> function.ListRequest
7, // 6: function.Function.Delete:input_type -> function.DeleteRequest
1, // 7: function.Function.Call:output_type -> function.CallResponse
3, // 8: function.Function.Deploy:output_type -> function.DeployResponse
6, // 9: function.Function.List:output_type -> function.ListResponse
8, // 10: function.Function.Delete:output_type -> function.DeleteResponse
7, // [7:11] is the sub-list for method output_type
3, // [3:7] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_proto_function_proto_init() }
func file_proto_function_proto_init() {
if File_proto_function_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_function_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CallRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CallResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeployRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeployResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Func); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_function_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_function_proto_goTypes,
DependencyIndexes: file_proto_function_proto_depIdxs,
MessageInfos: file_proto_function_proto_msgTypes,
}.Build()
File_proto_function_proto = out.File
file_proto_function_proto_rawDesc = nil
file_proto_function_proto_goTypes = nil
file_proto_function_proto_depIdxs = nil
}

View File

@@ -0,0 +1,145 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/function.proto
package function
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
_ "github.com/golang/protobuf/ptypes/struct"
math "math"
)
import (
context "context"
api "github.com/micro/micro/v3/service/api"
client "github.com/micro/micro/v3/service/client"
server "github.com/micro/micro/v3/service/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for Function service
func NewFunctionEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Function service
type FunctionService interface {
Call(ctx context.Context, in *CallRequest, opts ...client.CallOption) (*CallResponse, error)
Deploy(ctx context.Context, in *DeployRequest, opts ...client.CallOption) (*DeployResponse, error)
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
}
type functionService struct {
c client.Client
name string
}
func NewFunctionService(name string, c client.Client) FunctionService {
return &functionService{
c: c,
name: name,
}
}
func (c *functionService) Call(ctx context.Context, in *CallRequest, opts ...client.CallOption) (*CallResponse, error) {
req := c.c.NewRequest(c.name, "Function.Call", in)
out := new(CallResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *functionService) Deploy(ctx context.Context, in *DeployRequest, opts ...client.CallOption) (*DeployResponse, error) {
req := c.c.NewRequest(c.name, "Function.Deploy", in)
out := new(DeployResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *functionService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Function.List", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *functionService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
req := c.c.NewRequest(c.name, "Function.Delete", in)
out := new(DeleteResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Function service
type FunctionHandler interface {
Call(context.Context, *CallRequest, *CallResponse) error
Deploy(context.Context, *DeployRequest, *DeployResponse) error
List(context.Context, *ListRequest, *ListResponse) error
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
}
func RegisterFunctionHandler(s server.Server, hdlr FunctionHandler, opts ...server.HandlerOption) error {
type function interface {
Call(ctx context.Context, in *CallRequest, out *CallResponse) error
Deploy(ctx context.Context, in *DeployRequest, out *DeployResponse) error
List(ctx context.Context, in *ListRequest, out *ListResponse) error
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
}
type Function struct {
function
}
h := &functionHandler{hdlr}
return s.Handle(s.NewHandler(&Function{h}, opts...))
}
type functionHandler struct {
FunctionHandler
}
func (h *functionHandler) Call(ctx context.Context, in *CallRequest, out *CallResponse) error {
return h.FunctionHandler.Call(ctx, in, out)
}
func (h *functionHandler) Deploy(ctx context.Context, in *DeployRequest, out *DeployResponse) error {
return h.FunctionHandler.Deploy(ctx, in, out)
}
func (h *functionHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.FunctionHandler.List(ctx, in, out)
}
func (h *functionHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
return h.FunctionHandler.Delete(ctx, in, out)
}

View File

@@ -0,0 +1,78 @@
syntax = "proto3";
import "google/protobuf/struct.proto";
package function;
option go_package = "./proto;function";
service Function {
rpc Call(CallRequest) returns (CallResponse) {}
rpc Deploy(DeployRequest) returns (DeployResponse) {}
rpc List(ListRequest) returns (ListResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
}
// Call a function
message CallRequest {
// Name of the function
string name = 1;
// Request body that will be passed to the function
google.protobuf.Struct request = 2;
}
message CallResponse {
// Response body that the function returned
google.protobuf.Struct response = 1;
}
// Deploy a group of functions
message DeployRequest {
// github url to repo
string repo = 1;
// optional subfolder path
string subfolder = 2;
// function name
string name = 3;
// entry point, ie. handler name in the source code
// if not provided, defaults to the name parameter
string entrypoint = 4;
// project is used for namespacing your functions
// optional. defaults to "default".
string project = 5;
}
message DeployResponse {
}
message ListRequest {
// optional
string project = 1;
}
message Func {
// project of function, optional
// defaults to literal "default"
// used to namespace functions
string project = 1;
// function name
string name = 2;
// name of handler in source code
string entrypoint = 3;
// git repo address
string repo = 4;
// subfolder path to entrypoint
string subfolder = 5;
}
message ListResponse {
repeated Func functions = 1;
}
message DeleteRequest {
string project = 1;
string name = 2;
}
message DeleteResponse {
}

10
function/publicapi.json Normal file
View File

@@ -0,0 +1,10 @@
{
"name": "function",
"icon": "🔥",
"category": "hosting",
"pricing": {
"Function.Deploy": 1000,
"Function.Call": 10
}
}