aboutsummaryrefslogtreecommitdiffstats
path: root/src/rsync/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/rsync/pkg')
-rw-r--r--src/rsync/pkg/grpc/installapp/installapp.pb.go346
-rw-r--r--src/rsync/pkg/grpc/installapp/installapp.proto45
-rw-r--r--src/rsync/pkg/grpc/installappserver/installappserver.go45
-rw-r--r--src/rsync/pkg/grpc/register.go97
4 files changed, 533 insertions, 0 deletions
diff --git a/src/rsync/pkg/grpc/installapp/installapp.pb.go b/src/rsync/pkg/grpc/installapp/installapp.pb.go
new file mode 100644
index 00000000..edb25b16
--- /dev/null
+++ b/src/rsync/pkg/grpc/installapp/installapp.pb.go
@@ -0,0 +1,346 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: installapp.proto
+
+package installapp
+
+import (
+ context "context"
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+ math "math"
+)
+
+// 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
+
+type InstallAppRequest struct {
+ AppContext string `protobuf:"bytes,1,opt,name=app_context,json=appContext,proto3" json:"app_context,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *InstallAppRequest) Reset() { *m = InstallAppRequest{} }
+func (m *InstallAppRequest) String() string { return proto.CompactTextString(m) }
+func (*InstallAppRequest) ProtoMessage() {}
+func (*InstallAppRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_e16b1077a28418a8, []int{0}
+}
+
+func (m *InstallAppRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_InstallAppRequest.Unmarshal(m, b)
+}
+func (m *InstallAppRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_InstallAppRequest.Marshal(b, m, deterministic)
+}
+func (m *InstallAppRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_InstallAppRequest.Merge(m, src)
+}
+func (m *InstallAppRequest) XXX_Size() int {
+ return xxx_messageInfo_InstallAppRequest.Size(m)
+}
+func (m *InstallAppRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_InstallAppRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_InstallAppRequest proto.InternalMessageInfo
+
+func (m *InstallAppRequest) GetAppContext() string {
+ if m != nil {
+ return m.AppContext
+ }
+ return ""
+}
+
+type InstallAppResponse struct {
+ AppContextInstalled bool `protobuf:"varint,1,opt,name=app_context_installed,json=appContextInstalled,proto3" json:"app_context_installed,omitempty"`
+ AppContextInstallMessage string `protobuf:"bytes,2,opt,name=app_context_install_message,json=appContextInstallMessage,proto3" json:"app_context_install_message,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *InstallAppResponse) Reset() { *m = InstallAppResponse{} }
+func (m *InstallAppResponse) String() string { return proto.CompactTextString(m) }
+func (*InstallAppResponse) ProtoMessage() {}
+func (*InstallAppResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_e16b1077a28418a8, []int{1}
+}
+
+func (m *InstallAppResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_InstallAppResponse.Unmarshal(m, b)
+}
+func (m *InstallAppResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_InstallAppResponse.Marshal(b, m, deterministic)
+}
+func (m *InstallAppResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_InstallAppResponse.Merge(m, src)
+}
+func (m *InstallAppResponse) XXX_Size() int {
+ return xxx_messageInfo_InstallAppResponse.Size(m)
+}
+func (m *InstallAppResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_InstallAppResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_InstallAppResponse proto.InternalMessageInfo
+
+func (m *InstallAppResponse) GetAppContextInstalled() bool {
+ if m != nil {
+ return m.AppContextInstalled
+ }
+ return false
+}
+
+func (m *InstallAppResponse) GetAppContextInstallMessage() string {
+ if m != nil {
+ return m.AppContextInstallMessage
+ }
+ return ""
+}
+
+type UninstallAppRequest struct {
+ AppContext string `protobuf:"bytes,1,opt,name=app_context,json=appContext,proto3" json:"app_context,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *UninstallAppRequest) Reset() { *m = UninstallAppRequest{} }
+func (m *UninstallAppRequest) String() string { return proto.CompactTextString(m) }
+func (*UninstallAppRequest) ProtoMessage() {}
+func (*UninstallAppRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_e16b1077a28418a8, []int{2}
+}
+
+func (m *UninstallAppRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_UninstallAppRequest.Unmarshal(m, b)
+}
+func (m *UninstallAppRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_UninstallAppRequest.Marshal(b, m, deterministic)
+}
+func (m *UninstallAppRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_UninstallAppRequest.Merge(m, src)
+}
+func (m *UninstallAppRequest) XXX_Size() int {
+ return xxx_messageInfo_UninstallAppRequest.Size(m)
+}
+func (m *UninstallAppRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_UninstallAppRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_UninstallAppRequest proto.InternalMessageInfo
+
+func (m *UninstallAppRequest) GetAppContext() string {
+ if m != nil {
+ return m.AppContext
+ }
+ return ""
+}
+
+type UninstallAppResponse struct {
+ AppContextUninstalled bool `protobuf:"varint,1,opt,name=app_context_uninstalled,json=appContextUninstalled,proto3" json:"app_context_uninstalled,omitempty"`
+ AppContextUninstallMessage string `protobuf:"bytes,2,opt,name=app_context_uninstall_message,json=appContextUninstallMessage,proto3" json:"app_context_uninstall_message,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *UninstallAppResponse) Reset() { *m = UninstallAppResponse{} }
+func (m *UninstallAppResponse) String() string { return proto.CompactTextString(m) }
+func (*UninstallAppResponse) ProtoMessage() {}
+func (*UninstallAppResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_e16b1077a28418a8, []int{3}
+}
+
+func (m *UninstallAppResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_UninstallAppResponse.Unmarshal(m, b)
+}
+func (m *UninstallAppResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_UninstallAppResponse.Marshal(b, m, deterministic)
+}
+func (m *UninstallAppResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_UninstallAppResponse.Merge(m, src)
+}
+func (m *UninstallAppResponse) XXX_Size() int {
+ return xxx_messageInfo_UninstallAppResponse.Size(m)
+}
+func (m *UninstallAppResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_UninstallAppResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_UninstallAppResponse proto.InternalMessageInfo
+
+func (m *UninstallAppResponse) GetAppContextUninstalled() bool {
+ if m != nil {
+ return m.AppContextUninstalled
+ }
+ return false
+}
+
+func (m *UninstallAppResponse) GetAppContextUninstallMessage() string {
+ if m != nil {
+ return m.AppContextUninstallMessage
+ }
+ return ""
+}
+
+func init() {
+ proto.RegisterType((*InstallAppRequest)(nil), "InstallAppRequest")
+ proto.RegisterType((*InstallAppResponse)(nil), "InstallAppResponse")
+ proto.RegisterType((*UninstallAppRequest)(nil), "UninstallAppRequest")
+ proto.RegisterType((*UninstallAppResponse)(nil), "UninstallAppResponse")
+}
+
+func init() {
+ proto.RegisterFile("installapp.proto", fileDescriptor_e16b1077a28418a8)
+}
+
+var fileDescriptor_e16b1077a28418a8 = []byte{
+ // 246 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0xcc, 0x2b, 0x2e,
+ 0x49, 0xcc, 0xc9, 0x49, 0x2c, 0x28, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0x32, 0xe1, 0x12,
+ 0xf4, 0x84, 0x88, 0x39, 0x16, 0x14, 0x04, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0xc9, 0x73,
+ 0x71, 0x27, 0x16, 0x14, 0xc4, 0x27, 0xe7, 0xe7, 0x95, 0xa4, 0x56, 0x94, 0x48, 0x30, 0x2a, 0x30,
+ 0x6a, 0x70, 0x06, 0x71, 0x25, 0x16, 0x14, 0x38, 0x43, 0x44, 0x94, 0xda, 0x19, 0xb9, 0x84, 0x90,
+ 0xb5, 0x15, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x19, 0x71, 0x89, 0x22, 0xe9, 0x8b, 0x87, 0x5a,
+ 0x96, 0x9a, 0x02, 0x36, 0x81, 0x23, 0x48, 0x18, 0x61, 0x82, 0x27, 0x4c, 0x4a, 0xc8, 0x96, 0x4b,
+ 0x1a, 0x8b, 0x9e, 0xf8, 0xdc, 0xd4, 0xe2, 0xe2, 0xc4, 0xf4, 0x54, 0x09, 0x26, 0xb0, 0xdd, 0x12,
+ 0x18, 0x3a, 0x7d, 0x21, 0xf2, 0x4a, 0x66, 0x5c, 0xc2, 0xa1, 0x79, 0x99, 0xa4, 0xfb, 0x60, 0x22,
+ 0x23, 0x97, 0x08, 0xaa, 0x46, 0xa8, 0x1f, 0xcc, 0xb8, 0xc4, 0x91, 0xdd, 0x53, 0x9a, 0x87, 0xee,
+ 0x0b, 0x51, 0x84, 0x29, 0xa1, 0x08, 0x49, 0x21, 0x47, 0x2e, 0x59, 0xac, 0xfa, 0xd0, 0x7c, 0x22,
+ 0x85, 0x45, 0x37, 0xd4, 0x2f, 0x46, 0x2d, 0x8c, 0x5c, 0x5c, 0x88, 0x08, 0x12, 0x32, 0xe7, 0xe2,
+ 0x42, 0x84, 0xb1, 0x90, 0x90, 0x1e, 0x46, 0x3c, 0x49, 0x09, 0xeb, 0x61, 0x46, 0x82, 0x12, 0x83,
+ 0x90, 0x2d, 0x17, 0x0f, 0xb2, 0xd7, 0x84, 0x44, 0xf4, 0xb0, 0x04, 0x91, 0x94, 0xa8, 0x1e, 0x36,
+ 0xff, 0x2b, 0x31, 0x24, 0xb1, 0x81, 0x53, 0x86, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x14,
+ 0x31, 0x29, 0x2d, 0x02, 0x00, 0x00,
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConnInterface
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion6
+
+// InstallappClient is the client API for Installapp service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type InstallappClient interface {
+ // Sync
+ InstallApp(ctx context.Context, in *InstallAppRequest, opts ...grpc.CallOption) (*InstallAppResponse, error)
+ UninstallApp(ctx context.Context, in *UninstallAppRequest, opts ...grpc.CallOption) (*UninstallAppResponse, error)
+}
+
+type installappClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewInstallappClient(cc grpc.ClientConnInterface) InstallappClient {
+ return &installappClient{cc}
+}
+
+func (c *installappClient) InstallApp(ctx context.Context, in *InstallAppRequest, opts ...grpc.CallOption) (*InstallAppResponse, error) {
+ out := new(InstallAppResponse)
+ err := c.cc.Invoke(ctx, "/installapp/InstallApp", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *installappClient) UninstallApp(ctx context.Context, in *UninstallAppRequest, opts ...grpc.CallOption) (*UninstallAppResponse, error) {
+ out := new(UninstallAppResponse)
+ err := c.cc.Invoke(ctx, "/installapp/UninstallApp", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// InstallappServer is the server API for Installapp service.
+type InstallappServer interface {
+ // Sync
+ InstallApp(context.Context, *InstallAppRequest) (*InstallAppResponse, error)
+ UninstallApp(context.Context, *UninstallAppRequest) (*UninstallAppResponse, error)
+}
+
+// UnimplementedInstallappServer can be embedded to have forward compatible implementations.
+type UnimplementedInstallappServer struct {
+}
+
+func (*UnimplementedInstallappServer) InstallApp(ctx context.Context, req *InstallAppRequest) (*InstallAppResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method InstallApp not implemented")
+}
+func (*UnimplementedInstallappServer) UninstallApp(ctx context.Context, req *UninstallAppRequest) (*UninstallAppResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method UninstallApp not implemented")
+}
+
+func RegisterInstallappServer(s *grpc.Server, srv InstallappServer) {
+ s.RegisterService(&_Installapp_serviceDesc, srv)
+}
+
+func _Installapp_InstallApp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(InstallAppRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(InstallappServer).InstallApp(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/installapp/InstallApp",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(InstallappServer).InstallApp(ctx, req.(*InstallAppRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Installapp_UninstallApp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UninstallAppRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(InstallappServer).UninstallApp(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/installapp/UninstallApp",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(InstallappServer).UninstallApp(ctx, req.(*UninstallAppRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+var _Installapp_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "installapp",
+ HandlerType: (*InstallappServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "InstallApp",
+ Handler: _Installapp_InstallApp_Handler,
+ },
+ {
+ MethodName: "UninstallApp",
+ Handler: _Installapp_UninstallApp_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "installapp.proto",
+}
diff --git a/src/rsync/pkg/grpc/installapp/installapp.proto b/src/rsync/pkg/grpc/installapp/installapp.proto
new file mode 100644
index 00000000..cd213567
--- /dev/null
+++ b/src/rsync/pkg/grpc/installapp/installapp.proto
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto3";
+
+service installapp {
+ // Sync
+ rpc InstallApp(InstallAppRequest) returns (InstallAppResponse) {
+ }
+
+ rpc UninstallApp(UninstallAppRequest) returns (UninstallAppResponse) {
+ }
+}
+
+message InstallAppRequest {
+ string app_context = 1;
+}
+
+message InstallAppResponse {
+ bool app_context_installed = 1;
+ string app_context_install_message = 2;
+}
+
+message UninstallAppRequest {
+ string app_context = 1;
+}
+
+message UninstallAppResponse {
+ bool app_context_uninstalled = 1;
+ string app_context_uninstall_message = 2;
+}
+
diff --git a/src/rsync/pkg/grpc/installappserver/installappserver.go b/src/rsync/pkg/grpc/installappserver/installappserver.go
new file mode 100644
index 00000000..ca7c85cc
--- /dev/null
+++ b/src/rsync/pkg/grpc/installappserver/installappserver.go
@@ -0,0 +1,45 @@
+/*
+Copyright 2020 Intel Corporation.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package installappserver
+
+import (
+ "context"
+ "encoding/json"
+ "log"
+
+ "rsync/pkg/grpc/installapp"
+ //"google.golang.org/grpc/codes"
+ //"google.golang.org/grpc/status"
+)
+
+type installappServer struct {
+ installapp.UnimplementedInstallappServer
+}
+
+func (cs *installappServer) InstallApp(ctx context.Context, req *installapp.InstallAppRequest) (*installapp.InstallAppResponse, error) {
+ installAppReq, _ := json.Marshal(req)
+ log.Println("GRPC Server received installAppRequest: ", string(installAppReq))
+
+ // Insert call to Server Functionality here
+ //
+ //
+
+ return &installapp.InstallAppResponse{AppContextInstalled: true}, nil
+}
+
+// NewInstallAppServer exported
+func NewInstallAppServer() *installappServer {
+ s := &installappServer{}
+ return s
+}
diff --git a/src/rsync/pkg/grpc/register.go b/src/rsync/pkg/grpc/register.go
new file mode 100644
index 00000000..4755256f
--- /dev/null
+++ b/src/rsync/pkg/grpc/register.go
@@ -0,0 +1,97 @@
+/*
+Copyright 2020 Intel Corporation.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package grpc
+
+import (
+ "os"
+ "strconv"
+ "strings"
+
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ module "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
+)
+
+const default_host = "localhost"
+const default_port = 9031
+const default_rsync_name = "rsync"
+const ENV_RSYNC_NAME = "RSYNC_NAME"
+
+func GetServerHostPort() (string, int) {
+
+ // expect name of this rsync program to be in env variable "RSYNC_NAME" - e.g. RSYNC_NAME="rsync"
+ serviceName := os.Getenv(ENV_RSYNC_NAME)
+ if serviceName == "" {
+ serviceName = default_rsync_name
+ log.Info("Using default name for RSYNC service name", log.Fields{
+ "Name": serviceName,
+ })
+ }
+
+ // expect service name to be in env variable - e.g. RSYNC_SERVICE_HOST
+ host := os.Getenv(strings.ToUpper(serviceName) + "_SERVICE_HOST")
+ if host == "" {
+ host = default_host
+ log.Info("Using default host for rsync gRPC controller", log.Fields{
+ "Host": host,
+ })
+ }
+
+ // expect service port to be in env variable - e.g. RSYNC_SERVICE_PORT
+ port, err := strconv.Atoi(os.Getenv(strings.ToUpper(serviceName) + "_SERVICE_PORT"))
+ if err != nil || port < 0 {
+ port = default_port
+ log.Info("Using default port for rsync gRPC controller", log.Fields{
+ "Port": port,
+ })
+ }
+ return host, port
+}
+
+func RegisterGrpcServer(host string, port int) error {
+ // expect name of this rsync program to be in env variable "RSYNC_NAME" - e.g. RSYNC_NAME="rsync"
+ // This will be the name of the controller that is registered in the orchestrator controller API
+ // This same name will be used as the key name for intents in the deployment intent group
+ serviceName := os.Getenv(ENV_RSYNC_NAME)
+ if serviceName == "" {
+ serviceName = default_rsync_name
+ log.Info("Using default name for rsync service name", log.Fields{
+ "Name": serviceName,
+ })
+ }
+
+ client := module.NewControllerClient()
+
+ // Create or update the controller entry
+ controller := module.Controller{
+ Metadata: module.Metadata{
+ Name: serviceName,
+ },
+ Spec: module.ControllerSpec{
+ Host: host,
+ Port: port,
+ Type: module.CONTROLLER_TYPE_ACTION,
+ Priority: module.MinControllerPriority,
+ },
+ }
+ _, err := client.CreateController(controller, true)
+ if err != nil {
+ log.Error("Failed to create/update a gRPC controller", log.Fields{
+ "Error": err,
+ "Controller": serviceName,
+ })
+ return err
+ }
+
+ return nil
+}