added barebones terminal, refactoring coordinators to be unique again :(

main
KeeganForelight 3 years ago
parent 95a00cb940
commit 31c1a702a7

Binary file not shown.

Binary file not shown.

@ -1,7 +1,11 @@
package main
import (
_ "fmt"
"fmt"
"flag"
"log"
"os"
"strconv"
"FRMS/internal/pkg/tui"
)
@ -9,16 +13,34 @@ type TUI interface {
Start()
}
func NewTUI(ch chan error) TUI {
return tui.NewDisplay(ch)
func NewTUI(ip string, port int, ch chan error) TUI {
return tui.NewTUI(ip, port, ch)
}
func main() {
var port int
var err error
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w,"Usage: %s port \n", os.Args[0])
}
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
args := flag.Args()
if port, err = strconv.Atoi(args[0]); port < 1024 || port > 65536 {
flag.Usage()
log.Fatal("Port must be between [1023,65535]")
} else if err != nil {
log.Fatal(err)
}
ch := make(chan error)
t := NewTUI(ch)
t := NewTUI("192.1.168.136",port,ch)
go t.Start()
err := <-ch
err = <-ch
if err != nil {
fmt.Println(err)
log.Fatal(err)
}
}

Binary file not shown.

@ -0,0 +1,899 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.6.1
// source: internal/pkg/grpc/management.proto
package grpc
import (
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)
)
type GetReactorsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
}
func (x *GetReactorsRequest) Reset() {
*x = GetReactorsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetReactorsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetReactorsRequest) ProtoMessage() {}
func (x *GetReactorsRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 GetReactorsRequest.ProtoReflect.Descriptor instead.
func (*GetReactorsRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{0}
}
func (x *GetReactorsRequest) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
type GetReactorsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
Reactors []*Reactor `protobuf:"bytes,2,rep,name=reactors,proto3" json:"reactors,omitempty"`
}
func (x *GetReactorsResponse) Reset() {
*x = GetReactorsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetReactorsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetReactorsResponse) ProtoMessage() {}
func (x *GetReactorsResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 GetReactorsResponse.ProtoReflect.Descriptor instead.
func (*GetReactorsResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{1}
}
func (x *GetReactorsResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *GetReactorsResponse) GetReactors() []*Reactor {
if x != nil {
return x.Reactors
}
return nil
}
type GetReactorDevicesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
}
func (x *GetReactorDevicesRequest) Reset() {
*x = GetReactorDevicesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetReactorDevicesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetReactorDevicesRequest) ProtoMessage() {}
func (x *GetReactorDevicesRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 GetReactorDevicesRequest.ProtoReflect.Descriptor instead.
func (*GetReactorDevicesRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{2}
}
func (x *GetReactorDevicesRequest) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *GetReactorDevicesRequest) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
type GetReactorDevicesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
Devices []*Dev `protobuf:"bytes,3,rep,name=devices,proto3" json:"devices,omitempty"`
}
func (x *GetReactorDevicesResponse) Reset() {
*x = GetReactorDevicesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetReactorDevicesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetReactorDevicesResponse) ProtoMessage() {}
func (x *GetReactorDevicesResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 GetReactorDevicesResponse.ProtoReflect.Descriptor instead.
func (*GetReactorDevicesResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{3}
}
func (x *GetReactorDevicesResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *GetReactorDevicesResponse) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
func (x *GetReactorDevicesResponse) GetDevices() []*Dev {
if x != nil {
return x.Devices
}
return nil
}
type DeleteReactorRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
}
func (x *DeleteReactorRequest) Reset() {
*x = DeleteReactorRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteReactorRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteReactorRequest) ProtoMessage() {}
func (x *DeleteReactorRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 DeleteReactorRequest.ProtoReflect.Descriptor instead.
func (*DeleteReactorRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{4}
}
func (x *DeleteReactorRequest) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *DeleteReactorRequest) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
type DeleteReactorResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`
}
func (x *DeleteReactorResponse) Reset() {
*x = DeleteReactorResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteReactorResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteReactorResponse) ProtoMessage() {}
func (x *DeleteReactorResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 DeleteReactorResponse.ProtoReflect.Descriptor instead.
func (*DeleteReactorResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{5}
}
func (x *DeleteReactorResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *DeleteReactorResponse) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
func (x *DeleteReactorResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
type DeleteReactorDeviceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
DevAddr int32 `protobuf:"varint,3,opt,name=devAddr,proto3" json:"devAddr,omitempty"`
}
func (x *DeleteReactorDeviceRequest) Reset() {
*x = DeleteReactorDeviceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteReactorDeviceRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteReactorDeviceRequest) ProtoMessage() {}
func (x *DeleteReactorDeviceRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 DeleteReactorDeviceRequest.ProtoReflect.Descriptor instead.
func (*DeleteReactorDeviceRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{6}
}
func (x *DeleteReactorDeviceRequest) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *DeleteReactorDeviceRequest) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
func (x *DeleteReactorDeviceRequest) GetDevAddr() int32 {
if x != nil {
return x.DevAddr
}
return 0
}
type DeleteReactorDeviceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ReactorId uint32 `protobuf:"varint,2,opt,name=reactorId,proto3" json:"reactorId,omitempty"`
DevAddr int32 `protobuf:"varint,3,opt,name=devAddr,proto3" json:"devAddr,omitempty"`
Success bool `protobuf:"varint,4,opt,name=success,proto3" json:"success,omitempty"`
}
func (x *DeleteReactorDeviceResponse) Reset() {
*x = DeleteReactorDeviceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteReactorDeviceResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteReactorDeviceResponse) ProtoMessage() {}
func (x *DeleteReactorDeviceResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 DeleteReactorDeviceResponse.ProtoReflect.Descriptor instead.
func (*DeleteReactorDeviceResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteReactorDeviceResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *DeleteReactorDeviceResponse) GetReactorId() uint32 {
if x != nil {
return x.ReactorId
}
return 0
}
func (x *DeleteReactorDeviceResponse) GetDevAddr() int32 {
if x != nil {
return x.DevAddr
}
return 0
}
func (x *DeleteReactorDeviceResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
type Reactor struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Status bool `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *Reactor) Reset() {
*x = Reactor{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Reactor) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Reactor) ProtoMessage() {}
func (x *Reactor) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_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 Reactor.ProtoReflect.Descriptor instead.
func (*Reactor) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{8}
}
func (x *Reactor) GetId() uint32 {
if x != nil {
return x.Id
}
return 0
}
func (x *Reactor) GetStatus() bool {
if x != nil {
return x.Status
}
return false
}
type Dev struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Addr int32 `protobuf:"varint,1,opt,name=addr,proto3" json:"addr,omitempty"`
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
Data string `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *Dev) Reset() {
*x = Dev{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Dev) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Dev) ProtoMessage() {}
func (x *Dev) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_management_proto_msgTypes[9]
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 Dev.ProtoReflect.Descriptor instead.
func (*Dev) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_management_proto_rawDescGZIP(), []int{9}
}
func (x *Dev) GetAddr() int32 {
if x != nil {
return x.Addr
}
return 0
}
func (x *Dev) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *Dev) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *Dev) GetData() string {
if x != nil {
return x.Data
}
return ""
}
var File_internal_pkg_grpc_management_proto protoreflect.FileDescriptor
var file_internal_pkg_grpc_management_proto_rawDesc = []byte{
0x0a, 0x22, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67,
0x72, 0x70, 0x63, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, 0x30, 0x0a, 0x12, 0x47, 0x65,
0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x5c, 0x0a, 0x13,
0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12,
0x29, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72,
0x52, 0x08, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x54, 0x0a, 0x18, 0x47, 0x65,
0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64,
0x22, 0x7a, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65,
0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61,
0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65,
0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x07, 0x64, 0x65, 0x76, 0x69, 0x63,
0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e,
0x44, 0x65, 0x76, 0x52, 0x07, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x22, 0x50, 0x0a, 0x14,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64,
0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x22, 0x6b,
0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x49,
0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x70, 0x0a, 0x1a, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72,
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x61, 0x63, 0x74, 0x6f,
0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x76, 0x41, 0x64, 0x64, 0x72, 0x18, 0x03,
0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, 0x65, 0x76, 0x41, 0x64, 0x64, 0x72, 0x22, 0x8b, 0x01,
0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44,
0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x61,
0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65,
0x61, 0x63, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x76, 0x41, 0x64,
0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, 0x65, 0x76, 0x41, 0x64, 0x64,
0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01,
0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x31, 0x0a, 0x07, 0x52,
0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x59,
0x0a, 0x03, 0x44, 0x65, 0x76, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20,
0x01, 0x28, 0x05, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a,
0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73,
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xcc, 0x02, 0x0a, 0x0a, 0x6d, 0x61,
0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52,
0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x18, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47,
0x65, 0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x19, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63,
0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x11,
0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
0x73, 0x12, 0x1e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63,
0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x63,
0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63,
0x74, 0x6f, 0x72, 0x12, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61,
0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x13,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76,
0x69, 0x63, 0x65, 0x12, 0x20, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x13, 0x5a, 0x11, 0x69, 0x6e, 0x74, 0x65,
0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_internal_pkg_grpc_management_proto_rawDescOnce sync.Once
file_internal_pkg_grpc_management_proto_rawDescData = file_internal_pkg_grpc_management_proto_rawDesc
)
func file_internal_pkg_grpc_management_proto_rawDescGZIP() []byte {
file_internal_pkg_grpc_management_proto_rawDescOnce.Do(func() {
file_internal_pkg_grpc_management_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_pkg_grpc_management_proto_rawDescData)
})
return file_internal_pkg_grpc_management_proto_rawDescData
}
var file_internal_pkg_grpc_management_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_internal_pkg_grpc_management_proto_goTypes = []interface{}{
(*GetReactorsRequest)(nil), // 0: grpc.GetReactorsRequest
(*GetReactorsResponse)(nil), // 1: grpc.GetReactorsResponse
(*GetReactorDevicesRequest)(nil), // 2: grpc.GetReactorDevicesRequest
(*GetReactorDevicesResponse)(nil), // 3: grpc.GetReactorDevicesResponse
(*DeleteReactorRequest)(nil), // 4: grpc.DeleteReactorRequest
(*DeleteReactorResponse)(nil), // 5: grpc.DeleteReactorResponse
(*DeleteReactorDeviceRequest)(nil), // 6: grpc.DeleteReactorDeviceRequest
(*DeleteReactorDeviceResponse)(nil), // 7: grpc.DeleteReactorDeviceResponse
(*Reactor)(nil), // 8: grpc.Reactor
(*Dev)(nil), // 9: grpc.Dev
}
var file_internal_pkg_grpc_management_proto_depIdxs = []int32{
8, // 0: grpc.GetReactorsResponse.reactors:type_name -> grpc.Reactor
9, // 1: grpc.GetReactorDevicesResponse.devices:type_name -> grpc.Dev
0, // 2: grpc.management.GetReactors:input_type -> grpc.GetReactorsRequest
2, // 3: grpc.management.GetReactorDevices:input_type -> grpc.GetReactorDevicesRequest
4, // 4: grpc.management.DeleteReactor:input_type -> grpc.DeleteReactorRequest
6, // 5: grpc.management.DeleteReactorDevice:input_type -> grpc.DeleteReactorDeviceRequest
1, // 6: grpc.management.GetReactors:output_type -> grpc.GetReactorsResponse
3, // 7: grpc.management.GetReactorDevices:output_type -> grpc.GetReactorDevicesResponse
5, // 8: grpc.management.DeleteReactor:output_type -> grpc.DeleteReactorResponse
7, // 9: grpc.management.DeleteReactorDevice:output_type -> grpc.DeleteReactorDeviceResponse
6, // [6:10] is the sub-list for method output_type
2, // [2:6] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_internal_pkg_grpc_management_proto_init() }
func file_internal_pkg_grpc_management_proto_init() {
if File_internal_pkg_grpc_management_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_internal_pkg_grpc_management_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetReactorsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetReactorsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetReactorDevicesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetReactorDevicesResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteReactorRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteReactorResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteReactorDeviceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteReactorDeviceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Reactor); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_management_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Dev); 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_internal_pkg_grpc_management_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_internal_pkg_grpc_management_proto_goTypes,
DependencyIndexes: file_internal_pkg_grpc_management_proto_depIdxs,
MessageInfos: file_internal_pkg_grpc_management_proto_msgTypes,
}.Build()
File_internal_pkg_grpc_management_proto = out.File
file_internal_pkg_grpc_management_proto_rawDesc = nil
file_internal_pkg_grpc_management_proto_goTypes = nil
file_internal_pkg_grpc_management_proto_depIdxs = nil
}

@ -0,0 +1,67 @@
syntax = "proto3";
package grpc;
option go_package = "internal/pkg/grpc";
service management {
rpc GetReactors(GetReactorsRequest) returns (GetReactorsResponse);
rpc GetReactorDevices(GetReactorDevicesRequest) returns (GetReactorDevicesResponse);
rpc DeleteReactor(DeleteReactorRequest) returns (DeleteReactorResponse);
rpc DeleteReactorDevice(DeleteReactorDeviceRequest) returns (DeleteReactorDeviceResponse);
}
message GetReactorsRequest {
uint32 clientId = 1;
}
message GetReactorsResponse {
uint32 clientId = 1;
repeated Reactor reactors = 2;
}
message GetReactorDevicesRequest {
uint32 clientId = 1;
uint32 reactorId = 2;
}
message GetReactorDevicesResponse {
uint32 clientId = 1;
uint32 reactorId = 2;
repeated Dev devices = 3;
}
message DeleteReactorRequest {
uint32 clientId = 1;
uint32 reactorId = 2;
}
message DeleteReactorResponse {
uint32 clientId = 1;
uint32 reactorId = 2;
bool success = 3;
}
message DeleteReactorDeviceRequest {
uint32 clientId = 1;
uint32 reactorId = 2;
int32 devAddr = 3;
}
message DeleteReactorDeviceResponse {
uint32 clientId = 1;
uint32 reactorId = 2;
int32 devAddr = 3;
bool success = 4;
}
message Reactor {
uint32 id = 1;
bool status = 2;
}
message Dev {
int32 addr = 1;
string type = 2;
string status = 3;
string data = 4;
}

@ -0,0 +1,213 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.6.1
// source: internal/pkg/grpc/management.proto
package grpc
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// ManagementClient is the client API for Management service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ManagementClient interface {
GetReactors(ctx context.Context, in *GetReactorsRequest, opts ...grpc.CallOption) (*GetReactorsResponse, error)
GetReactorDevices(ctx context.Context, in *GetReactorDevicesRequest, opts ...grpc.CallOption) (*GetReactorDevicesResponse, error)
DeleteReactor(ctx context.Context, in *DeleteReactorRequest, opts ...grpc.CallOption) (*DeleteReactorResponse, error)
DeleteReactorDevice(ctx context.Context, in *DeleteReactorDeviceRequest, opts ...grpc.CallOption) (*DeleteReactorDeviceResponse, error)
}
type managementClient struct {
cc grpc.ClientConnInterface
}
func NewManagementClient(cc grpc.ClientConnInterface) ManagementClient {
return &managementClient{cc}
}
func (c *managementClient) GetReactors(ctx context.Context, in *GetReactorsRequest, opts ...grpc.CallOption) (*GetReactorsResponse, error) {
out := new(GetReactorsResponse)
err := c.cc.Invoke(ctx, "/grpc.management/GetReactors", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *managementClient) GetReactorDevices(ctx context.Context, in *GetReactorDevicesRequest, opts ...grpc.CallOption) (*GetReactorDevicesResponse, error) {
out := new(GetReactorDevicesResponse)
err := c.cc.Invoke(ctx, "/grpc.management/GetReactorDevices", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *managementClient) DeleteReactor(ctx context.Context, in *DeleteReactorRequest, opts ...grpc.CallOption) (*DeleteReactorResponse, error) {
out := new(DeleteReactorResponse)
err := c.cc.Invoke(ctx, "/grpc.management/DeleteReactor", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *managementClient) DeleteReactorDevice(ctx context.Context, in *DeleteReactorDeviceRequest, opts ...grpc.CallOption) (*DeleteReactorDeviceResponse, error) {
out := new(DeleteReactorDeviceResponse)
err := c.cc.Invoke(ctx, "/grpc.management/DeleteReactorDevice", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ManagementServer is the server API for Management service.
// All implementations must embed UnimplementedManagementServer
// for forward compatibility
type ManagementServer interface {
GetReactors(context.Context, *GetReactorsRequest) (*GetReactorsResponse, error)
GetReactorDevices(context.Context, *GetReactorDevicesRequest) (*GetReactorDevicesResponse, error)
DeleteReactor(context.Context, *DeleteReactorRequest) (*DeleteReactorResponse, error)
DeleteReactorDevice(context.Context, *DeleteReactorDeviceRequest) (*DeleteReactorDeviceResponse, error)
mustEmbedUnimplementedManagementServer()
}
// UnimplementedManagementServer must be embedded to have forward compatible implementations.
type UnimplementedManagementServer struct {
}
func (UnimplementedManagementServer) GetReactors(context.Context, *GetReactorsRequest) (*GetReactorsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetReactors not implemented")
}
func (UnimplementedManagementServer) GetReactorDevices(context.Context, *GetReactorDevicesRequest) (*GetReactorDevicesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetReactorDevices not implemented")
}
func (UnimplementedManagementServer) DeleteReactor(context.Context, *DeleteReactorRequest) (*DeleteReactorResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteReactor not implemented")
}
func (UnimplementedManagementServer) DeleteReactorDevice(context.Context, *DeleteReactorDeviceRequest) (*DeleteReactorDeviceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteReactorDevice not implemented")
}
func (UnimplementedManagementServer) mustEmbedUnimplementedManagementServer() {}
// UnsafeManagementServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ManagementServer will
// result in compilation errors.
type UnsafeManagementServer interface {
mustEmbedUnimplementedManagementServer()
}
func RegisterManagementServer(s grpc.ServiceRegistrar, srv ManagementServer) {
s.RegisterService(&Management_ServiceDesc, srv)
}
func _Management_GetReactors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetReactorsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ManagementServer).GetReactors(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.management/GetReactors",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ManagementServer).GetReactors(ctx, req.(*GetReactorsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Management_GetReactorDevices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetReactorDevicesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ManagementServer).GetReactorDevices(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.management/GetReactorDevices",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ManagementServer).GetReactorDevices(ctx, req.(*GetReactorDevicesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Management_DeleteReactor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteReactorRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ManagementServer).DeleteReactor(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.management/DeleteReactor",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ManagementServer).DeleteReactor(ctx, req.(*DeleteReactorRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Management_DeleteReactorDevice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteReactorDeviceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ManagementServer).DeleteReactorDevice(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.management/DeleteReactorDevice",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ManagementServer).DeleteReactorDevice(ctx, req.(*DeleteReactorDeviceRequest))
}
return interceptor(ctx, in, info, handler)
}
// Management_ServiceDesc is the grpc.ServiceDesc for Management service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Management_ServiceDesc = grpc.ServiceDesc{
ServiceName: "grpc.management",
HandlerType: (*ManagementServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetReactors",
Handler: _Management_GetReactors_Handler,
},
{
MethodName: "GetReactorDevices",
Handler: _Management_GetReactorDevices_Handler,
},
{
MethodName: "DeleteReactor",
Handler: _Management_DeleteReactor_Handler,
},
{
MethodName: "DeleteReactorDevice",
Handler: _Management_DeleteReactorDevice_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "internal/pkg/grpc/management.proto",
}

@ -20,20 +20,20 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ClientDiscoveryRequest struct {
type ReactorClientRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id uint32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
Ip string `protobuf:"bytes,2,opt,name=Ip,proto3" json:"Ip,omitempty"`
Port int32 `protobuf:"varint,3,opt,name=Port,proto3" json:"Port,omitempty"`
Model string `protobuf:"bytes,4,opt,name=Model,proto3" json:"Model,omitempty"`
ClientType string `protobuf:"bytes,5,opt,name=ClientType,proto3" json:"ClientType,omitempty"`
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ClientIp string `protobuf:"bytes,2,opt,name=clientIp,proto3" json:"clientIp,omitempty"`
ClientPort int32 `protobuf:"varint,3,opt,name=clientPort,proto3" json:"clientPort,omitempty"`
ClientModel string `protobuf:"bytes,4,opt,name=clientModel,proto3" json:"clientModel,omitempty"`
ClientType string `protobuf:"bytes,5,opt,name=clientType,proto3" json:"clientType,omitempty"`
}
func (x *ClientDiscoveryRequest) Reset() {
*x = ClientDiscoveryRequest{}
func (x *ReactorClientRequest) Reset() {
*x = ReactorClientRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -41,13 +41,13 @@ func (x *ClientDiscoveryRequest) Reset() {
}
}
func (x *ClientDiscoveryRequest) String() string {
func (x *ReactorClientRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ClientDiscoveryRequest) ProtoMessage() {}
func (*ReactorClientRequest) ProtoMessage() {}
func (x *ClientDiscoveryRequest) ProtoReflect() protoreflect.Message {
func (x *ReactorClientRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -59,56 +59,57 @@ func (x *ClientDiscoveryRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ClientDiscoveryRequest.ProtoReflect.Descriptor instead.
func (*ClientDiscoveryRequest) Descriptor() ([]byte, []int) {
// Deprecated: Use ReactorClientRequest.ProtoReflect.Descriptor instead.
func (*ReactorClientRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_server_proto_rawDescGZIP(), []int{0}
}
func (x *ClientDiscoveryRequest) GetId() uint32 {
func (x *ReactorClientRequest) GetClientId() uint32 {
if x != nil {
return x.Id
return x.ClientId
}
return 0
}
func (x *ClientDiscoveryRequest) GetIp() string {
func (x *ReactorClientRequest) GetClientIp() string {
if x != nil {
return x.Ip
return x.ClientIp
}
return ""
}
func (x *ClientDiscoveryRequest) GetPort() int32 {
func (x *ReactorClientRequest) GetClientPort() int32 {
if x != nil {
return x.Port
return x.ClientPort
}
return 0
}
func (x *ClientDiscoveryRequest) GetModel() string {
func (x *ReactorClientRequest) GetClientModel() string {
if x != nil {
return x.Model
return x.ClientModel
}
return ""
}
func (x *ClientDiscoveryRequest) GetClientType() string {
func (x *ReactorClientRequest) GetClientType() string {
if x != nil {
return x.ClientType
}
return ""
}
type ClientDiscoveryResponse struct {
type ReactorClientResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Success bool `protobuf:"varint,1,opt,name=Success,proto3" json:"Success,omitempty"`
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
Success bool `protobuf:"varint,2,opt,name=Success,proto3" json:"Success,omitempty"`
}
func (x *ClientDiscoveryResponse) Reset() {
*x = ClientDiscoveryResponse{}
func (x *ReactorClientResponse) Reset() {
*x = ReactorClientResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -116,13 +117,13 @@ func (x *ClientDiscoveryResponse) Reset() {
}
}
func (x *ClientDiscoveryResponse) String() string {
func (x *ReactorClientResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ClientDiscoveryResponse) ProtoMessage() {}
func (*ReactorClientResponse) ProtoMessage() {}
func (x *ClientDiscoveryResponse) ProtoReflect() protoreflect.Message {
func (x *ReactorClientResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -134,44 +135,180 @@ func (x *ClientDiscoveryResponse) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ClientDiscoveryResponse.ProtoReflect.Descriptor instead.
func (*ClientDiscoveryResponse) Descriptor() ([]byte, []int) {
// Deprecated: Use ReactorClientResponse.ProtoReflect.Descriptor instead.
func (*ReactorClientResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_server_proto_rawDescGZIP(), []int{1}
}
func (x *ClientDiscoveryResponse) GetSuccess() bool {
func (x *ReactorClientResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *ReactorClientResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
type TUIClientRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
}
func (x *TUIClientRequest) Reset() {
*x = TUIClientRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TUIClientRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TUIClientRequest) ProtoMessage() {}
func (x *TUIClientRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_server_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 TUIClientRequest.ProtoReflect.Descriptor instead.
func (*TUIClientRequest) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_server_proto_rawDescGZIP(), []int{2}
}
func (x *TUIClientRequest) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
type TUIClientResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientId uint32 `protobuf:"varint,1,opt,name=clientId,proto3" json:"clientId,omitempty"`
ServerIp string `protobuf:"bytes,2,opt,name=serverIp,proto3" json:"serverIp,omitempty"`
ServerPort int32 `protobuf:"varint,3,opt,name=serverPort,proto3" json:"serverPort,omitempty"`
}
func (x *TUIClientResponse) Reset() {
*x = TUIClientResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_pkg_grpc_server_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TUIClientResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TUIClientResponse) ProtoMessage() {}
func (x *TUIClientResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_pkg_grpc_server_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 TUIClientResponse.ProtoReflect.Descriptor instead.
func (*TUIClientResponse) Descriptor() ([]byte, []int) {
return file_internal_pkg_grpc_server_proto_rawDescGZIP(), []int{3}
}
func (x *TUIClientResponse) GetClientId() uint32 {
if x != nil {
return x.ClientId
}
return 0
}
func (x *TUIClientResponse) GetServerIp() string {
if x != nil {
return x.ServerIp
}
return ""
}
func (x *TUIClientResponse) GetServerPort() int32 {
if x != nil {
return x.ServerPort
}
return 0
}
var File_internal_pkg_grpc_server_proto protoreflect.FileDescriptor
var file_internal_pkg_grpc_server_proto_rawDesc = []byte{
0x0a, 0x1e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67,
0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, 0x82, 0x01, 0x0a, 0x16, 0x43, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x49,
0x64, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49,
0x70, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x33, 0x0a, 0x17, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73,
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
0x32, 0x62, 0x0a, 0x09, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x12, 0x55, 0x0a,
0x16, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79,
0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x42, 0x13, 0x5a, 0x11, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, 0xb0, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x61, 0x63, 0x74,
0x6f, 0x72, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x4d, 0x0a, 0x15, 0x52, 0x65, 0x61,
0x63, 0x74, 0x6f, 0x72, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18,
0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52,
0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x2e, 0x0a, 0x10, 0x54, 0x55, 0x49, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08,
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x6b, 0x0a, 0x11, 0x54, 0x55, 0x49, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x49, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x49, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x50,
0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65,
0x72, 0x50, 0x6f, 0x72, 0x74, 0x32, 0xb3, 0x01, 0x0a, 0x09, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x68,
0x61, 0x6b, 0x65, 0x12, 0x58, 0x0a, 0x1d, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x48, 0x61, 0x6e,
0x64, 0x6c, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x63,
0x74, 0x6f, 0x72, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a,
0x19, 0x54, 0x55, 0x49, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76,
0x65, 0x72, 0x79, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x70,
0x63, 0x2e, 0x54, 0x55, 0x49, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x55, 0x49, 0x43, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x13, 0x5a, 0x11, 0x69,
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -186,16 +323,20 @@ func file_internal_pkg_grpc_server_proto_rawDescGZIP() []byte {
return file_internal_pkg_grpc_server_proto_rawDescData
}
var file_internal_pkg_grpc_server_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_internal_pkg_grpc_server_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_internal_pkg_grpc_server_proto_goTypes = []interface{}{
(*ClientDiscoveryRequest)(nil), // 0: grpc.ClientDiscoveryRequest
(*ClientDiscoveryResponse)(nil), // 1: grpc.ClientDiscoveryResponse
(*ReactorClientRequest)(nil), // 0: grpc.ReactorClientRequest
(*ReactorClientResponse)(nil), // 1: grpc.ReactorClientResponse
(*TUIClientRequest)(nil), // 2: grpc.TUIClientRequest
(*TUIClientResponse)(nil), // 3: grpc.TUIClientResponse
}
var file_internal_pkg_grpc_server_proto_depIdxs = []int32{
0, // 0: grpc.handshake.ClientDiscoveryHandler:input_type -> grpc.ClientDiscoveryRequest
1, // 1: grpc.handshake.ClientDiscoveryHandler:output_type -> grpc.ClientDiscoveryResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // 0: grpc.handshake.ReactorClientDiscoveryHandler:input_type -> grpc.ReactorClientRequest
2, // 1: grpc.handshake.TUIClientDiscoveryHandler:input_type -> grpc.TUIClientRequest
1, // 2: grpc.handshake.ReactorClientDiscoveryHandler:output_type -> grpc.ReactorClientResponse
3, // 3: grpc.handshake.TUIClientDiscoveryHandler:output_type -> grpc.TUIClientResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@ -208,7 +349,7 @@ func file_internal_pkg_grpc_server_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_internal_pkg_grpc_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ClientDiscoveryRequest); i {
switch v := v.(*ReactorClientRequest); i {
case 0:
return &v.state
case 1:
@ -220,7 +361,31 @@ func file_internal_pkg_grpc_server_proto_init() {
}
}
file_internal_pkg_grpc_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ClientDiscoveryResponse); i {
switch v := v.(*ReactorClientResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TUIClientRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_pkg_grpc_server_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TUIClientResponse); i {
case 0:
return &v.state
case 1:
@ -238,7 +403,7 @@ func file_internal_pkg_grpc_server_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_internal_pkg_grpc_server_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},

@ -4,17 +4,28 @@ package grpc;
option go_package = "internal/pkg/grpc";
service handshake {
rpc ClientDiscoveryHandler(ClientDiscoveryRequest) returns (ClientDiscoveryResponse);
rpc ReactorClientDiscoveryHandler(ReactorClientRequest) returns (ReactorClientResponse);
rpc TUIClientDiscoveryHandler(TUIClientRequest) returns (TUIClientResponse);
}
message ClientDiscoveryRequest {
uint32 Id = 1;
string Ip = 2;
int32 Port = 3;
string Model = 4;
string ClientType = 5;
message ReactorClientRequest {
uint32 clientId = 1;
string clientIp = 2;
int32 clientPort = 3;
string clientModel = 4;
}
message ClientDiscoveryResponse {
bool Success = 1;
message ReactorClientResponse {
uint32 clientId = 1;
bool Success = 2;
}
message TUIClientRequest {
uint32 clientId = 1;
}
message TUIClientResponse {
uint32 clientId = 1;
string serverIp = 2;
int32 serverPort = 3;
}

@ -22,7 +22,8 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HandshakeClient interface {
ClientDiscoveryHandler(ctx context.Context, in *ClientDiscoveryRequest, opts ...grpc.CallOption) (*ClientDiscoveryResponse, error)
ReactorClientDiscoveryHandler(ctx context.Context, in *ReactorClientRequest, opts ...grpc.CallOption) (*ReactorClientResponse, error)
TUIClientDiscoveryHandler(ctx context.Context, in *TUIClientRequest, opts ...grpc.CallOption) (*TUIClientResponse, error)
}
type handshakeClient struct {
@ -33,9 +34,18 @@ func NewHandshakeClient(cc grpc.ClientConnInterface) HandshakeClient {
return &handshakeClient{cc}
}
func (c *handshakeClient) ClientDiscoveryHandler(ctx context.Context, in *ClientDiscoveryRequest, opts ...grpc.CallOption) (*ClientDiscoveryResponse, error) {
out := new(ClientDiscoveryResponse)
err := c.cc.Invoke(ctx, "/grpc.handshake/ClientDiscoveryHandler", in, out, opts...)
func (c *handshakeClient) ReactorClientDiscoveryHandler(ctx context.Context, in *ReactorClientRequest, opts ...grpc.CallOption) (*ReactorClientResponse, error) {
out := new(ReactorClientResponse)
err := c.cc.Invoke(ctx, "/grpc.handshake/ReactorClientDiscoveryHandler", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *handshakeClient) TUIClientDiscoveryHandler(ctx context.Context, in *TUIClientRequest, opts ...grpc.CallOption) (*TUIClientResponse, error) {
out := new(TUIClientResponse)
err := c.cc.Invoke(ctx, "/grpc.handshake/TUIClientDiscoveryHandler", in, out, opts...)
if err != nil {
return nil, err
}
@ -46,7 +56,8 @@ func (c *handshakeClient) ClientDiscoveryHandler(ctx context.Context, in *Client
// All implementations must embed UnimplementedHandshakeServer
// for forward compatibility
type HandshakeServer interface {
ClientDiscoveryHandler(context.Context, *ClientDiscoveryRequest) (*ClientDiscoveryResponse, error)
ReactorClientDiscoveryHandler(context.Context, *ReactorClientRequest) (*ReactorClientResponse, error)
TUIClientDiscoveryHandler(context.Context, *TUIClientRequest) (*TUIClientResponse, error)
mustEmbedUnimplementedHandshakeServer()
}
@ -54,8 +65,11 @@ type HandshakeServer interface {
type UnimplementedHandshakeServer struct {
}
func (UnimplementedHandshakeServer) ClientDiscoveryHandler(context.Context, *ClientDiscoveryRequest) (*ClientDiscoveryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ClientDiscoveryHandler not implemented")
func (UnimplementedHandshakeServer) ReactorClientDiscoveryHandler(context.Context, *ReactorClientRequest) (*ReactorClientResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ReactorClientDiscoveryHandler not implemented")
}
func (UnimplementedHandshakeServer) TUIClientDiscoveryHandler(context.Context, *TUIClientRequest) (*TUIClientResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method TUIClientDiscoveryHandler not implemented")
}
func (UnimplementedHandshakeServer) mustEmbedUnimplementedHandshakeServer() {}
@ -70,20 +84,38 @@ func RegisterHandshakeServer(s grpc.ServiceRegistrar, srv HandshakeServer) {
s.RegisterService(&Handshake_ServiceDesc, srv)
}
func _Handshake_ClientDiscoveryHandler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ClientDiscoveryRequest)
func _Handshake_ReactorClientDiscoveryHandler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ReactorClientRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandshakeServer).ReactorClientDiscoveryHandler(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.handshake/ReactorClientDiscoveryHandler",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandshakeServer).ReactorClientDiscoveryHandler(ctx, req.(*ReactorClientRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Handshake_TUIClientDiscoveryHandler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TUIClientRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HandshakeServer).ClientDiscoveryHandler(ctx, in)
return srv.(HandshakeServer).TUIClientDiscoveryHandler(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.handshake/ClientDiscoveryHandler",
FullMethod: "/grpc.handshake/TUIClientDiscoveryHandler",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HandshakeServer).ClientDiscoveryHandler(ctx, req.(*ClientDiscoveryRequest))
return srv.(HandshakeServer).TUIClientDiscoveryHandler(ctx, req.(*TUIClientRequest))
}
return interceptor(ctx, in, info, handler)
}
@ -96,8 +128,12 @@ var Handshake_ServiceDesc = grpc.ServiceDesc{
HandlerType: (*HandshakeServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ClientDiscoveryHandler",
Handler: _Handshake_ClientDiscoveryHandler_Handler,
MethodName: "ReactorClientDiscoveryHandler",
Handler: _Handshake_ReactorClientDiscoveryHandler_Handler,
},
{
MethodName: "TUIClientDiscoveryHandler",
Handler: _Handshake_TUIClientDiscoveryHandler_Handler,
},
},
Streams: []grpc.StreamDesc{},

@ -47,7 +47,6 @@ type hwinfo struct {
Ip string
Port int
Model string
Type string
Bus int
Id uint32
}
@ -91,7 +90,6 @@ func NewCoordinator(ip string,port int,ch chan error) *Coordinator {
c := &Coordinator{Err:ch,Devices:sen}
c.server = serv
c.hwinfo = &hwinfo{}
c.Type = "reactor" // explicit for client stuff
return c
}
@ -175,8 +173,8 @@ func (c *Coordinator) Connect() {
}
defer conn.Close()
client := pb.NewHandshakeClient(conn)
req := &pb.ClientDiscoveryRequest{Id:c.Id,Ip:c.hwinfo.Ip,Port:int32(c.hwinfo.Port),Model:c.Model,ClientType:c.Type}
resp, err := client.ClientDiscoveryHandler(context.Background(), req)
req := &pb.ReactorClientRequest{ClientId:c.Id,ClientIp:c.hwinfo.Ip,ClientPort:int32(c.hwinfo.Port),ClientModel:c.Model}
resp, err := client.ReactorClientDiscoveryHandler(context.Background(), req)
if err != nil {
c.Err <-err
}

@ -12,7 +12,9 @@ type Coordinator struct {
Type string // ["reactor","tui"]
IncomingClients <-chan *Client
*Managers
Sys *System
Err chan error
Pc chan int
}
type Managers struct {
@ -20,20 +22,22 @@ type Managers struct {
sync.Mutex
}
func NewCoordinator(t string,ch chan *Client, err chan error) *Coordinator {
func NewCoordinator(t string,ch chan *Client, sys *System,pc chan int, err chan error) *Coordinator {
d := make(map[uint32](chan<- *Client))
m := &Managers{Directory:d}
c := &Coordinator{Type: t,IncomingClients: ch,Err:err}
c.Managers = m
c.Sys = sys
c.Pc = pc
return c
}
func FindNewManager(c *Client,ch chan *Client, err chan error) {
func FindNewManager(c *Client,ch chan *Client, sys *System, pc chan int, err chan error) {
switch c.Type {
case "reactor":
NewReactorManager(c,ch,err)
NewReactorManager(c,ch,sys,err)
case "tui":
NewTUIManager(c,ch,err)
NewTUIManager(c,"192.1.168.136",ch,sys,pc,err)
default:
log.Fatal(fmt.Sprintf("ERROR %v NOT FOUND",c.Type))
}
@ -62,7 +66,7 @@ func (c *Coordinator) ClientHandler(cl *Client) {
} else {
// create channel and manager
ch := make(chan *Client)
FindNewManager(cl, ch,c.Err)
FindNewManager(cl, ch, c.Sys, c.Pc, c.Err)
c.Managers.Directory[cl.Id] = ch
// will block until manager is ready
ch <-cl

@ -3,7 +3,6 @@ package server
import (
"fmt"
"net"
"log"
"sync"
"context"
"FRMS/internal/pkg/system"
@ -19,6 +18,7 @@ type Listener struct { // exporting for easy use in the short term
Ip string
Port int
*Coordinators
Sys *System
Err chan error
pb.UnimplementedHandshakeServer
}
@ -29,6 +29,7 @@ type Coordinators struct {
}
type Client struct {
// can use general client and leave unset fields nil
Ip string
Port int
Id uint32
@ -36,9 +37,6 @@ type Client struct {
Type string
}
func NewClient(ip, model, t string, port int, id uint32) *Client {
return &Client{Ip:ip,Port:port,Id:id,Model:model,Type:t}
}
func GetIp(e string) (string, error) {
return system.GetIp(e)
@ -55,6 +53,7 @@ func NewListener(ifconfig string,ch chan error) (*Listener, error) {
c := &Coordinators{Channel:m}
l := &Listener{Ip:ip,Err:ch}
l.Coordinators = c
l.Sys = NewSystemStruct()
return l, nil
}
@ -80,31 +79,36 @@ func (l *Listener) Register() error {
return nil
}
func (l *Listener) ClientDiscoveryHandler(ctx context.Context, ping *pb.ClientDiscoveryRequest) (*pb.ClientDiscoveryResponse, error) {
func (l *Listener) ReactorClientDiscoveryHandler(ctx context.Context, ping *pb.ReactorClientRequest) (*pb.ReactorClientResponse, error) {
// incoming reactor ping need to spawn coord
c := NewClient(ping.GetIp(),ping.GetModel(),ping.GetClientType(),int(ping.GetPort()),ping.GetId())
c := &Client{Ip:ping.GetClientIp(),Model:ping.GetClientModel(),Type:"reactor",Port:int(ping.GetClientPort()),Id:ping.GetClientId()}
fmt.Printf("%v Client %v has connected from %v:%v\n",c.Type,c.Id,c.Ip,c.Port)
go l.ConnectClient(c)
ch := make(chan int)
go l.ConnectClient(c,ch)
// we dont handle any actual logic about the creation so we just respon true if the request was received
return &pb.ClientDiscoveryResponse{Success:true}, nil
return &pb.ReactorClientResponse{ClientId:c.Id,Success:true}, nil
}
func (l *Listener) TUIClientDiscoveryHandler(ctx context.Context, ping *pb.TUIClientRequest) (*pb.TUIClientResponse, error) {
t := &Client{Type:"tui",Id:ping.GetClientId()}
ch := make(chan int)
go l.ConnectClient(t,ch)
port := <-ch
r := &pb.TUIClientResponse{ClientId:t.Id,ServerIp:l.Ip,ServerPort:int32(port)}
return r, nil
}
func (l *Listener) ConnectClient(c *Client){
func (l *Listener) ConnectClient(c *Client, portchan chan int){
// send to reactor coordinator for ease
l.Coordinators.Lock()
defer l.Coordinators.Unlock()
switch c.Type {
case "reactor","tui":
if ch, exists := l.Coordinators.Channel[c.Type]; exists {
ch <-c
} else {
ch := make(chan *Client)
newC := NewCoordinator(c.Type, ch, l.Err)
go newC.Start()
l.Coordinators.Channel[c.Type] = ch
ch <-c
}
default:
log.Fatal("Error! client %v not supported!",c.Type)
if ch, exists := l.Coordinators.Channel[c.Type]; exists {
ch <-c
} else {
ch := make(chan *Client)
newC := NewCoordinator(c.Type, ch, l.Sys, portchan, l.Err)
go newC.Start()
l.Coordinators.Channel[c.Type] = ch
ch <-c
}
}

@ -1,14 +1,10 @@
package server
import (
"fmt"
"time"
"math"
"sync"
"errors"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
"google.golang.org/grpc/credentials/insecure"
)
// this package will implement a boilerplate manager
@ -111,37 +107,3 @@ func (m *Manager) Timeout() int {
return 0
}
}
func (m *Manager) Connect() *grpc.ClientConn{
// establish initial gRPC connection with client
var opts []grpc.DialOption
var conn *grpc.ClientConn
opts = append(opts,grpc.WithTransportCredentials(insecure.NewCredentials()))
for {
if !m.IsActive() {
fmt.Printf("Aborting connection attempt\n")
return &grpc.ClientConn{}
}
var err error
conn, err = grpc.Dial(fmt.Sprintf("%v:%v",m.Ip,m.Port),opts...)
// begin error handling
code := status.Code(err)
if code != 0 { // != OK
if code == (5 | 14) { // == unavailable or not found
to := m.Timeout()
if to == 0 {
fmt.Printf("Client not responding\n")
m.Exit()
return&grpc.ClientConn{}
}
fmt.Printf("gRPC endpoint currently unavailable, retrying in %v ms\n",to)
time.Sleep(time.Duration(to) * time.Millisecond)
} else {
fmt.Printf("ERR GRPC: %v\n",code)
m.Err <-err
}
}
break;
}
return conn
}

@ -3,10 +3,12 @@ package server
import (
"fmt"
"time"
"log"
"context"
"sync"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
"google.golang.org/grpc/credentials/insecure"
pb "FRMS/internal/pkg/grpc"
)
@ -15,6 +17,7 @@ import (
type ReactorManager struct {
*Manager
Devs *Devices
*System
}
type Devices struct {
@ -22,11 +25,12 @@ type Devices struct {
D map[int]Device
}
func NewReactorManager(c *Client,ch chan *Client,err chan error) {
func NewReactorManager(c *Client,ch chan *Client,sys *System,err chan error) {
d := new(Devices)
r := &ReactorManager{Devs:d}
start := make(chan bool)
r.Manager = NewManager(c, ch, start, err)
r.System = sys
go r.Listen(start)
}
@ -41,24 +45,63 @@ func (r *ReactorManager) Listen(ch chan bool) {
func (r *ReactorManager) Start() {
conn := r.Connect()
go r.Monitor(conn)
empty := &grpc.ClientConn{}
if conn != empty {
go r.Monitor(conn)
}
}
func (r *ReactorManager) Connect() *grpc.ClientConn {
// establish gRPC conection with reactor
var opts []grpc.DialOption
var conn *grpc.ClientConn
opts = append(opts,grpc.WithTransportCredentials(insecure.NewCredentials()))
for {
if !r.IsActive() {
log.Fatal("No longer active, aborting connection attempt\n")
return &grpc.ClientConn{}
}
var err error
conn, err = grpc.Dial(fmt.Sprintf("%v:%v",r.Ip,r.Port),opts...)
// error handling
code := status.Code(err)
if code != 0 { // != OK
if code == (5 | 14) { // unavailable or not found
to := r.Timeout()
if to == 0 {
log.Printf("Client not responding\n")
return &grpc.ClientConn{}
}
log.Printf("Client currently down, retrying in %v ms\n",to)
time.Sleep(time.Duration(to) * time.Millisecond)
} else {
log.Fatal("GRPC ERROR: %v",code)
r.Err <- err
}
}
break;
}
return conn
}
func (r *ReactorManager) Monitor(conn *grpc.ClientConn) {
defer conn.Close()
client := pb.NewMonitoringClient(conn)
r.UpdateReactor(r.Id,true)
for r.IsActive() {
req := &pb.ReactorStatusRequest{Id:r.Id}
resp, err := client.GetReactorStatus(context.Background(),req)
code := status.Code(err)
if code != 0 { // if != OK
go r.UpdateReactor(r.Id,false)
fmt.Printf("Reactor %v down! ", r.Id)
r.Exit()
}
for _,v := range resp.GetDevices() {
fmt.Printf("%v is %v, ",v.GetType(),v.GetStatus())
go r.System.UpdateReactorDevice(r.Id, int(v.GetAddr()), v.GetType(), v.GetStatus(), v.GetData())
}
fmt.Print("\n")
time.Sleep(r.Hb * time.Second) // time between sensor pings
}
}

@ -0,0 +1,91 @@
package server
import (
"sync"
)
// package will create and maintain a concurrent system structure
// allows for multiple readers/writers
type System struct {
sync.Mutex
Reactors map[uint32]*Reactor
}
type Reactor struct {
Status bool
Devices map[int]*Device
sync.Mutex
}
type Device struct {
Type string
Status string
Data string
}
type ReactorInfo struct {
Id uint32
Status bool
}
type DeviceInfo struct {
Addr int
Type string
Status string
Data string
}
func NewSystemStruct() *System {
s := &System{}
r := make(map[uint32]*Reactor)
s.Reactors = r
return s
}
func (s *System) UpdateReactor(id uint32, status bool) {
s.Lock()
defer s.Unlock()
if _, exists := s.Reactors[id]; exists {
s.Reactors[id].Status = status
} else {
m := make(map[int]*Device)
s.Reactors[id] = &Reactor{Status:status,Devices:m}
}
}
func (s *System) UpdateReactorDevice(id uint32, addr int, t, st, d string) {
dev := &Device{Type:t, Status:st, Data:d}
go s.Reactors[id].UpdateDevice(addr, dev)
}
func (r *Reactor) UpdateDevice(addr int, d *Device) {
r.Lock()
defer r.Unlock()
r.Devices[addr] = d
}
func (s *System) GetReactors() []*ReactorInfo {
s.Lock()
defer s.Unlock()
rinfo := []*ReactorInfo{}
for id, r := range s.Reactors {
rinfo = append(rinfo,&ReactorInfo{Id:id,Status:r.Status})
}
return rinfo
}
func (s *System) GetReactorDevices(id uint32) []*DeviceInfo {
return s.Reactors[id].GetDevices()
}
func (r *Reactor) GetDevices() []*DeviceInfo {
//
r.Lock()
defer r.Unlock()
di := []*DeviceInfo{}
for a,v := range r.Devices {
di = append(di, &DeviceInfo{Addr:a,Status:v.Status,Type:v.Type,Data:v.Data})
}
return di
}

@ -3,62 +3,36 @@ package server
import (
"fmt"
"time"
"sync"
_ "sync"
"net"
"log"
"context"
"google.golang.org/grpc"
pb "FRMS/internal/pkg/grpc"
)
// implement tui specific manager to be called for each client conn
type TUIManager struct {
*Manager // embedded manager for access to methods and client
Sys *KnownReactors
*System
Ip string
Port int
Err chan error
Hb time.Duration
Pc chan int
*pb.UnimplementedManagementServer
}
type KnownReactors struct {
Reactors map[uint32]*Reactor
sync.Mutex
}
type Reactor struct {
Devices map[string]*Device
}
type Device struct {
Status DeviceStatus
Type string
Addr int
}
type DeviceStatus uint32
const (
READY DeviceStatus = iota
ACTIVE
DISABLED
)
func (d DeviceStatus) String() string {
return [...]string{"Ready","Active","Disabled"}[d]
}
func (d Device) String() string {
return fmt.Sprintf("%v is %v at %x",d.Type,d.Status,d.Addr)
}
type DeviceManager interface{
// GetStatus() uint32 UNSUPPORTED: arguable memory benifit but until we support 100s of sensors across 10s of tui clients im not implementing it
PrintSatus() string
GetType() string
}
func NewTUIManager(c *Client,ch chan *Client, err chan error) {
k := new(KnownReactors)
func NewTUIManager(c *Client, ip string, ch chan *Client,sys *System, pc chan int, err chan error) {
sig := make(chan bool)
m := NewManager(c, ch, sig, err)
hb := time.Duration(5)
t := &TUIManager{Hb: hb,Sys: k,Err: err}
t := &TUIManager{Hb: hb,Err: err}
t.Manager = m
t.System = sys
t.Ip = ip
t.Pc = pc
go t.Listen(sig)
}
@ -73,6 +47,52 @@ func (t *TUIManager) Listen(sig chan bool) {
func (t *TUIManager) Start() {
//
//conn := t.Conn()
go t.Register() // begin tui server to respond to tui client reqs
//go t.Monitor(conn)
}
func (t *TUIManager) Register() {
lis, err := net.Listen("tcp", fmt.Sprintf("%v:0",t.Ip))
if err != nil {
log.Fatal(err)
}
t.Port = lis.Addr().(*net.TCPAddr).Port
grpcServer := grpc.NewServer()
pb.RegisterManagementServer(grpcServer,t)
go grpcServer.Serve(lis)
log.Printf("TUI %v Endpoint active on %v:%v\n",t.Id, t.Ip, t.Port)
t.Pc <-t.Port
}
func (t *TUIManager) GetReactors(ctx context.Context, req *pb.GetReactorsRequest) (*pb.GetReactorsResponse, error) {
//
reactors := []*pb.Reactor{}
resp := &pb.GetReactorsResponse{ClientId:t.Id,Reactors:reactors}
r := t.System.GetReactors()
for _,v := range r {
resp.Reactors = append(resp.Reactors, &pb.Reactor{Id:v.Id,Status:v.Status})
}
return resp, nil
}
func (t *TUIManager) GetReactorDevices(ctx context.Context, req *pb.GetReactorDevicesRequest) (*pb.GetReactorDevicesResponse, error) {
rid := req.GetReactorId()
devs := t.System.GetReactorDevices(rid)
devices := []*pb.Dev{}
resp := &pb.GetReactorDevicesResponse{ClientId:t.Id,ReactorId:rid,Devices:devices}
for _, v := range devs {
resp.Devices = append(resp.Devices, &pb.Dev{Addr:int32(v.Addr),Type:v.Type,Status:v.Status,Data:v.Data})
}
return resp, nil
}
func (t *TUIManager) DeleteReactors(ctx context.Context, req *pb.DeleteReactorRequest) (*pb.DeleteReactorResponse, error) {
//
return &pb.DeleteReactorResponse{}, nil
}
func (t *TUIManager) DeleteReactorDevice(ctx context.Context, req *pb.DeleteReactorDeviceRequest) (*pb.DeleteReactorDeviceResponse, error) {
//
return &pb.DeleteReactorDeviceResponse{}, nil
}

@ -0,0 +1,143 @@
package tui
import (
"sync"
"fmt"
"log"
"time"
"math"
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
"google.golang.org/grpc/credentials/insecure"
pb "FRMS/internal/pkg/grpc"
)
// this package will interact with the server to get system status
type TUIClient struct {
Ip string
Port int
client pb.ManagementClient
Active
}
type Active struct {
sync.Mutex
bool
int
}
func NewTUIClient(ip string, port int) *TUIClient {
t := &TUIClient{Ip:ip,Port:port}
return t
}
func (t *TUIClient) Start() error {
t.Connect()
return nil
}
func (t *TUIClient) Timeout() int {
t.Active.Lock()
defer t.Active.Unlock()
if t.Active.int < 9 {
v := int( 5 * math.Pow(float64(2), float64(t.Active.int)))
t.Active.int += 1
return v
} else {
return 0
}
}
func (t *TUIClient) Connect() {
// connect to server and register as client
var conn *grpc.ClientConn
var err error
var opts []grpc.DialOption
opts = append(opts,grpc.WithTransportCredentials(insecure.NewCredentials()))
for {
conn, err = grpc.Dial(fmt.Sprintf("%v:%v",t.Ip,t.Port),opts...)
code := status.Code(err)
if code != 0 {
if code == (5 | 14) {
to := t.Timeout()
if to == 0 {
log.Fatal("Failed to connect to central server")
}
fmt.Printf("Server currently down, reconnecting in %v ms\n",to)
time.Sleep(time.Duration(to) * time.Millisecond)
} else {
log.Fatal("Central server currently unavailable")
}
}
//t.client = pb.NewManagementClient(conn)
break;
}
// handle handshake logic here
client := pb.NewHandshakeClient(conn)
req := &pb.TUIClientRequest{ClientId:10120}
resp, err := client.TUIClientDiscoveryHandler(context.Background(),req)
if err != nil {
log.Fatal(err)
}
// setting up server connection with provided port
t.Ip = resp.GetServerIp()
t.Port = int(resp.GetServerPort())
for {
conn, err = grpc.Dial(fmt.Sprintf("%v:%v",t.Ip,t.Port),opts...)
code := status.Code(err)
if code != 0 {
if code == (5 | 14) {
to := t.Timeout()
if to == 0 {
log.Fatal("Failed to connect to central server")
}
fmt.Printf("Server currently down, reconnecting in %v ms\n",to)
time.Sleep(time.Duration(to) * time.Millisecond)
} else {
log.Fatal("Central server currently unavailable")
}
}
t.client = pb.NewManagementClient(conn)
break;
}
}
func (t *TUIClient) GetReactors() (map[uint32]*Reactor, error) {
req := &pb.GetReactorsRequest{}
r := make(map[uint32]*Reactor)
resp, err := t.client.GetReactors(context.Background(), req)
if err != nil {
return r, err
}
for _, v := range resp.GetReactors() {
m := make(map[int]*Device)
r[v.GetId()] = &Reactor{Status:v.GetStatus(),Devices:m}
}
return r, nil
}
func (t *TUIClient) GetReactorDevices(id uint32) (map[int]*Device, error) {
req := &pb.GetReactorDevicesRequest{}
r := make(map[int]*Device)
resp, err := t.client.GetReactorDevices(context.Background(), req)
if err != nil {
return r, nil
}
for _, v := range resp.GetDevices() {
r[int(v.GetAddr())] = &Device{Type:v.GetType(),Status:v.GetStatus()}
}
return r, err
}
func (t *TUIClient) DeleteReactor(id uint32) error {
req := &pb.DeleteReactorRequest{}
_, err := t.client.DeleteReactor(context.Background(), req)
return err
}
func (t *TUIClient) DeleteReactorDevice(id uint32, addr int) error {
req := &pb.DeleteReactorDeviceRequest{}
_, err := t.client.DeleteReactorDevice(context.Background(), req)
return err
}

@ -0,0 +1,56 @@
package tui
import (
_ "fmt"
"sync"
)
type LocalView struct {
sync.Mutex
Reactors map[uint32]*Reactor
*TUIClient // embedding for easy grpc calls
}
type Reactor struct {
Status bool
Devices map[int]*Device
}
type Device struct {
Type string
Status string
Data string
}
func (l *LocalView) UpdateReactors(id uint32, r *Reactor) {
l.Lock()
defer l.Unlock()
l.Reactors[id] = r
}
func (l *LocalView) UpdateReactorDevices(id uint32, addr int, d *Device) {
l.Lock()
defer l.Unlock()
if _, exists := l.Reactors[id]; !exists {
m := make(map[int]*Device)
l.Reactors[id] = &Reactor{Devices:m}
l.Reactors[id].Devices[addr] = d
}
l.Reactors[id].Devices[addr] = d
}
func (l *LocalView) GetReactors() map[uint32]bool {
l.Lock()
defer l.Unlock()
r := make(map[uint32]bool)
for a,s := range l.Reactors {
r[a] = s.Status
}
return r
}
func (l *LocalView) GetReactorDevices(id uint32) map[int]*Device {
l.Lock()
defer l.Unlock()
return l.Reactors[id].Devices
}

@ -1,145 +1,171 @@
package tui
import (
"sync"
"fmt"
"log"
"strconv"
"time"
"github.com/rivo/tview"
tcell "github.com/gdamore/tcell/v2"
_ "github.com/gdamore/tcell/v2"
)
// gonna start from scratch :/
type TUI struct {
*Display
*LocalView
*TUIClient
SelectedReactor <-chan uint32
Err chan error
}
type System struct {
// struct to hold actual system state
Display
Connected map[uint32]*Reactor
err chan error
type Display struct {
app *tview.Application
flex *tview.Flex
reactorlist *tview.List
sensortable *tview.Table
mu sync.Mutex
func NewTUI(ip string, port int, ch chan error) *TUI {
r := make(map[uint32]*Reactor)
t := &TUI{}
l := new(LocalView)
l.Reactors = r
t.LocalView = l
c := make(chan uint32)
t.Display = NewDisplay(c)
t.SelectedReactor = c
t.Err = ch
client := NewTUIClient(ip, port)
t.TUIClient = client
return t
}
type Reactor struct {
Index int // index into list
Id uint32
Ip string
Port int
Model string
Status bool
Sensors map[int]*Sensor
func (t *TUI) Start() {
// setup tview app and wait for user connection in standin modal
t.Display.Start()
t.Connect()
go t.Monitor()
go t.Listen()
//go t.Refresh()
}
func (r Reactor) String() string {
s := ""
if r.Status {
s = "[green]ONLINE"
} else {
s = "[red]OFFLINE"
func (t *TUI) Refresh() {
for {
//
}
}
func (t *TUI) Listen() {
for {
select {
case <-t.SelectedReactor:
//blah
}
}
return fmt.Sprintf("Reactor %v (%v) is %v on %v:%v",r.Id,r.Model,s,r.Ip,r.Port)
}
type Sensor struct {
Id uint32
Addr int
Type string
Status string
func (t *TUI) Monitor() {
// orchestrates updates and grpc requests
timer := make(chan struct{})
go func(signal chan struct{}){
for {
signal <- struct{}{}
time.Sleep(1 * time.Second)
}
}(timer)
for {
select {
case reactor := <-t.SelectedReactor:
// reactor has been selected in tui, grabbing devs
go t.UpdateDevices(reactor)
//devs := t.GetReactorDevices(reactor)
//t.DisplayReactorDevices(devs)
case <-timer:
// time to ping for status
go t.UpdateReactors()
}
}
}
func NewDisplay(ch chan error) *Display {
m := make(map[uint32]*Reactor)
a := tview.NewApplication()
f := tview.NewFlex()
f.AddItem(tview.NewBox().SetTitle("Connected Reactors").SetBorder(true),0,1, true)
f.AddItem(tview.NewBox().SetTitle("Sensor Info").SetBorder(true),0,2, false)
if err := a.SetRoot(f,true).SetFocus(f).Run(); err != nil {
panic(err)
func (t *TUI) UpdateDevices(r uint32) {
// get devices for the reactor and update the tui
devs, err := t.TUIClient.GetReactorDevices(r)
if err != nil {
log.Fatal(err)
}
a.Stop()
return &Display{app:a,Connected:m,err:ch}
for a, d := range devs {
go t.LocalView.UpdateReactorDevices(r,a,d)
}
t.DisplayReactorDevices(devs)
}
func NewReactor(ip,model string, status bool, id uint32, port int) *Reactor {
s := map[int]*Sensor{}
return &Reactor{Ip:ip,Model:model,Status:status,Id:id,Port:port,Sensors:s}
func (t *TUI) UpdateReactors() {
// get all reactors and update the tui
reactors, err := t.TUIClient.GetReactors()
if err != nil {
log.Fatal(err)
}
for id, r := range reactors {
go t.LocalView.UpdateReactors(id, r)
}
t.DisplayReactors(reactors)
}
func NewSensor(addr int, t, status string) *Sensor {
return &Sensor{Addr:addr,Type:t,Status:status}
// display struct and logic
type Display struct {
App *tview.Application
Flex *tview.Flex
ReactorList *tview.List
DeviceList *tview.List
SelectedReactor chan<- uint32
}
func (d *Display) Start () {
go d.Refresh()
func NewDisplay(ch chan uint32) *Display {
d := &Display{}
d.App = tview.NewApplication()
d.Flex = tview.NewFlex()
d.ReactorList = tview.NewList().ShowSecondaryText(false)
d.DeviceList = tview.NewList().ShowSecondaryText(false)
d.SelectedReactor = ch
d.ReactorList.SetSelectedFunc(d.SelectReactor)
return d
}
func (d *Display) UpdateReactor(r *Reactor) {
d.mu.Lock()
defer d.mu.Unlock()
if _, ok := d.Connected[r.Id]; ok {
// reactor exists in memory
d.Connected[r.Id] = r
d.reactorlist.SetItemText(r.Index,fmt.Sprint(r),"")
} else {
r.Index = d.reactorlist.GetItemCount() // get before adding
d.reactorlist.AddItem(fmt.Sprint(r),"",rune(r.Index), func () {d.SelectSensor(r.Id)})
func (d *Display) Start() {
d.Flex.AddItem(d.ReactorList.SetBorder(true).SetTitle("Reactors"),0,1,true)
d.Flex.AddItem(d.DeviceList.SetBorder(true).SetTitle("Devices"),0,3,false)
if err := d.App.SetRoot(d.Flex, true).Run(); err != nil {
log.Fatal(err)
}
d.app.Run()
d.app.Stop()
}
func (d *Display) UpdateSensor(s *Sensor) {
d.mu.Lock()
defer d.mu.Unlock()
if r,ok := d.Connected[s.Id]; ok {
r.Sensors[s.Addr] = s
func (d *Display) DisplayReactors(r map[uint32]*Reactor) {
// function to display reactor list to table
for id, reactor := range r {
var status string
if reactor.Status {
status = "[green]ONLINE"
} else {
status = "[red]OFFLINE"
}
txt := fmt.Sprintf("Reactor %v is %v", id, status)
d.ReactorList.AddItem(txt,string(id),0,nil)
}
}
func (d *Display) SelectSensor(id uint32) {
d.mu.Lock()
defer d.mu.Unlock()
if reactor, ok := d.Connected[id]; ok {
d.sensortable.Clear()
row := 0
ch := []string{"Type","Addr","Status"}
for i,v := range ch {
// create column headings
c := tview.NewTableCell(v).SetTextColor(tcell.ColorGray)
d.sensortable.SetCell(row,i,c)
}
row += 1
for a,s := range reactor.Sensors {
addr := tview.NewTableCell(string(a))
typ := tview.NewTableCell(s.Type)
st := ""
col := tcell.ColorWhite
if s.Status == "ACTIVE" {
col = tcell.ColorGreen
} else if s.Status == "KILLED" {
col = tcell.ColorRed
} else {
st = "UNKNOWN"
col = tcell.ColorYellow
}
status := tview.NewTableCell(st).SetTextColor(col)
d.sensortable.SetCell(row,0,typ)
d.sensortable.SetCell(row,1,addr)
d.sensortable.SetCell(row,2,status)
row += 1
}
func (d *Display) SelectReactor(index int, main, id string, r rune) {
// called when reactor in list in selected
if id, err := strconv.Atoi(id); err != nil {
log.Fatal(err)
} else {
d.SelectedReactor <-uint32(id)
}
}
func (d *Display) Refresh() {
tick := time.NewTicker(500 * time.Millisecond)
for {
select {
case <-tick.C:
d.app.Draw()
func (d *Display) DisplayReactorDevices(devs map[int]*Device) {
//Function that displays devices to the table
d.DeviceList.Clear()
for addr, dev := range devs {
var status string
if dev.Status == "ACTIVE" {
status = "[green]ACTIVE[white]"
} else if dev.Status == "KILLED" {
status = "[red]KILLED[white]"
}
txt := fmt.Sprintf("%v is %v at %x",dev.Type,status,addr)
d.DeviceList.AddItem(txt,"",0,nil)
}
}

65
notes

@ -610,3 +610,68 @@ dm struct
- implements
- status response
alright holy shit
i have rewritten the same five functions so many times
time to take inventory
right now the system has
a central coordinator
that can spawn managers
that can manage clients
and a reactor coordinator
that can spawn device managers
that can manage devices
I have a rudimentary ping system that queries the reactors for their status
where to go next
I want to build in control before I worry about actual data
this means tui and removal of managers
how to start?
need to create a central struct that serves as a representation of the system
map[reactorid] -> [dev addr] device info
reactor is online by nature of responding to a ping
device info is what we query for
tui manager will request data from the server struct
server struct should bridge between reactor coordiantor and terminal coordinator
needs to be concurrent
needs to synchronize incoming sensor data
instead of a big stupid struct
- just have rm maintain struct for each reactor
- connect tui requests to rm
pros
- prevent redundancies in data
- limit operations after the ping
- serve copies?
what will this look like
TODO 7/5
time to flesh out the tui and move into actual sensor/db libraries
tuitime:
tui client (user side)
*will most likely be divided
needs to know:
- ip address of host
- eventually
- username/pass auth
needs to be able to
- request system info via server
- establish connection to central server
implements
- basic system management functionality
relies on
- server for up to date reactor and sensor data

Loading…
Cancel
Save