replace db with store in function (#318)

* replace db with store in function

* .

* set id properly

* .
This commit is contained in:
Asim Aslam
2021-12-10 15:51:34 +00:00
committed by GitHub
parent f022c62a87
commit 855fd8f72a
5 changed files with 491 additions and 138 deletions

View File

@@ -14,21 +14,18 @@ import (
"github.com/micro/micro/v3/service/config"
"github.com/micro/micro/v3/service/errors"
log "github.com/micro/micro/v3/service/logger"
"gopkg.in/yaml.v2"
"github.com/micro/micro/v3/service/runtime/source/git"
_struct "github.com/golang/protobuf/ptypes/struct"
db "github.com/micro/services/db/proto"
"github.com/micro/micro/v3/service/store"
function "github.com/micro/services/function/proto"
"github.com/micro/services/pkg/tenant"
"gopkg.in/yaml.v2"
)
type Function struct {
project string
// eg. https://us-central1-m3o-apis.cloudfunctions.net/
address string
db db.DbService
limit int
}
type Func struct {
@@ -37,7 +34,7 @@ type Func struct {
Project string `json:"project"`
}
func NewFunction(db db.DbService) *Function {
func NewFunction() *Function {
v, err := config.Get("function.service_account_json")
if err != nil {
log.Fatalf("function.service_account_json: %v", err)
@@ -64,7 +61,14 @@ func NewFunction(db db.DbService) *Function {
if len(project) == 0 {
log.Fatalf("empty project")
}
v, err = config.Get("function.limit")
if err != nil {
log.Fatalf("function.limit: %v", err)
}
limit := v.Int(0)
if limit > 0 {
log.Infof("Function limit is %d", limit)
}
v, err = config.Get("function.service_account")
if err != nil {
log.Fatalf("function.service_account: %v", err)
@@ -97,7 +101,7 @@ func NewFunction(db db.DbService) *Function {
log.Fatalf(string(outp))
}
log.Info(string(outp))
return &Function{project: project, address: address, db: db}
return &Function{project: project, address: address, limit: limit}
}
func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp *function.DeployResponse) error {
@@ -110,6 +114,9 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
if len(req.Repo) == 0 {
return errors.BadRequest("function.deploy", "Missing repo")
}
if req.Runtime == "" {
return fmt.Errorf("missing runtime field, please specify nodejs14, go116 etc")
}
gitter := git.NewGitter(map[string]string{})
@@ -141,15 +148,28 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
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 {
key := fmt.Sprintf("%s/%s/%s", tenantId, project, req.Name)
records, err := store.Read(key)
if err != nil && err != store.ErrNotFound {
return err
}
if req.Runtime == "" {
return fmt.Errorf("missing runtime field, please specify nodejs14, go116 etc")
if len(records) > 0 {
return errors.BadRequest("function.deploy", "already exists")
}
// check for function limit
if e.limit > 0 {
// read all the records for the user
records, err := store.Read(tenantId+"/", store.ReadPrefix())
if err != nil {
return err
}
if v := len(records); v >= e.limit {
return errors.BadRequest("function.deploy", "deployment limit reached")
}
}
// process the env vars to the required format
@@ -178,9 +198,8 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
}
}()
s := &_struct.Struct{}
id := fmt.Sprintf("%v-%v-%v", tenantId, project, req.Name)
jso, _ := json.Marshal(map[string]interface{}{
rec := store.NewRecord(key, map[string]interface{}{
"id": id,
"project": project,
"name": req.Name,
@@ -189,30 +208,107 @@ func (e *Function) Deploy(ctx context.Context, req *function.DeployRequest, rsp
"subfolder": req.Subfolder,
"entrypoint": req.Entrypoint,
"runtime": req.Runtime,
"env_vars": envVars,
})
err = s.UnmarshalJSON(jso)
// write the record
return store.Write(rec)
}
func (e *Function) Update(ctx context.Context, req *function.UpdateRequest, rsp *function.UpdateResponse) error {
log.Info("Received Function.Update request")
if len(req.Name) == 0 {
return errors.BadRequest("function.update", "Missing name")
}
if len(req.Repo) == 0 {
return errors.BadRequest("function.update", "Missing repo")
}
if req.Runtime == "" {
return fmt.Errorf("missing runtime field, please specify nodejs14, go116 etc")
}
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"
}
key := fmt.Sprintf("%s/%s/%s", tenantId, project, req.Name)
records, err := store.Read(key)
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)
if len(records) == 0 {
return errors.BadRequest("function.deploy", "function does not exist")
}
gitter := git.NewGitter(map[string]string{})
for _, branch := range []string{"master", "main"} {
err = gitter.Checkout(req.Repo, branch)
if err == nil {
break
}
return err
}
_, err = e.db.Create(ctx, &db.CreateRequest{
Table: "functions",
Record: s,
})
if err != nil {
log.Error(err)
return errors.InternalServerError("function.update", err.Error())
}
return err
// process the env vars to the required format
var envVars []string
for k, v := range req.EnvVars {
envVars = append(envVars, k+"="+v)
}
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", req.Runtime)
// if env vars exist then set them
if len(envVars) > 0 {
cmd.Args = append(cmd.Args, "--set-env-vars", strings.Join(envVars, ","))
}
cmd.Dir = filepath.Join(gitter.RepoDir(), req.Subfolder)
outp, err := cmd.CombinedOutput()
if err != nil {
log.Error(fmt.Errorf(string(outp)))
}
}()
id := fmt.Sprintf("%v-%v-%v", tenantId, project, req.Name)
rec := store.NewRecord(key, map[string]interface{}{
"id": id,
"project": project,
"name": req.Name,
"tenantId": tenantId,
"repo": req.Repo,
"subfolder": req.Subfolder,
"entrypoint": req.Entrypoint,
"runtime": req.Runtime,
"env_vars": envVars,
})
// write the record
return store.Write(rec)
}
func (e *Function) Call(ctx context.Context, req *function.CallRequest, rsp *function.CallResponse) error {
@@ -289,12 +385,9 @@ func (e *Function) Delete(ctx context.Context, req *function.DeleteRequest, rsp
return err
}
id := fmt.Sprintf("%v-%v-%v", tenantId, project, req.Name)
_, err = e.db.Delete(ctx, &db.DeleteRequest{
Table: "functions",
Id: id,
})
return err
key := fmt.Sprintf("%v/%v/%v", tenantId, project, req.Name)
return store.Delete(key)
}
func (e *Function) List(ctx context.Context, req *function.ListRequest, rsp *function.ListResponse) error {
@@ -304,21 +397,18 @@ func (e *Function) List(ctx context.Context, req *function.ListRequest, rsp *fun
if !ok {
tenantId = "micro"
}
project := req.Project
q := fmt.Sprintf(`tenantId == "%v"`, tenantId)
if project != "" {
q += fmt.Sprintf(` and project == "%v"`, project)
key := tenantId + "/"
project := req.Project
if len(project) > 0 {
key = key + "/" + project + "/"
}
log.Infof("Making query %v", q)
readRsp, err := e.db.Read(ctx, &db.ReadRequest{
Table: "functions",
Query: q,
})
records, err := store.Read(key, store.ReadPrefix())
if err != nil {
return err
}
log.Info(readRsp.Records)
multitenantPrefix := strings.Replace(tenantId, "/", "-", -1)
cmd := exec.Command("gcloud", "functions", "list", "--project", e.project, "--filter", "name~"+multitenantPrefix+"*")
@@ -326,8 +416,10 @@ func (e *Function) List(ctx context.Context, req *function.ListRequest, rsp *fun
if err != nil {
log.Error(fmt.Errorf(string(outp)))
}
lines := strings.Split(string(outp), "\n")
statuses := map[string]string{}
for _, line := range lines {
fields := strings.Fields(line)
if len(fields) < 2 {
@@ -337,17 +429,16 @@ func (e *Function) List(ctx context.Context, req *function.ListRequest, rsp *fun
}
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 {
for _, record := range records {
f := new(function.Func)
if err := record.Decode(f); err != nil {
return err
}
f.Status = statuses[multitenantPrefix+"-"+f.Name]
rsp.Functions = append(rsp.Functions, f)
}
return nil
}
@@ -367,12 +458,9 @@ func (e *Function) Describe(ctx context.Context, req *function.DescribeRequest,
}
multitenantPrefix := strings.Replace(tenantId, "/", "-", -1)
id := fmt.Sprintf("%v-%v-%v", tenantId, project, req.Name)
key := fmt.Sprintf("%v/%v/%v", tenantId, project, req.Name)
readRsp, err := e.db.Read(ctx, &db.ReadRequest{
Table: "functions",
Id: id,
})
records, err := store.Read(key)
if err != nil {
return err
}
@@ -391,12 +479,9 @@ func (e *Function) Describe(ctx context.Context, req *function.DescribeRequest,
return err
}
if len(readRsp.Records) > 0 {
m := readRsp.Records[0].AsMap()
bs, _ := json.Marshal(m)
if len(records) > 0 {
f := &function.Func{}
err = json.Unmarshal(bs, f)
if err != nil {
if err := records[0].Decode(f); err != nil {
return err
}
rsp.Function = f

View File

@@ -1,12 +1,10 @@
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"
"github.com/micro/services/function/handler"
pb "github.com/micro/services/function/proto"
)
func main() {
@@ -17,7 +15,7 @@ func main() {
)
// Register handler
pb.RegisterFunctionHandler(srv.Server(), handler.NewFunction(db.NewDbService("db", srv.Client())))
pb.RegisterFunctionHandler(srv.Server(), handler.NewFunction())
// Run service
if err := srv.Run(); err != nil {

View File

@@ -355,6 +355,8 @@ type Func struct {
Runtime string `protobuf:"bytes,6,opt,name=runtime,proto3" json:"runtime,omitempty"`
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
Status string `protobuf:"bytes,7,opt,name=status,proto3" json:"status,omitempty"`
// associated env vars
Env_Vars map[string]string `protobuf:"bytes,8,rep,name=env_Vars,json=envVars,proto3" json:"env_Vars,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *Func) Reset() {
@@ -438,6 +440,13 @@ func (x *Func) GetStatus() string {
return ""
}
func (x *Func) GetEnv_Vars() map[string]string {
if x != nil {
return x.Env_Vars
}
return nil
}
type ListResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -706,6 +715,155 @@ func (x *DescribeResponse) GetTimeout() string {
return ""
}
type UpdateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// function name
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// github url to repo
Repo string `protobuf:"bytes,2,opt,name=repo,proto3" json:"repo,omitempty"`
// optional subfolder path
Subfolder string `protobuf:"bytes,3,opt,name=subfolder,proto3" json:"subfolder,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"`
// runtime/language of the function
// eg: php74,
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16
// dotnet3
// java11
// ruby26, ruby27
// go111, go113, go116
// python37, python38, python39
Runtime string `protobuf:"bytes,6,opt,name=runtime,proto3" json:"runtime,omitempty"`
// environment variables to pass in at runtime
EnvVars map[string]string `protobuf:"bytes,7,rep,name=env_vars,json=envVars,proto3" json:"env_vars,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *UpdateRequest) Reset() {
*x = UpdateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateRequest) ProtoMessage() {}
func (x *UpdateRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[11]
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 UpdateRequest.ProtoReflect.Descriptor instead.
func (*UpdateRequest) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{11}
}
func (x *UpdateRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UpdateRequest) GetRepo() string {
if x != nil {
return x.Repo
}
return ""
}
func (x *UpdateRequest) GetSubfolder() string {
if x != nil {
return x.Subfolder
}
return ""
}
func (x *UpdateRequest) GetEntrypoint() string {
if x != nil {
return x.Entrypoint
}
return ""
}
func (x *UpdateRequest) GetProject() string {
if x != nil {
return x.Project
}
return ""
}
func (x *UpdateRequest) GetRuntime() string {
if x != nil {
return x.Runtime
}
return ""
}
func (x *UpdateRequest) GetEnvVars() map[string]string {
if x != nil {
return x.EnvVars
}
return nil
}
type UpdateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UpdateResponse) Reset() {
*x = UpdateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_function_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateResponse) ProtoMessage() {}
func (x *UpdateResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_function_proto_msgTypes[12]
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 UpdateResponse.ProtoReflect.Descriptor instead.
func (*UpdateResponse) Descriptor() ([]byte, []int) {
return file_proto_function_proto_rawDescGZIP(), []int{12}
}
var File_proto_function_proto protoreflect.FileDescriptor
var file_proto_function_proto_rawDesc = []byte{
@@ -744,7 +902,7 @@ var file_proto_function_proto_rawDesc = []byte{
0x38, 0x01, 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, 0xb8, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0xac, 0x02,
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,
@@ -756,49 +914,80 @@ var file_proto_function_proto_rawDesc = []byte{
0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x36, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f,
0x56, 0x61, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61,
0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73,
0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 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, 0x12, 0x0a, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x0f, 0x44,
0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 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, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x77, 0x0a, 0x10,
0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x2a, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x46, 0x75,
0x6e, 0x63, 0x52, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x74,
0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x69,
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0xa6, 0x02, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
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, 0x18, 0x0a, 0x07, 0x70,
0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72,
0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x0f, 0x44, 0x65, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 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, 0x18,
0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x77, 0x0a, 0x10, 0x44, 0x65, 0x73, 0x63,
0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x08,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e,
0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x52, 0x08,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70,
0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f,
0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75,
0x74, 0x32, 0xbf, 0x02, 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, 0x12, 0x43,
0x0a, 0x08, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x19, 0x2e, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 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,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72,
0x65, 0x70, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12,
0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 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, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69,
0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
0x65, 0x12, 0x3f, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x07, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x6e, 0x76,
0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61,
0x72, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x10,
0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x32, 0xfe, 0x02, 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, 0x12, 0x43, 0x0a,
0x08, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x19, 0x2e, 0x66, 0x75, 0x6e, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x3d, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x66,
0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x55, 0x70, 0x64, 0x61, 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 (
@@ -813,7 +1002,7 @@ func file_proto_function_proto_rawDescGZIP() []byte {
return file_proto_function_proto_rawDescData
}
var file_proto_function_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_proto_function_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
var file_proto_function_proto_goTypes = []interface{}{
(*CallRequest)(nil), // 0: function.CallRequest
(*CallResponse)(nil), // 1: function.CallResponse
@@ -826,30 +1015,38 @@ var file_proto_function_proto_goTypes = []interface{}{
(*DeleteResponse)(nil), // 8: function.DeleteResponse
(*DescribeRequest)(nil), // 9: function.DescribeRequest
(*DescribeResponse)(nil), // 10: function.DescribeResponse
nil, // 11: function.DeployRequest.EnvVarsEntry
(*structpb.Struct)(nil), // 12: google.protobuf.Struct
(*UpdateRequest)(nil), // 11: function.UpdateRequest
(*UpdateResponse)(nil), // 12: function.UpdateResponse
nil, // 13: function.DeployRequest.EnvVarsEntry
nil, // 14: function.Func.EnvVarsEntry
nil, // 15: function.UpdateRequest.EnvVarsEntry
(*structpb.Struct)(nil), // 16: google.protobuf.Struct
}
var file_proto_function_proto_depIdxs = []int32{
12, // 0: function.CallRequest.request:type_name -> google.protobuf.Struct
12, // 1: function.CallResponse.response:type_name -> google.protobuf.Struct
11, // 2: function.DeployRequest.env_vars:type_name -> function.DeployRequest.EnvVarsEntry
5, // 3: function.ListResponse.functions:type_name -> function.Func
5, // 4: function.DescribeResponse.function:type_name -> function.Func
0, // 5: function.Function.Call:input_type -> function.CallRequest
2, // 6: function.Function.Deploy:input_type -> function.DeployRequest
4, // 7: function.Function.List:input_type -> function.ListRequest
7, // 8: function.Function.Delete:input_type -> function.DeleteRequest
9, // 9: function.Function.Describe:input_type -> function.DescribeRequest
1, // 10: function.Function.Call:output_type -> function.CallResponse
3, // 11: function.Function.Deploy:output_type -> function.DeployResponse
6, // 12: function.Function.List:output_type -> function.ListResponse
8, // 13: function.Function.Delete:output_type -> function.DeleteResponse
10, // 14: function.Function.Describe:output_type -> function.DescribeResponse
10, // [10:15] is the sub-list for method output_type
5, // [5:10] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
16, // 0: function.CallRequest.request:type_name -> google.protobuf.Struct
16, // 1: function.CallResponse.response:type_name -> google.protobuf.Struct
13, // 2: function.DeployRequest.env_vars:type_name -> function.DeployRequest.EnvVarsEntry
14, // 3: function.Func.env_Vars:type_name -> function.Func.EnvVarsEntry
5, // 4: function.ListResponse.functions:type_name -> function.Func
5, // 5: function.DescribeResponse.function:type_name -> function.Func
15, // 6: function.UpdateRequest.env_vars:type_name -> function.UpdateRequest.EnvVarsEntry
0, // 7: function.Function.Call:input_type -> function.CallRequest
2, // 8: function.Function.Deploy:input_type -> function.DeployRequest
4, // 9: function.Function.List:input_type -> function.ListRequest
7, // 10: function.Function.Delete:input_type -> function.DeleteRequest
9, // 11: function.Function.Describe:input_type -> function.DescribeRequest
11, // 12: function.Function.Update:input_type -> function.UpdateRequest
1, // 13: function.Function.Call:output_type -> function.CallResponse
3, // 14: function.Function.Deploy:output_type -> function.DeployResponse
6, // 15: function.Function.List:output_type -> function.ListResponse
8, // 16: function.Function.Delete:output_type -> function.DeleteResponse
10, // 17: function.Function.Describe:output_type -> function.DescribeResponse
12, // 18: function.Function.Update:output_type -> function.UpdateResponse
13, // [13:19] is the sub-list for method output_type
7, // [7:13] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_proto_function_proto_init() }
@@ -990,6 +1187,30 @@ func file_proto_function_proto_init() {
return nil
}
}
file_proto_function_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_function_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateResponse); 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{
@@ -997,7 +1218,7 @@ func file_proto_function_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_function_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumMessages: 16,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -48,6 +48,7 @@ type FunctionService interface {
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
Describe(ctx context.Context, in *DescribeRequest, opts ...client.CallOption) (*DescribeResponse, error)
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
}
type functionService struct {
@@ -112,6 +113,16 @@ func (c *functionService) Describe(ctx context.Context, in *DescribeRequest, opt
return out, nil
}
func (c *functionService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
req := c.c.NewRequest(c.name, "Function.Update", in)
out := new(UpdateResponse)
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 {
@@ -120,6 +131,7 @@ type FunctionHandler interface {
List(context.Context, *ListRequest, *ListResponse) error
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
Describe(context.Context, *DescribeRequest, *DescribeResponse) error
Update(context.Context, *UpdateRequest, *UpdateResponse) error
}
func RegisterFunctionHandler(s server.Server, hdlr FunctionHandler, opts ...server.HandlerOption) error {
@@ -129,6 +141,7 @@ func RegisterFunctionHandler(s server.Server, hdlr FunctionHandler, opts ...serv
List(ctx context.Context, in *ListRequest, out *ListResponse) error
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
Describe(ctx context.Context, in *DescribeRequest, out *DescribeResponse) error
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
}
type Function struct {
function
@@ -160,3 +173,7 @@ func (h *functionHandler) Delete(ctx context.Context, in *DeleteRequest, out *De
func (h *functionHandler) Describe(ctx context.Context, in *DescribeRequest, out *DescribeResponse) error {
return h.FunctionHandler.Describe(ctx, in, out)
}
func (h *functionHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
return h.FunctionHandler.Update(ctx, in, out)
}

View File

@@ -11,6 +11,7 @@ service Function {
rpc List(ListRequest) returns (ListResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc Describe(DescribeRequest) returns (DescribeResponse) {}
rpc Update(UpdateRequest) returns (UpdateResponse) {}
}
// Call a function by name
@@ -87,6 +88,8 @@ message Func {
string runtime = 6;
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
string status = 7;
// associated env vars
map<string,string> env_Vars = 8;
}
message ListResponse {
@@ -122,3 +125,32 @@ message DescribeResponse {
// The timeout for requests to the function
string timeout = 3;
}
message UpdateRequest {
// function name
string name = 1;
// github url to repo
string repo = 2;
// optional subfolder path
string subfolder = 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;
// runtime/language of the function
// eg: php74,
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16
// dotnet3
// java11
// ruby26, ruby27
// go111, go113, go116
// python37, python38, python39
string runtime = 6;
// environment variables to pass in at runtime
map<string,string> env_vars = 7;
}
message UpdateResponse {
}