From 42ede404c3d96db7ccc6d542edc2812d28f46892 Mon Sep 17 00:00:00 2001 From: Nikita Zhamoidzik Date: Mon, 19 Feb 2024 11:33:00 +0300 Subject: [PATCH 1/6] Create events service --- api.swagger.json | 49 ++- eventbus/eventbus.pb.go | 366 ++++++++++++++++++ eventbus/eventbus.pb.validate.go | 310 +++++++++++++++ eventbus/eventbus.proto | 36 ++ eventbus/eventbus_grpc.pb.go | 137 +++++++ eventbus/eventbusconnect/eventbus.connect.go | 113 ++++++ .../handsfreeconnect/handsfree.connect.go | 21 +- node/nodeconnect/node.connect.go | 327 +++++++++++----- plugins/pluginsconnect/plugins.connect.go | 42 +- shadow/shadowconnect/shadow.connect.go | 35 +- .../timeseriesconnect/timeseries.connect.go | 42 +- 11 files changed, 1345 insertions(+), 133 deletions(-) create mode 100644 eventbus/eventbus.pb.go create mode 100644 eventbus/eventbus.pb.validate.go create mode 100644 eventbus/eventbus.proto create mode 100644 eventbus/eventbus_grpc.pb.go create mode 100644 eventbus/eventbusconnect/eventbus.connect.go diff --git a/api.swagger.json b/api.swagger.json index 98b72f5..502cce1 100644 --- a/api.swagger.json +++ b/api.swagger.json @@ -1,13 +1,10 @@ { "swagger": "2.0", "info": { - "title": "handsfree/handsfree.proto", + "title": "node/access/access.proto", "version": "version not set" }, "tags": [ - { - "name": "HandsfreeService" - }, { "name": "ShadowService" }, @@ -24,10 +21,13 @@ "name": "DevicesService" }, { - "name": "ShadowService" + "name": "InternalService" }, { - "name": "InternalService" + "name": "EventsService" + }, + { + "name": "HandsfreeService" }, { "name": "PluginsService" @@ -3163,6 +3163,43 @@ } } }, + "eventbusEvent": { + "type": "object", + "properties": { + "eventType": { + "$ref": "#/definitions/eventbusEventType" + }, + "account": { + "$ref": "#/definitions/accountsAccount" + }, + "namespace": { + "$ref": "#/definitions/namespacesNamespace" + }, + "device": { + "$ref": "#/definitions/devicesDevice" + }, + "meta": { + "type": "object", + "additionalProperties": {} + } + } + }, + "eventbusEventType": { + "type": "string", + "enum": [ + "NONE", + "ACCOUNT_CREATE", + "ACCOUNT_UPDATE", + "ACCOUNT_DELETE", + "NAMESPACE_CREATE", + "NAMESPACE_UPDATE", + "NAMESPACE_DELETE", + "DEVICE_CREATE", + "DEVICE_UPDATE", + "DEVICE_DELETE" + ], + "default": "NONE" + }, "handsfreeCode": { "type": "string", "enum": [ diff --git a/eventbus/eventbus.pb.go b/eventbus/eventbus.pb.go new file mode 100644 index 0000000..da7d7c9 --- /dev/null +++ b/eventbus/eventbus.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc (unknown) +// source: eventbus/eventbus.proto + +package eventbus + +import ( + node "github.com/infinimesh/proto/node" + accounts "github.com/infinimesh/proto/node/accounts" + devices "github.com/infinimesh/proto/node/devices" + namespaces "github.com/infinimesh/proto/node/namespaces" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + 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 EventType int32 + +const ( + EventType_NONE EventType = 0 + EventType_ACCOUNT_CREATE EventType = 1 + EventType_ACCOUNT_UPDATE EventType = 2 + EventType_ACCOUNT_DELETE EventType = 3 + EventType_NAMESPACE_CREATE EventType = 4 + EventType_NAMESPACE_UPDATE EventType = 5 + EventType_NAMESPACE_DELETE EventType = 6 + EventType_DEVICE_CREATE EventType = 7 + EventType_DEVICE_UPDATE EventType = 8 + EventType_DEVICE_DELETE EventType = 9 +) + +// Enum value maps for EventType. +var ( + EventType_name = map[int32]string{ + 0: "NONE", + 1: "ACCOUNT_CREATE", + 2: "ACCOUNT_UPDATE", + 3: "ACCOUNT_DELETE", + 4: "NAMESPACE_CREATE", + 5: "NAMESPACE_UPDATE", + 6: "NAMESPACE_DELETE", + 7: "DEVICE_CREATE", + 8: "DEVICE_UPDATE", + 9: "DEVICE_DELETE", + } + EventType_value = map[string]int32{ + "NONE": 0, + "ACCOUNT_CREATE": 1, + "ACCOUNT_UPDATE": 2, + "ACCOUNT_DELETE": 3, + "NAMESPACE_CREATE": 4, + "NAMESPACE_UPDATE": 5, + "NAMESPACE_DELETE": 6, + "DEVICE_CREATE": 7, + "DEVICE_UPDATE": 8, + "DEVICE_DELETE": 9, + } +) + +func (x EventType) Enum() *EventType { + p := new(EventType) + *p = x + return p +} + +func (x EventType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (EventType) Descriptor() protoreflect.EnumDescriptor { + return file_eventbus_eventbus_proto_enumTypes[0].Descriptor() +} + +func (EventType) Type() protoreflect.EnumType { + return &file_eventbus_eventbus_proto_enumTypes[0] +} + +func (x EventType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use EventType.Descriptor instead. +func (EventType) EnumDescriptor() ([]byte, []int) { + return file_eventbus_eventbus_proto_rawDescGZIP(), []int{0} +} + +type Event struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EventType EventType `protobuf:"varint,1,opt,name=event_type,json=eventType,proto3,enum=infinimesh.eventbus.EventType" json:"event_type,omitempty"` + // Types that are assignable to Entity: + // + // *Event_Account + // *Event_Namespace + // *Event_Device + Entity isEvent_Entity `protobuf_oneof:"entity"` + Meta map[string]*structpb.Value `protobuf:"bytes,5,rep,name=meta,proto3" json:"meta,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Event) Reset() { + *x = Event{} + if protoimpl.UnsafeEnabled { + mi := &file_eventbus_eventbus_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_eventbus_eventbus_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 Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_eventbus_eventbus_proto_rawDescGZIP(), []int{0} +} + +func (x *Event) GetEventType() EventType { + if x != nil { + return x.EventType + } + return EventType_NONE +} + +func (m *Event) GetEntity() isEvent_Entity { + if m != nil { + return m.Entity + } + return nil +} + +func (x *Event) GetAccount() *accounts.Account { + if x, ok := x.GetEntity().(*Event_Account); ok { + return x.Account + } + return nil +} + +func (x *Event) GetNamespace() *namespaces.Namespace { + if x, ok := x.GetEntity().(*Event_Namespace); ok { + return x.Namespace + } + return nil +} + +func (x *Event) GetDevice() *devices.Device { + if x, ok := x.GetEntity().(*Event_Device); ok { + return x.Device + } + return nil +} + +func (x *Event) GetMeta() map[string]*structpb.Value { + if x != nil { + return x.Meta + } + return nil +} + +type isEvent_Entity interface { + isEvent_Entity() +} + +type Event_Account struct { + Account *accounts.Account `protobuf:"bytes,2,opt,name=account,proto3,oneof"` +} + +type Event_Namespace struct { + Namespace *namespaces.Namespace `protobuf:"bytes,3,opt,name=namespace,proto3,oneof"` +} + +type Event_Device struct { + Device *devices.Device `protobuf:"bytes,4,opt,name=device,proto3,oneof"` +} + +func (*Event_Account) isEvent_Entity() {} + +func (*Event_Namespace) isEvent_Entity() {} + +func (*Event_Device) isEvent_Entity() {} + +var File_eventbus_eventbus_proto protoreflect.FileDescriptor + +var file_eventbus_eventbus_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x62, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x69, 0x6e, 0x66, 0x69, 0x6e, + 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x1a, 0x1c, + 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x6e, 0x6f, + 0x64, 0x65, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, + 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x64, 0x65, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, + 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x03, 0x0a, 0x05, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, + 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x45, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, + 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, + 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, + 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, + 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x1a, 0x4f, 0x0a, + 0x09, 0x4d, 0x65, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, + 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, + 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, + 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, + 0x55, 0x4e, 0x54, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, + 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, + 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, + 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, + 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, 0x12, 0x11, + 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, + 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, + 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x44, + 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x59, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, + 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, + 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, + 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x42, 0x0d, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x69, + 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, 0x49, 0x6e, + 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, + 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, + 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, 0x66, 0x69, + 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_eventbus_eventbus_proto_rawDescOnce sync.Once + file_eventbus_eventbus_proto_rawDescData = file_eventbus_eventbus_proto_rawDesc +) + +func file_eventbus_eventbus_proto_rawDescGZIP() []byte { + file_eventbus_eventbus_proto_rawDescOnce.Do(func() { + file_eventbus_eventbus_proto_rawDescData = protoimpl.X.CompressGZIP(file_eventbus_eventbus_proto_rawDescData) + }) + return file_eventbus_eventbus_proto_rawDescData +} + +var file_eventbus_eventbus_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_eventbus_eventbus_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_eventbus_eventbus_proto_goTypes = []interface{}{ + (EventType)(0), // 0: infinimesh.eventbus.EventType + (*Event)(nil), // 1: infinimesh.eventbus.Event + nil, // 2: infinimesh.eventbus.Event.MetaEntry + (*accounts.Account)(nil), // 3: infinimesh.node.accounts.Account + (*namespaces.Namespace)(nil), // 4: infinimesh.node.namespaces.Namespace + (*devices.Device)(nil), // 5: infinimesh.node.devices.Device + (*structpb.Value)(nil), // 6: google.protobuf.Value + (*node.EmptyMessage)(nil), // 7: infinimesh.node.EmptyMessage +} +var file_eventbus_eventbus_proto_depIdxs = []int32{ + 0, // 0: infinimesh.eventbus.Event.event_type:type_name -> infinimesh.eventbus.EventType + 3, // 1: infinimesh.eventbus.Event.account:type_name -> infinimesh.node.accounts.Account + 4, // 2: infinimesh.eventbus.Event.namespace:type_name -> infinimesh.node.namespaces.Namespace + 5, // 3: infinimesh.eventbus.Event.device:type_name -> infinimesh.node.devices.Device + 2, // 4: infinimesh.eventbus.Event.meta:type_name -> infinimesh.eventbus.Event.MetaEntry + 6, // 5: infinimesh.eventbus.Event.MetaEntry.value:type_name -> google.protobuf.Value + 7, // 6: infinimesh.eventbus.EventsService.Subscribe:input_type -> infinimesh.node.EmptyMessage + 1, // 7: infinimesh.eventbus.EventsService.Subscribe:output_type -> infinimesh.eventbus.Event + 7, // [7:8] is the sub-list for method output_type + 6, // [6:7] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_eventbus_eventbus_proto_init() } +func file_eventbus_eventbus_proto_init() { + if File_eventbus_eventbus_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_eventbus_eventbus_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Event); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_eventbus_eventbus_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Event_Account)(nil), + (*Event_Namespace)(nil), + (*Event_Device)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_eventbus_eventbus_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_eventbus_eventbus_proto_goTypes, + DependencyIndexes: file_eventbus_eventbus_proto_depIdxs, + EnumInfos: file_eventbus_eventbus_proto_enumTypes, + MessageInfos: file_eventbus_eventbus_proto_msgTypes, + }.Build() + File_eventbus_eventbus_proto = out.File + file_eventbus_eventbus_proto_rawDesc = nil + file_eventbus_eventbus_proto_goTypes = nil + file_eventbus_eventbus_proto_depIdxs = nil +} diff --git a/eventbus/eventbus.pb.validate.go b/eventbus/eventbus.pb.validate.go new file mode 100644 index 0000000..f792a33 --- /dev/null +++ b/eventbus/eventbus.pb.validate.go @@ -0,0 +1,310 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: eventbus/eventbus.proto + +package eventbus + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Event with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Event) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Event with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in EventMultiError, or nil if none found. +func (m *Event) ValidateAll() error { + return m.validate(true) +} + +func (m *Event) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for EventType + + { + sorted_keys := make([]string, len(m.GetMeta())) + i := 0 + for key := range m.GetMeta() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetMeta()[key] + _ = val + + // no validation rules for Meta[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, EventValidationError{ + field: fmt.Sprintf("Meta[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, EventValidationError{ + field: fmt.Sprintf("Meta[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return EventValidationError{ + field: fmt.Sprintf("Meta[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + switch v := m.Entity.(type) { + case *Event_Account: + if v == nil { + err := EventValidationError{ + field: "Entity", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetAccount()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, EventValidationError{ + field: "Account", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, EventValidationError{ + field: "Account", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAccount()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return EventValidationError{ + field: "Account", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Event_Namespace: + if v == nil { + err := EventValidationError{ + field: "Entity", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, EventValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, EventValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return EventValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Event_Device: + if v == nil { + err := EventValidationError{ + field: "Entity", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetDevice()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, EventValidationError{ + field: "Device", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, EventValidationError{ + field: "Device", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDevice()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return EventValidationError{ + field: "Device", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return EventMultiError(errors) + } + + return nil +} + +// EventMultiError is an error wrapping multiple validation errors returned by +// Event.ValidateAll() if the designated constraints aren't met. +type EventMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m EventMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m EventMultiError) AllErrors() []error { return m } + +// EventValidationError is the validation error returned by Event.Validate if +// the designated constraints aren't met. +type EventValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e EventValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e EventValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e EventValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e EventValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e EventValidationError) ErrorName() string { return "EventValidationError" } + +// Error satisfies the builtin error interface +func (e EventValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sEvent.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = EventValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = EventValidationError{} diff --git a/eventbus/eventbus.proto b/eventbus/eventbus.proto new file mode 100644 index 0000000..fd8e592 --- /dev/null +++ b/eventbus/eventbus.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package infinimesh.eventbus; + +import "node/accounts/accounts.proto"; +import "node/namespaces/namespaces.proto"; +import "node/devices/devices.proto"; +import "node/node.proto"; +import "google/protobuf/struct.proto"; + +enum EventType{ + NONE = 0; + ACCOUNT_CREATE = 1; + ACCOUNT_UPDATE = 2; + ACCOUNT_DELETE = 3; + NAMESPACE_CREATE = 4; + NAMESPACE_UPDATE = 5; + NAMESPACE_DELETE = 6; + DEVICE_CREATE = 7; + DEVICE_UPDATE = 8; + DEVICE_DELETE = 9; +} + +message Event { + EventType event_type = 1; + oneof entity { + node.accounts.Account account = 2; + node.namespaces.Namespace namespace = 3; + node.devices.Device device = 4; + } + map meta = 5; +} + +service EventsService{ + rpc Subscribe (node.EmptyMessage) returns (stream Event); +} \ No newline at end of file diff --git a/eventbus/eventbus_grpc.pb.go b/eventbus/eventbus_grpc.pb.go new file mode 100644 index 0000000..d06d71a --- /dev/null +++ b/eventbus/eventbus_grpc.pb.go @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: eventbus/eventbus.proto + +package eventbus + +import ( + context "context" + node "github.com/infinimesh/proto/node" + 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 + +const ( + EventsService_Subscribe_FullMethodName = "/infinimesh.eventbus.EventsService/Subscribe" +) + +// EventsServiceClient is the client API for EventsService 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 EventsServiceClient interface { + Subscribe(ctx context.Context, in *node.EmptyMessage, opts ...grpc.CallOption) (EventsService_SubscribeClient, error) +} + +type eventsServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewEventsServiceClient(cc grpc.ClientConnInterface) EventsServiceClient { + return &eventsServiceClient{cc} +} + +func (c *eventsServiceClient) Subscribe(ctx context.Context, in *node.EmptyMessage, opts ...grpc.CallOption) (EventsService_SubscribeClient, error) { + stream, err := c.cc.NewStream(ctx, &EventsService_ServiceDesc.Streams[0], EventsService_Subscribe_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &eventsServiceSubscribeClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type EventsService_SubscribeClient interface { + Recv() (*Event, error) + grpc.ClientStream +} + +type eventsServiceSubscribeClient struct { + grpc.ClientStream +} + +func (x *eventsServiceSubscribeClient) Recv() (*Event, error) { + m := new(Event) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// EventsServiceServer is the server API for EventsService service. +// All implementations must embed UnimplementedEventsServiceServer +// for forward compatibility +type EventsServiceServer interface { + Subscribe(*node.EmptyMessage, EventsService_SubscribeServer) error + mustEmbedUnimplementedEventsServiceServer() +} + +// UnimplementedEventsServiceServer must be embedded to have forward compatible implementations. +type UnimplementedEventsServiceServer struct { +} + +func (UnimplementedEventsServiceServer) Subscribe(*node.EmptyMessage, EventsService_SubscribeServer) error { + return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") +} +func (UnimplementedEventsServiceServer) mustEmbedUnimplementedEventsServiceServer() {} + +// UnsafeEventsServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EventsServiceServer will +// result in compilation errors. +type UnsafeEventsServiceServer interface { + mustEmbedUnimplementedEventsServiceServer() +} + +func RegisterEventsServiceServer(s grpc.ServiceRegistrar, srv EventsServiceServer) { + s.RegisterService(&EventsService_ServiceDesc, srv) +} + +func _EventsService_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(node.EmptyMessage) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(EventsServiceServer).Subscribe(m, &eventsServiceSubscribeServer{stream}) +} + +type EventsService_SubscribeServer interface { + Send(*Event) error + grpc.ServerStream +} + +type eventsServiceSubscribeServer struct { + grpc.ServerStream +} + +func (x *eventsServiceSubscribeServer) Send(m *Event) error { + return x.ServerStream.SendMsg(m) +} + +// EventsService_ServiceDesc is the grpc.ServiceDesc for EventsService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var EventsService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "infinimesh.eventbus.EventsService", + HandlerType: (*EventsServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Subscribe", + Handler: _EventsService_Subscribe_Handler, + ServerStreams: true, + }, + }, + Metadata: "eventbus/eventbus.proto", +} diff --git a/eventbus/eventbusconnect/eventbus.connect.go b/eventbus/eventbusconnect/eventbus.connect.go new file mode 100644 index 0000000..9668e34 --- /dev/null +++ b/eventbus/eventbusconnect/eventbus.connect.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: eventbus/eventbus.proto + +package eventbusconnect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + eventbus "github.com/infinimesh/proto/eventbus" + node "github.com/infinimesh/proto/node" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // EventsServiceName is the fully-qualified name of the EventsService service. + EventsServiceName = "infinimesh.eventbus.EventsService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // EventsServiceSubscribeProcedure is the fully-qualified name of the EventsService's Subscribe RPC. + EventsServiceSubscribeProcedure = "/infinimesh.eventbus.EventsService/Subscribe" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + eventsServiceServiceDescriptor = eventbus.File_eventbus_eventbus_proto.Services().ByName("EventsService") + eventsServiceSubscribeMethodDescriptor = eventsServiceServiceDescriptor.Methods().ByName("Subscribe") +) + +// EventsServiceClient is a client for the infinimesh.eventbus.EventsService service. +type EventsServiceClient interface { + Subscribe(context.Context, *connect.Request[node.EmptyMessage]) (*connect.ServerStreamForClient[eventbus.Event], error) +} + +// NewEventsServiceClient constructs a client for the infinimesh.eventbus.EventsService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewEventsServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) EventsServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &eventsServiceClient{ + subscribe: connect.NewClient[node.EmptyMessage, eventbus.Event]( + httpClient, + baseURL+EventsServiceSubscribeProcedure, + connect.WithSchema(eventsServiceSubscribeMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// eventsServiceClient implements EventsServiceClient. +type eventsServiceClient struct { + subscribe *connect.Client[node.EmptyMessage, eventbus.Event] +} + +// Subscribe calls infinimesh.eventbus.EventsService.Subscribe. +func (c *eventsServiceClient) Subscribe(ctx context.Context, req *connect.Request[node.EmptyMessage]) (*connect.ServerStreamForClient[eventbus.Event], error) { + return c.subscribe.CallServerStream(ctx, req) +} + +// EventsServiceHandler is an implementation of the infinimesh.eventbus.EventsService service. +type EventsServiceHandler interface { + Subscribe(context.Context, *connect.Request[node.EmptyMessage], *connect.ServerStream[eventbus.Event]) error +} + +// NewEventsServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewEventsServiceHandler(svc EventsServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + eventsServiceSubscribeHandler := connect.NewServerStreamHandler( + EventsServiceSubscribeProcedure, + svc.Subscribe, + connect.WithSchema(eventsServiceSubscribeMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/infinimesh.eventbus.EventsService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case EventsServiceSubscribeProcedure: + eventsServiceSubscribeHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedEventsServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedEventsServiceHandler struct{} + +func (UnimplementedEventsServiceHandler) Subscribe(context.Context, *connect.Request[node.EmptyMessage], *connect.ServerStream[eventbus.Event]) error { + return connect.NewError(connect.CodeUnimplemented, errors.New("infinimesh.eventbus.EventsService.Subscribe is not implemented")) +} diff --git a/handsfree/handsfreeconnect/handsfree.connect.go b/handsfree/handsfreeconnect/handsfree.connect.go index 13662e5..866700d 100644 --- a/handsfree/handsfreeconnect/handsfree.connect.go +++ b/handsfree/handsfreeconnect/handsfree.connect.go @@ -33,7 +33,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // HandsfreeServiceName is the fully-qualified name of the HandsfreeService service. @@ -55,6 +55,13 @@ const ( HandsfreeServiceConnectProcedure = "/infinimesh.handsfree.HandsfreeService/Connect" ) +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + handsfreeServiceServiceDescriptor = handsfree.File_handsfree_handsfree_proto.Services().ByName("HandsfreeService") + handsfreeServiceSendMethodDescriptor = handsfreeServiceServiceDescriptor.Methods().ByName("Send") + handsfreeServiceConnectMethodDescriptor = handsfreeServiceServiceDescriptor.Methods().ByName("Connect") +) + // HandsfreeServiceClient is a client for the infinimesh.handsfree.HandsfreeService service. type HandsfreeServiceClient interface { Send(context.Context, *connect.Request[handsfree.ControlPacket]) (*connect.Response[handsfree.ControlPacket], error) @@ -74,12 +81,14 @@ func NewHandsfreeServiceClient(httpClient connect.HTTPClient, baseURL string, op send: connect.NewClient[handsfree.ControlPacket, handsfree.ControlPacket]( httpClient, baseURL+HandsfreeServiceSendProcedure, - opts..., + connect.WithSchema(handsfreeServiceSendMethodDescriptor), + connect.WithClientOptions(opts...), ), connect: connect.NewClient[handsfree.ConnectionRequest, handsfree.ControlPacket]( httpClient, baseURL+HandsfreeServiceConnectProcedure, - opts..., + connect.WithSchema(handsfreeServiceConnectMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -116,12 +125,14 @@ func NewHandsfreeServiceHandler(svc HandsfreeServiceHandler, opts ...connect.Han handsfreeServiceSendHandler := connect.NewUnaryHandler( HandsfreeServiceSendProcedure, svc.Send, - opts..., + connect.WithSchema(handsfreeServiceSendMethodDescriptor), + connect.WithHandlerOptions(opts...), ) handsfreeServiceConnectHandler := connect.NewServerStreamHandler( HandsfreeServiceConnectProcedure, svc.Connect, - opts..., + connect.WithSchema(handsfreeServiceConnectMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.handsfree.HandsfreeService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/node/nodeconnect/node.connect.go b/node/nodeconnect/node.connect.go index 3ddb36e..6e70fb3 100644 --- a/node/nodeconnect/node.connect.go +++ b/node/nodeconnect/node.connect.go @@ -39,7 +39,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // AccountsServiceName is the fully-qualified name of the AccountsService service. @@ -175,6 +175,61 @@ const ( InternalServiceGetLDAPProvidersProcedure = "/infinimesh.node.InternalService/GetLDAPProviders" ) +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + accountsServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("AccountsService") + accountsServiceTokenMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Token") + accountsServiceGetMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Get") + accountsServiceListMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("List") + accountsServiceCreateMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Create") + accountsServiceUpdateMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Update") + accountsServiceToggleMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Toggle") + accountsServiceDeleteMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Delete") + accountsServiceAccessiblesMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Accessibles") + accountsServiceDeletablesMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Deletables") + accountsServiceMoveMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("Move") + accountsServiceGetCredentialsMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("GetCredentials") + accountsServiceSetCredentialsMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("SetCredentials") + accountsServiceDelCredentialsMethodDescriptor = accountsServiceServiceDescriptor.Methods().ByName("DelCredentials") + sessionsServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("SessionsService") + sessionsServiceGetMethodDescriptor = sessionsServiceServiceDescriptor.Methods().ByName("Get") + sessionsServiceRevokeMethodDescriptor = sessionsServiceServiceDescriptor.Methods().ByName("Revoke") + sessionsServiceGetActivityMethodDescriptor = sessionsServiceServiceDescriptor.Methods().ByName("GetActivity") + namespacesServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("NamespacesService") + namespacesServiceGetMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Get") + namespacesServiceListMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("List") + namespacesServiceCreateMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Create") + namespacesServiceUpdateMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Update") + namespacesServiceDeleteMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Delete") + namespacesServiceAccessiblesMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Accessibles") + namespacesServiceDeletablesMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Deletables") + namespacesServiceJoinsMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Joins") + namespacesServiceJoinMethodDescriptor = namespacesServiceServiceDescriptor.Methods().ByName("Join") + devicesServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("DevicesService") + devicesServiceGetMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Get") + devicesServiceListMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("List") + devicesServiceCreateMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Create") + devicesServiceUpdateMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Update") + devicesServicePatchConfigMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("PatchConfig") + devicesServiceDeleteMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Delete") + devicesServiceToggleMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Toggle") + devicesServiceToggleBasicMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("ToggleBasic") + devicesServiceMakeDevicesTokenMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("MakeDevicesToken") + devicesServiceMoveMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Move") + devicesServiceJoinsMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Joins") + devicesServiceJoinMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("Join") + devicesServiceGetByTokenMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("GetByToken") + devicesServiceGetByFingerprintMethodDescriptor = devicesServiceServiceDescriptor.Methods().ByName("GetByFingerprint") + shadowServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("ShadowService") + shadowServiceGetMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Get") + shadowServicePatchMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Patch") + shadowServiceRemoveMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Remove") + shadowServiceStreamShadowMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("StreamShadow") + shadowServiceStreamShadowSyncMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("StreamShadowSync") + internalServiceServiceDescriptor = node.File_node_node_proto.Services().ByName("InternalService") + internalServiceGetLDAPProvidersMethodDescriptor = internalServiceServiceDescriptor.Methods().ByName("GetLDAPProviders") +) + // AccountsServiceClient is a client for the infinimesh.node.AccountsService service. type AccountsServiceClient interface { Token(context.Context, *connect.Request[node.TokenRequest]) (*connect.Response[node.TokenResponse], error) @@ -205,67 +260,80 @@ func NewAccountsServiceClient(httpClient connect.HTTPClient, baseURL string, opt token: connect.NewClient[node.TokenRequest, node.TokenResponse]( httpClient, baseURL+AccountsServiceTokenProcedure, - opts..., + connect.WithSchema(accountsServiceTokenMethodDescriptor), + connect.WithClientOptions(opts...), ), get: connect.NewClient[accounts.Account, accounts.Account]( httpClient, baseURL+AccountsServiceGetProcedure, - opts..., + connect.WithSchema(accountsServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), list: connect.NewClient[node.EmptyMessage, accounts.Accounts]( httpClient, baseURL+AccountsServiceListProcedure, - opts..., + connect.WithSchema(accountsServiceListMethodDescriptor), + connect.WithClientOptions(opts...), ), create: connect.NewClient[accounts.CreateRequest, accounts.CreateResponse]( httpClient, baseURL+AccountsServiceCreateProcedure, - opts..., + connect.WithSchema(accountsServiceCreateMethodDescriptor), + connect.WithClientOptions(opts...), ), update: connect.NewClient[accounts.Account, accounts.Account]( httpClient, baseURL+AccountsServiceUpdateProcedure, - opts..., + connect.WithSchema(accountsServiceUpdateMethodDescriptor), + connect.WithClientOptions(opts...), ), toggle: connect.NewClient[accounts.Account, accounts.Account]( httpClient, baseURL+AccountsServiceToggleProcedure, - opts..., + connect.WithSchema(accountsServiceToggleMethodDescriptor), + connect.WithClientOptions(opts...), ), delete: connect.NewClient[accounts.Account, node.DeleteResponse]( httpClient, baseURL+AccountsServiceDeleteProcedure, - opts..., + connect.WithSchema(accountsServiceDeleteMethodDescriptor), + connect.WithClientOptions(opts...), ), accessibles: connect.NewClient[namespaces.Namespace, access.Nodes]( httpClient, baseURL+AccountsServiceAccessiblesProcedure, - opts..., + connect.WithSchema(accountsServiceAccessiblesMethodDescriptor), + connect.WithClientOptions(opts...), ), deletables: connect.NewClient[accounts.Account, access.Nodes]( httpClient, baseURL+AccountsServiceDeletablesProcedure, - opts..., + connect.WithSchema(accountsServiceDeletablesMethodDescriptor), + connect.WithClientOptions(opts...), ), move: connect.NewClient[node.MoveRequest, node.EmptyMessage]( httpClient, baseURL+AccountsServiceMoveProcedure, - opts..., + connect.WithSchema(accountsServiceMoveMethodDescriptor), + connect.WithClientOptions(opts...), ), getCredentials: connect.NewClient[node.GetCredentialsRequest, node.GetCredentialsResponse]( httpClient, baseURL+AccountsServiceGetCredentialsProcedure, - opts..., + connect.WithSchema(accountsServiceGetCredentialsMethodDescriptor), + connect.WithClientOptions(opts...), ), setCredentials: connect.NewClient[node.SetCredentialsRequest, node.SetCredentialsResponse]( httpClient, baseURL+AccountsServiceSetCredentialsProcedure, - opts..., + connect.WithSchema(accountsServiceSetCredentialsMethodDescriptor), + connect.WithClientOptions(opts...), ), delCredentials: connect.NewClient[node.DeleteCredentialsRequest, node.DeleteResponse]( httpClient, baseURL+AccountsServiceDelCredentialsProcedure, - opts..., + connect.WithSchema(accountsServiceDelCredentialsMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -378,67 +446,80 @@ func NewAccountsServiceHandler(svc AccountsServiceHandler, opts ...connect.Handl accountsServiceTokenHandler := connect.NewUnaryHandler( AccountsServiceTokenProcedure, svc.Token, - opts..., + connect.WithSchema(accountsServiceTokenMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceGetHandler := connect.NewUnaryHandler( AccountsServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(accountsServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceListHandler := connect.NewUnaryHandler( AccountsServiceListProcedure, svc.List, - opts..., + connect.WithSchema(accountsServiceListMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceCreateHandler := connect.NewUnaryHandler( AccountsServiceCreateProcedure, svc.Create, - opts..., + connect.WithSchema(accountsServiceCreateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceUpdateHandler := connect.NewUnaryHandler( AccountsServiceUpdateProcedure, svc.Update, - opts..., + connect.WithSchema(accountsServiceUpdateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceToggleHandler := connect.NewUnaryHandler( AccountsServiceToggleProcedure, svc.Toggle, - opts..., + connect.WithSchema(accountsServiceToggleMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceDeleteHandler := connect.NewUnaryHandler( AccountsServiceDeleteProcedure, svc.Delete, - opts..., + connect.WithSchema(accountsServiceDeleteMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceAccessiblesHandler := connect.NewUnaryHandler( AccountsServiceAccessiblesProcedure, svc.Accessibles, - opts..., + connect.WithSchema(accountsServiceAccessiblesMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceDeletablesHandler := connect.NewUnaryHandler( AccountsServiceDeletablesProcedure, svc.Deletables, - opts..., + connect.WithSchema(accountsServiceDeletablesMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceMoveHandler := connect.NewUnaryHandler( AccountsServiceMoveProcedure, svc.Move, - opts..., + connect.WithSchema(accountsServiceMoveMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceGetCredentialsHandler := connect.NewUnaryHandler( AccountsServiceGetCredentialsProcedure, svc.GetCredentials, - opts..., + connect.WithSchema(accountsServiceGetCredentialsMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceSetCredentialsHandler := connect.NewUnaryHandler( AccountsServiceSetCredentialsProcedure, svc.SetCredentials, - opts..., + connect.WithSchema(accountsServiceSetCredentialsMethodDescriptor), + connect.WithHandlerOptions(opts...), ) accountsServiceDelCredentialsHandler := connect.NewUnaryHandler( AccountsServiceDelCredentialsProcedure, svc.DelCredentials, - opts..., + connect.WithSchema(accountsServiceDelCredentialsMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.AccountsService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -549,17 +630,20 @@ func NewSessionsServiceClient(httpClient connect.HTTPClient, baseURL string, opt get: connect.NewClient[node.EmptyMessage, sessions.Sessions]( httpClient, baseURL+SessionsServiceGetProcedure, - opts..., + connect.WithSchema(sessionsServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), revoke: connect.NewClient[sessions.Session, node.DeleteResponse]( httpClient, baseURL+SessionsServiceRevokeProcedure, - opts..., + connect.WithSchema(sessionsServiceRevokeMethodDescriptor), + connect.WithClientOptions(opts...), ), getActivity: connect.NewClient[node.EmptyMessage, sessions.Activity]( httpClient, baseURL+SessionsServiceGetActivityProcedure, - opts..., + connect.WithSchema(sessionsServiceGetActivityMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -602,17 +686,20 @@ func NewSessionsServiceHandler(svc SessionsServiceHandler, opts ...connect.Handl sessionsServiceGetHandler := connect.NewUnaryHandler( SessionsServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(sessionsServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) sessionsServiceRevokeHandler := connect.NewUnaryHandler( SessionsServiceRevokeProcedure, svc.Revoke, - opts..., + connect.WithSchema(sessionsServiceRevokeMethodDescriptor), + connect.WithHandlerOptions(opts...), ) sessionsServiceGetActivityHandler := connect.NewUnaryHandler( SessionsServiceGetActivityProcedure, svc.GetActivity, - opts..., + connect.WithSchema(sessionsServiceGetActivityMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.SessionsService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -672,47 +759,56 @@ func NewNamespacesServiceClient(httpClient connect.HTTPClient, baseURL string, o get: connect.NewClient[namespaces.Namespace, namespaces.Namespace]( httpClient, baseURL+NamespacesServiceGetProcedure, - opts..., + connect.WithSchema(namespacesServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), list: connect.NewClient[node.EmptyMessage, namespaces.Namespaces]( httpClient, baseURL+NamespacesServiceListProcedure, - opts..., + connect.WithSchema(namespacesServiceListMethodDescriptor), + connect.WithClientOptions(opts...), ), create: connect.NewClient[namespaces.Namespace, namespaces.Namespace]( httpClient, baseURL+NamespacesServiceCreateProcedure, - opts..., + connect.WithSchema(namespacesServiceCreateMethodDescriptor), + connect.WithClientOptions(opts...), ), update: connect.NewClient[namespaces.Namespace, namespaces.Namespace]( httpClient, baseURL+NamespacesServiceUpdateProcedure, - opts..., + connect.WithSchema(namespacesServiceUpdateMethodDescriptor), + connect.WithClientOptions(opts...), ), delete: connect.NewClient[namespaces.Namespace, node.DeleteResponse]( httpClient, baseURL+NamespacesServiceDeleteProcedure, - opts..., + connect.WithSchema(namespacesServiceDeleteMethodDescriptor), + connect.WithClientOptions(opts...), ), accessibles: connect.NewClient[namespaces.Namespace, access.Nodes]( httpClient, baseURL+NamespacesServiceAccessiblesProcedure, - opts..., + connect.WithSchema(namespacesServiceAccessiblesMethodDescriptor), + connect.WithClientOptions(opts...), ), deletables: connect.NewClient[namespaces.Namespace, access.Nodes]( httpClient, baseURL+NamespacesServiceDeletablesProcedure, - opts..., + connect.WithSchema(namespacesServiceDeletablesMethodDescriptor), + connect.WithClientOptions(opts...), ), joins: connect.NewClient[namespaces.Namespace, accounts.Accounts]( httpClient, baseURL+NamespacesServiceJoinsProcedure, - opts..., + connect.WithSchema(namespacesServiceJoinsMethodDescriptor), + connect.WithClientOptions(opts...), ), join: connect.NewClient[node.JoinRequest, accounts.Accounts]( httpClient, baseURL+NamespacesServiceJoinProcedure, - opts..., + connect.WithSchema(namespacesServiceJoinMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -800,47 +896,56 @@ func NewNamespacesServiceHandler(svc NamespacesServiceHandler, opts ...connect.H namespacesServiceGetHandler := connect.NewUnaryHandler( NamespacesServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(namespacesServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceListHandler := connect.NewUnaryHandler( NamespacesServiceListProcedure, svc.List, - opts..., + connect.WithSchema(namespacesServiceListMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceCreateHandler := connect.NewUnaryHandler( NamespacesServiceCreateProcedure, svc.Create, - opts..., + connect.WithSchema(namespacesServiceCreateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceUpdateHandler := connect.NewUnaryHandler( NamespacesServiceUpdateProcedure, svc.Update, - opts..., + connect.WithSchema(namespacesServiceUpdateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceDeleteHandler := connect.NewUnaryHandler( NamespacesServiceDeleteProcedure, svc.Delete, - opts..., + connect.WithSchema(namespacesServiceDeleteMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceAccessiblesHandler := connect.NewUnaryHandler( NamespacesServiceAccessiblesProcedure, svc.Accessibles, - opts..., + connect.WithSchema(namespacesServiceAccessiblesMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceDeletablesHandler := connect.NewUnaryHandler( NamespacesServiceDeletablesProcedure, svc.Deletables, - opts..., + connect.WithSchema(namespacesServiceDeletablesMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceJoinsHandler := connect.NewUnaryHandler( NamespacesServiceJoinsProcedure, svc.Joins, - opts..., + connect.WithSchema(namespacesServiceJoinsMethodDescriptor), + connect.WithHandlerOptions(opts...), ) namespacesServiceJoinHandler := connect.NewUnaryHandler( NamespacesServiceJoinProcedure, svc.Join, - opts..., + connect.WithSchema(namespacesServiceJoinMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.NamespacesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -943,72 +1048,86 @@ func NewDevicesServiceClient(httpClient connect.HTTPClient, baseURL string, opts get: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServiceGetProcedure, - opts..., + connect.WithSchema(devicesServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), list: connect.NewClient[node.QueryRequest, devices.Devices]( httpClient, baseURL+DevicesServiceListProcedure, - opts..., + connect.WithSchema(devicesServiceListMethodDescriptor), + connect.WithClientOptions(opts...), ), create: connect.NewClient[devices.CreateRequest, devices.CreateResponse]( httpClient, baseURL+DevicesServiceCreateProcedure, - opts..., + connect.WithSchema(devicesServiceCreateMethodDescriptor), + connect.WithClientOptions(opts...), ), update: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServiceUpdateProcedure, - opts..., + connect.WithSchema(devicesServiceUpdateMethodDescriptor), + connect.WithClientOptions(opts...), ), patchConfig: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServicePatchConfigProcedure, - opts..., + connect.WithSchema(devicesServicePatchConfigMethodDescriptor), + connect.WithClientOptions(opts...), ), delete: connect.NewClient[devices.Device, node.DeleteResponse]( httpClient, baseURL+DevicesServiceDeleteProcedure, - opts..., + connect.WithSchema(devicesServiceDeleteMethodDescriptor), + connect.WithClientOptions(opts...), ), toggle: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServiceToggleProcedure, - opts..., + connect.WithSchema(devicesServiceToggleMethodDescriptor), + connect.WithClientOptions(opts...), ), toggleBasic: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServiceToggleBasicProcedure, - opts..., + connect.WithSchema(devicesServiceToggleBasicMethodDescriptor), + connect.WithClientOptions(opts...), ), makeDevicesToken: connect.NewClient[node.DevicesTokenRequest, node.TokenResponse]( httpClient, baseURL+DevicesServiceMakeDevicesTokenProcedure, - opts..., + connect.WithSchema(devicesServiceMakeDevicesTokenMethodDescriptor), + connect.WithClientOptions(opts...), ), move: connect.NewClient[node.MoveRequest, node.EmptyMessage]( httpClient, baseURL+DevicesServiceMoveProcedure, - opts..., + connect.WithSchema(devicesServiceMoveMethodDescriptor), + connect.WithClientOptions(opts...), ), joins: connect.NewClient[devices.Device, access.Nodes]( httpClient, baseURL+DevicesServiceJoinsProcedure, - opts..., + connect.WithSchema(devicesServiceJoinsMethodDescriptor), + connect.WithClientOptions(opts...), ), join: connect.NewClient[node.JoinGeneralRequest, access.Node]( httpClient, baseURL+DevicesServiceJoinProcedure, - opts..., + connect.WithSchema(devicesServiceJoinMethodDescriptor), + connect.WithClientOptions(opts...), ), getByToken: connect.NewClient[devices.Device, devices.Device]( httpClient, baseURL+DevicesServiceGetByTokenProcedure, - opts..., + connect.WithSchema(devicesServiceGetByTokenMethodDescriptor), + connect.WithClientOptions(opts...), ), getByFingerprint: connect.NewClient[devices.GetByFingerprintRequest, devices.Device]( httpClient, baseURL+DevicesServiceGetByFingerprintProcedure, - opts..., + connect.WithSchema(devicesServiceGetByFingerprintMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -1133,72 +1252,86 @@ func NewDevicesServiceHandler(svc DevicesServiceHandler, opts ...connect.Handler devicesServiceGetHandler := connect.NewUnaryHandler( DevicesServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(devicesServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceListHandler := connect.NewUnaryHandler( DevicesServiceListProcedure, svc.List, - opts..., + connect.WithSchema(devicesServiceListMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceCreateHandler := connect.NewUnaryHandler( DevicesServiceCreateProcedure, svc.Create, - opts..., + connect.WithSchema(devicesServiceCreateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceUpdateHandler := connect.NewUnaryHandler( DevicesServiceUpdateProcedure, svc.Update, - opts..., + connect.WithSchema(devicesServiceUpdateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServicePatchConfigHandler := connect.NewUnaryHandler( DevicesServicePatchConfigProcedure, svc.PatchConfig, - opts..., + connect.WithSchema(devicesServicePatchConfigMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceDeleteHandler := connect.NewUnaryHandler( DevicesServiceDeleteProcedure, svc.Delete, - opts..., + connect.WithSchema(devicesServiceDeleteMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceToggleHandler := connect.NewUnaryHandler( DevicesServiceToggleProcedure, svc.Toggle, - opts..., + connect.WithSchema(devicesServiceToggleMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceToggleBasicHandler := connect.NewUnaryHandler( DevicesServiceToggleBasicProcedure, svc.ToggleBasic, - opts..., + connect.WithSchema(devicesServiceToggleBasicMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceMakeDevicesTokenHandler := connect.NewUnaryHandler( DevicesServiceMakeDevicesTokenProcedure, svc.MakeDevicesToken, - opts..., + connect.WithSchema(devicesServiceMakeDevicesTokenMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceMoveHandler := connect.NewUnaryHandler( DevicesServiceMoveProcedure, svc.Move, - opts..., + connect.WithSchema(devicesServiceMoveMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceJoinsHandler := connect.NewUnaryHandler( DevicesServiceJoinsProcedure, svc.Joins, - opts..., + connect.WithSchema(devicesServiceJoinsMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceJoinHandler := connect.NewUnaryHandler( DevicesServiceJoinProcedure, svc.Join, - opts..., + connect.WithSchema(devicesServiceJoinMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceGetByTokenHandler := connect.NewUnaryHandler( DevicesServiceGetByTokenProcedure, svc.GetByToken, - opts..., + connect.WithSchema(devicesServiceGetByTokenMethodDescriptor), + connect.WithHandlerOptions(opts...), ) devicesServiceGetByFingerprintHandler := connect.NewUnaryHandler( DevicesServiceGetByFingerprintProcedure, svc.GetByFingerprint, - opts..., + connect.WithSchema(devicesServiceGetByFingerprintMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.DevicesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -1317,27 +1450,32 @@ func NewShadowServiceClient(httpClient connect.HTTPClient, baseURL string, opts get: connect.NewClient[shadow.GetRequest, shadow.GetResponse]( httpClient, baseURL+ShadowServiceGetProcedure, - opts..., + connect.WithSchema(shadowServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), patch: connect.NewClient[shadow.Shadow, shadow.Shadow]( httpClient, baseURL+ShadowServicePatchProcedure, - opts..., + connect.WithSchema(shadowServicePatchMethodDescriptor), + connect.WithClientOptions(opts...), ), remove: connect.NewClient[shadow.RemoveRequest, shadow.Shadow]( httpClient, baseURL+ShadowServiceRemoveProcedure, - opts..., + connect.WithSchema(shadowServiceRemoveMethodDescriptor), + connect.WithClientOptions(opts...), ), streamShadow: connect.NewClient[shadow.StreamShadowRequest, shadow.Shadow]( httpClient, baseURL+ShadowServiceStreamShadowProcedure, - opts..., + connect.WithSchema(shadowServiceStreamShadowMethodDescriptor), + connect.WithClientOptions(opts...), ), streamShadowSync: connect.NewClient[shadow.StreamShadowRequest, shadow.Shadow]( httpClient, baseURL+ShadowServiceStreamShadowSyncProcedure, - opts..., + connect.WithSchema(shadowServiceStreamShadowSyncMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -1394,27 +1532,32 @@ func NewShadowServiceHandler(svc ShadowServiceHandler, opts ...connect.HandlerOp shadowServiceGetHandler := connect.NewUnaryHandler( ShadowServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(shadowServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServicePatchHandler := connect.NewUnaryHandler( ShadowServicePatchProcedure, svc.Patch, - opts..., + connect.WithSchema(shadowServicePatchMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServiceRemoveHandler := connect.NewUnaryHandler( ShadowServiceRemoveProcedure, svc.Remove, - opts..., + connect.WithSchema(shadowServiceRemoveMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServiceStreamShadowHandler := connect.NewServerStreamHandler( ShadowServiceStreamShadowProcedure, svc.StreamShadow, - opts..., + connect.WithSchema(shadowServiceStreamShadowMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServiceStreamShadowSyncHandler := connect.NewServerStreamHandler( ShadowServiceStreamShadowSyncProcedure, svc.StreamShadowSync, - opts..., + connect.WithSchema(shadowServiceStreamShadowSyncMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.ShadowService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -1475,7 +1618,8 @@ func NewInternalServiceClient(httpClient connect.HTTPClient, baseURL string, opt getLDAPProviders: connect.NewClient[node.EmptyMessage, node.LDAPProviders]( httpClient, baseURL+InternalServiceGetLDAPProvidersProcedure, - opts..., + connect.WithSchema(internalServiceGetLDAPProvidersMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -1504,7 +1648,8 @@ func NewInternalServiceHandler(svc InternalServiceHandler, opts ...connect.Handl internalServiceGetLDAPProvidersHandler := connect.NewUnaryHandler( InternalServiceGetLDAPProvidersProcedure, svc.GetLDAPProviders, - opts..., + connect.WithSchema(internalServiceGetLDAPProvidersMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.node.InternalService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/plugins/pluginsconnect/plugins.connect.go b/plugins/pluginsconnect/plugins.connect.go index cad80af..cbd8332 100644 --- a/plugins/pluginsconnect/plugins.connect.go +++ b/plugins/pluginsconnect/plugins.connect.go @@ -33,7 +33,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // PluginsServiceName is the fully-qualified name of the PluginsService service. @@ -60,6 +60,16 @@ const ( PluginsServiceDeleteProcedure = "/infinimesh.plugins.PluginsService/Delete" ) +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + pluginsServiceServiceDescriptor = plugins.File_plugins_plugins_proto.Services().ByName("PluginsService") + pluginsServiceGetMethodDescriptor = pluginsServiceServiceDescriptor.Methods().ByName("Get") + pluginsServiceListMethodDescriptor = pluginsServiceServiceDescriptor.Methods().ByName("List") + pluginsServiceCreateMethodDescriptor = pluginsServiceServiceDescriptor.Methods().ByName("Create") + pluginsServiceUpdateMethodDescriptor = pluginsServiceServiceDescriptor.Methods().ByName("Update") + pluginsServiceDeleteMethodDescriptor = pluginsServiceServiceDescriptor.Methods().ByName("Delete") +) + // PluginsServiceClient is a client for the infinimesh.plugins.PluginsService service. type PluginsServiceClient interface { Get(context.Context, *connect.Request[plugins.Plugin]) (*connect.Response[plugins.Plugin], error) @@ -82,27 +92,32 @@ func NewPluginsServiceClient(httpClient connect.HTTPClient, baseURL string, opts get: connect.NewClient[plugins.Plugin, plugins.Plugin]( httpClient, baseURL+PluginsServiceGetProcedure, - opts..., + connect.WithSchema(pluginsServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), list: connect.NewClient[plugins.ListRequest, plugins.Plugins]( httpClient, baseURL+PluginsServiceListProcedure, - opts..., + connect.WithSchema(pluginsServiceListMethodDescriptor), + connect.WithClientOptions(opts...), ), create: connect.NewClient[plugins.Plugin, plugins.Plugin]( httpClient, baseURL+PluginsServiceCreateProcedure, - opts..., + connect.WithSchema(pluginsServiceCreateMethodDescriptor), + connect.WithClientOptions(opts...), ), update: connect.NewClient[plugins.Plugin, plugins.Plugin]( httpClient, baseURL+PluginsServiceUpdateProcedure, - opts..., + connect.WithSchema(pluginsServiceUpdateMethodDescriptor), + connect.WithClientOptions(opts...), ), delete: connect.NewClient[plugins.Plugin, plugins.Plugin]( httpClient, baseURL+PluginsServiceDeleteProcedure, - opts..., + connect.WithSchema(pluginsServiceDeleteMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -159,27 +174,32 @@ func NewPluginsServiceHandler(svc PluginsServiceHandler, opts ...connect.Handler pluginsServiceGetHandler := connect.NewUnaryHandler( PluginsServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(pluginsServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) pluginsServiceListHandler := connect.NewUnaryHandler( PluginsServiceListProcedure, svc.List, - opts..., + connect.WithSchema(pluginsServiceListMethodDescriptor), + connect.WithHandlerOptions(opts...), ) pluginsServiceCreateHandler := connect.NewUnaryHandler( PluginsServiceCreateProcedure, svc.Create, - opts..., + connect.WithSchema(pluginsServiceCreateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) pluginsServiceUpdateHandler := connect.NewUnaryHandler( PluginsServiceUpdateProcedure, svc.Update, - opts..., + connect.WithSchema(pluginsServiceUpdateMethodDescriptor), + connect.WithHandlerOptions(opts...), ) pluginsServiceDeleteHandler := connect.NewUnaryHandler( PluginsServiceDeleteProcedure, svc.Delete, - opts..., + connect.WithSchema(pluginsServiceDeleteMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.plugins.PluginsService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/shadow/shadowconnect/shadow.connect.go b/shadow/shadowconnect/shadow.connect.go index 2027088..26bf106 100644 --- a/shadow/shadowconnect/shadow.connect.go +++ b/shadow/shadowconnect/shadow.connect.go @@ -33,7 +33,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // ShadowServiceName is the fully-qualified name of the ShadowService service. @@ -59,6 +59,15 @@ const ( ShadowServiceStreamShadowProcedure = "/infinimesh.shadow.ShadowService/StreamShadow" ) +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + shadowServiceServiceDescriptor = shadow.File_shadow_shadow_proto.Services().ByName("ShadowService") + shadowServiceGetMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Get") + shadowServicePatchMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Patch") + shadowServiceRemoveMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("Remove") + shadowServiceStreamShadowMethodDescriptor = shadowServiceServiceDescriptor.Methods().ByName("StreamShadow") +) + // ShadowServiceClient is a client for the infinimesh.shadow.ShadowService service. type ShadowServiceClient interface { Get(context.Context, *connect.Request[shadow.GetRequest]) (*connect.Response[shadow.GetResponse], error) @@ -80,22 +89,26 @@ func NewShadowServiceClient(httpClient connect.HTTPClient, baseURL string, opts get: connect.NewClient[shadow.GetRequest, shadow.GetResponse]( httpClient, baseURL+ShadowServiceGetProcedure, - opts..., + connect.WithSchema(shadowServiceGetMethodDescriptor), + connect.WithClientOptions(opts...), ), patch: connect.NewClient[shadow.Shadow, shadow.Shadow]( httpClient, baseURL+ShadowServicePatchProcedure, - opts..., + connect.WithSchema(shadowServicePatchMethodDescriptor), + connect.WithClientOptions(opts...), ), remove: connect.NewClient[shadow.RemoveRequest, shadow.Shadow]( httpClient, baseURL+ShadowServiceRemoveProcedure, - opts..., + connect.WithSchema(shadowServiceRemoveMethodDescriptor), + connect.WithClientOptions(opts...), ), streamShadow: connect.NewClient[shadow.StreamShadowRequest, shadow.Shadow]( httpClient, baseURL+ShadowServiceStreamShadowProcedure, - opts..., + connect.WithSchema(shadowServiceStreamShadowMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -145,22 +158,26 @@ func NewShadowServiceHandler(svc ShadowServiceHandler, opts ...connect.HandlerOp shadowServiceGetHandler := connect.NewUnaryHandler( ShadowServiceGetProcedure, svc.Get, - opts..., + connect.WithSchema(shadowServiceGetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServicePatchHandler := connect.NewUnaryHandler( ShadowServicePatchProcedure, svc.Patch, - opts..., + connect.WithSchema(shadowServicePatchMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServiceRemoveHandler := connect.NewUnaryHandler( ShadowServiceRemoveProcedure, svc.Remove, - opts..., + connect.WithSchema(shadowServiceRemoveMethodDescriptor), + connect.WithHandlerOptions(opts...), ) shadowServiceStreamShadowHandler := connect.NewServerStreamHandler( ShadowServiceStreamShadowProcedure, svc.StreamShadow, - opts..., + connect.WithSchema(shadowServiceStreamShadowMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.shadow.ShadowService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/timeseries/timeseriesconnect/timeseries.connect.go b/timeseries/timeseriesconnect/timeseries.connect.go index ab58d76..310c8f6 100644 --- a/timeseries/timeseriesconnect/timeseries.connect.go +++ b/timeseries/timeseriesconnect/timeseries.connect.go @@ -18,7 +18,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // TimeseriesServiceName is the fully-qualified name of the TimeseriesService service. @@ -46,6 +46,16 @@ const ( TimeseriesServiceFlushProcedure = "/infinimesh.timeseries.TimeseriesService/Flush" ) +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + timeseriesServiceServiceDescriptor = timeseries.File_timeseries_timeseries_proto.Services().ByName("TimeseriesService") + timeseriesServiceWriteMethodDescriptor = timeseriesServiceServiceDescriptor.Methods().ByName("Write") + timeseriesServiceWriteBulkMethodDescriptor = timeseriesServiceServiceDescriptor.Methods().ByName("WriteBulk") + timeseriesServiceReadMethodDescriptor = timeseriesServiceServiceDescriptor.Methods().ByName("Read") + timeseriesServiceStatMethodDescriptor = timeseriesServiceServiceDescriptor.Methods().ByName("Stat") + timeseriesServiceFlushMethodDescriptor = timeseriesServiceServiceDescriptor.Methods().ByName("Flush") +) + // TimeseriesServiceClient is a client for the infinimesh.timeseries.TimeseriesService service. type TimeseriesServiceClient interface { Write(context.Context, *connect.Request[timeseries.WriteRequest]) (*connect.Response[timeseries.WriteResponse], error) @@ -68,27 +78,32 @@ func NewTimeseriesServiceClient(httpClient connect.HTTPClient, baseURL string, o write: connect.NewClient[timeseries.WriteRequest, timeseries.WriteResponse]( httpClient, baseURL+TimeseriesServiceWriteProcedure, - opts..., + connect.WithSchema(timeseriesServiceWriteMethodDescriptor), + connect.WithClientOptions(opts...), ), writeBulk: connect.NewClient[timeseries.WriteBulkRequest, timeseries.WriteBulkResponse]( httpClient, baseURL+TimeseriesServiceWriteBulkProcedure, - opts..., + connect.WithSchema(timeseriesServiceWriteBulkMethodDescriptor), + connect.WithClientOptions(opts...), ), read: connect.NewClient[timeseries.ReadRequest, timeseries.ReadResponse]( httpClient, baseURL+TimeseriesServiceReadProcedure, - opts..., + connect.WithSchema(timeseriesServiceReadMethodDescriptor), + connect.WithClientOptions(opts...), ), stat: connect.NewClient[timeseries.StatRequest, timeseries.StatResponse]( httpClient, baseURL+TimeseriesServiceStatProcedure, - opts..., + connect.WithSchema(timeseriesServiceStatMethodDescriptor), + connect.WithClientOptions(opts...), ), flush: connect.NewClient[timeseries.FlushRequest, timeseries.FlushResponse]( httpClient, baseURL+TimeseriesServiceFlushProcedure, - opts..., + connect.WithSchema(timeseriesServiceFlushMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -146,27 +161,32 @@ func NewTimeseriesServiceHandler(svc TimeseriesServiceHandler, opts ...connect.H timeseriesServiceWriteHandler := connect.NewUnaryHandler( TimeseriesServiceWriteProcedure, svc.Write, - opts..., + connect.WithSchema(timeseriesServiceWriteMethodDescriptor), + connect.WithHandlerOptions(opts...), ) timeseriesServiceWriteBulkHandler := connect.NewUnaryHandler( TimeseriesServiceWriteBulkProcedure, svc.WriteBulk, - opts..., + connect.WithSchema(timeseriesServiceWriteBulkMethodDescriptor), + connect.WithHandlerOptions(opts...), ) timeseriesServiceReadHandler := connect.NewUnaryHandler( TimeseriesServiceReadProcedure, svc.Read, - opts..., + connect.WithSchema(timeseriesServiceReadMethodDescriptor), + connect.WithHandlerOptions(opts...), ) timeseriesServiceStatHandler := connect.NewUnaryHandler( TimeseriesServiceStatProcedure, svc.Stat, - opts..., + connect.WithSchema(timeseriesServiceStatMethodDescriptor), + connect.WithHandlerOptions(opts...), ) timeseriesServiceFlushHandler := connect.NewUnaryHandler( TimeseriesServiceFlushProcedure, svc.Flush, - opts..., + connect.WithSchema(timeseriesServiceFlushMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/infinimesh.timeseries.TimeseriesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { From 7d8690ed51185c2386340442f9b3597686f4af1d Mon Sep 17 00:00:00 2001 From: Nikita Zhamoidzik Date: Mon, 19 Feb 2024 14:07:47 +0300 Subject: [PATCH 2/6] Fix type --- api.swagger.json | 3 +- eventbus/eventbus.pb.go | 122 +++++++++++++++---------------- eventbus/eventbus.pb.validate.go | 65 ++++++---------- eventbus/eventbus.proto | 2 +- 4 files changed, 83 insertions(+), 109 deletions(-) diff --git a/api.swagger.json b/api.swagger.json index 502cce1..780984a 100644 --- a/api.swagger.json +++ b/api.swagger.json @@ -3179,8 +3179,7 @@ "$ref": "#/definitions/devicesDevice" }, "meta": { - "type": "object", - "additionalProperties": {} + "type": "object" } } }, diff --git a/eventbus/eventbus.pb.go b/eventbus/eventbus.pb.go index da7d7c9..0d855a4 100644 --- a/eventbus/eventbus.pb.go +++ b/eventbus/eventbus.pb.go @@ -106,8 +106,8 @@ type Event struct { // *Event_Account // *Event_Namespace // *Event_Device - Entity isEvent_Entity `protobuf_oneof:"entity"` - Meta map[string]*structpb.Value `protobuf:"bytes,5,rep,name=meta,proto3" json:"meta,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Entity isEvent_Entity `protobuf_oneof:"entity"` + Meta *structpb.Struct `protobuf:"bytes,5,opt,name=meta,proto3" json:"meta,omitempty"` } func (x *Event) Reset() { @@ -177,7 +177,7 @@ func (x *Event) GetDevice() *devices.Device { return nil } -func (x *Event) GetMeta() map[string]*structpb.Value { +func (x *Event) GetMeta() *structpb.Struct { if x != nil { return x.Meta } @@ -220,7 +220,7 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x03, 0x0a, 0x05, 0x45, 0x76, + 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x02, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, @@ -237,47 +237,41 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, - 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x1a, 0x4f, 0x0a, - 0x09, 0x4d, 0x65, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, - 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, - 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, - 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, - 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, - 0x55, 0x4e, 0x54, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, - 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, - 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, - 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, - 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, 0x12, 0x11, - 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, - 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, - 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x44, - 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x59, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, - 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, - 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, - 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x42, 0x0d, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x69, - 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, 0x49, 0x6e, - 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, - 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, - 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, 0x66, 0x69, - 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x63, 0x65, 0x12, 0x2b, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, + 0x42, 0x08, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, + 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, + 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, + 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, + 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x14, + 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, + 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, + 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, + 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, + 0x45, 0x10, 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, + 0x44, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, + 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x59, 0x0a, 0x0d, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x53, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, + 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, + 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, + 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, + 0x42, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, + 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, + 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x62, 0x75, 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, + 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, + 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, + 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, + 0x75, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -293,31 +287,29 @@ func file_eventbus_eventbus_proto_rawDescGZIP() []byte { } var file_eventbus_eventbus_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_eventbus_eventbus_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_eventbus_eventbus_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_eventbus_eventbus_proto_goTypes = []interface{}{ (EventType)(0), // 0: infinimesh.eventbus.EventType (*Event)(nil), // 1: infinimesh.eventbus.Event - nil, // 2: infinimesh.eventbus.Event.MetaEntry - (*accounts.Account)(nil), // 3: infinimesh.node.accounts.Account - (*namespaces.Namespace)(nil), // 4: infinimesh.node.namespaces.Namespace - (*devices.Device)(nil), // 5: infinimesh.node.devices.Device - (*structpb.Value)(nil), // 6: google.protobuf.Value - (*node.EmptyMessage)(nil), // 7: infinimesh.node.EmptyMessage + (*accounts.Account)(nil), // 2: infinimesh.node.accounts.Account + (*namespaces.Namespace)(nil), // 3: infinimesh.node.namespaces.Namespace + (*devices.Device)(nil), // 4: infinimesh.node.devices.Device + (*structpb.Struct)(nil), // 5: google.protobuf.Struct + (*node.EmptyMessage)(nil), // 6: infinimesh.node.EmptyMessage } var file_eventbus_eventbus_proto_depIdxs = []int32{ 0, // 0: infinimesh.eventbus.Event.event_type:type_name -> infinimesh.eventbus.EventType - 3, // 1: infinimesh.eventbus.Event.account:type_name -> infinimesh.node.accounts.Account - 4, // 2: infinimesh.eventbus.Event.namespace:type_name -> infinimesh.node.namespaces.Namespace - 5, // 3: infinimesh.eventbus.Event.device:type_name -> infinimesh.node.devices.Device - 2, // 4: infinimesh.eventbus.Event.meta:type_name -> infinimesh.eventbus.Event.MetaEntry - 6, // 5: infinimesh.eventbus.Event.MetaEntry.value:type_name -> google.protobuf.Value - 7, // 6: infinimesh.eventbus.EventsService.Subscribe:input_type -> infinimesh.node.EmptyMessage - 1, // 7: infinimesh.eventbus.EventsService.Subscribe:output_type -> infinimesh.eventbus.Event - 7, // [7:8] is the sub-list for method output_type - 6, // [6:7] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 2, // 1: infinimesh.eventbus.Event.account:type_name -> infinimesh.node.accounts.Account + 3, // 2: infinimesh.eventbus.Event.namespace:type_name -> infinimesh.node.namespaces.Namespace + 4, // 3: infinimesh.eventbus.Event.device:type_name -> infinimesh.node.devices.Device + 5, // 4: infinimesh.eventbus.Event.meta:type_name -> google.protobuf.Struct + 6, // 5: infinimesh.eventbus.EventsService.Subscribe:input_type -> infinimesh.node.EmptyMessage + 1, // 6: infinimesh.eventbus.EventsService.Subscribe:output_type -> infinimesh.eventbus.Event + 6, // [6:7] is the sub-list for method output_type + 5, // [5:6] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_eventbus_eventbus_proto_init() } @@ -350,7 +342,7 @@ func file_eventbus_eventbus_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_eventbus_eventbus_proto_rawDesc, NumEnums: 1, - NumMessages: 2, + NumMessages: 1, NumExtensions: 0, NumServices: 1, }, diff --git a/eventbus/eventbus.pb.validate.go b/eventbus/eventbus.pb.validate.go index f792a33..c225ad8 100644 --- a/eventbus/eventbus.pb.validate.go +++ b/eventbus/eventbus.pb.validate.go @@ -58,49 +58,32 @@ func (m *Event) validate(all bool) error { // no validation rules for EventType - { - sorted_keys := make([]string, len(m.GetMeta())) - i := 0 - for key := range m.GetMeta() { - sorted_keys[i] = key - i++ + if all { + switch v := interface{}(m.GetMeta()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, EventValidationError{ + field: "Meta", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, EventValidationError{ + field: "Meta", + reason: "embedded message failed validation", + cause: err, + }) + } } - sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) - for _, key := range sorted_keys { - val := m.GetMeta()[key] - _ = val - - // no validation rules for Meta[key] - - if all { - switch v := interface{}(val).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, EventValidationError{ - field: fmt.Sprintf("Meta[%v]", key), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, EventValidationError{ - field: fmt.Sprintf("Meta[%v]", key), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return EventValidationError{ - field: fmt.Sprintf("Meta[%v]", key), - reason: "embedded message failed validation", - cause: err, - } - } + } else if v, ok := interface{}(m.GetMeta()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return EventValidationError{ + field: "Meta", + reason: "embedded message failed validation", + cause: err, } - } } diff --git a/eventbus/eventbus.proto b/eventbus/eventbus.proto index fd8e592..df56212 100644 --- a/eventbus/eventbus.proto +++ b/eventbus/eventbus.proto @@ -28,7 +28,7 @@ message Event { node.namespaces.Namespace namespace = 3; node.devices.Device device = 4; } - map meta = 5; + google.protobuf.Struct meta = 5; } service EventsService{ From a5c86b6acb6ba6989c29a7703dcb18d516abb0c6 Mon Sep 17 00:00:00 2001 From: Nikita Zhamoidzik Date: Mon, 19 Feb 2024 17:12:16 +0300 Subject: [PATCH 3/6] Add gateway --- api.swagger.json | 31 +++++++++ eventbus/eventbus.pb.go | 109 +++++++++++++++-------------- eventbus/eventbus.pb.gw.go | 137 +++++++++++++++++++++++++++++++++++++ eventbus/eventbus.proto | 5 +- 4 files changed, 229 insertions(+), 53 deletions(-) create mode 100644 eventbus/eventbus.pb.gw.go diff --git a/api.swagger.json b/api.swagger.json index 780984a..794b27e 100644 --- a/api.swagger.json +++ b/api.swagger.json @@ -1741,6 +1741,37 @@ ] } }, + "/eventbus/stream": { + "get": { + "operationId": "EventsService_Subscribe", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "properties": { + "result": { + "$ref": "#/definitions/eventbusEvent" + }, + "error": { + "$ref": "#/definitions/rpcStatus" + } + }, + "title": "Stream result of eventbusEvent" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "EventsService" + ] + } + }, "/handsfree": { "post": { "operationId": "HandsfreeService_Send", diff --git a/eventbus/eventbus.pb.go b/eventbus/eventbus.pb.go index 0d855a4..9fbcd3d 100644 --- a/eventbus/eventbus.pb.go +++ b/eventbus/eventbus.pb.go @@ -11,6 +11,7 @@ import ( accounts "github.com/infinimesh/proto/node/accounts" devices "github.com/infinimesh/proto/node/devices" namespaces "github.com/infinimesh/proto/node/namespaces" + _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" @@ -220,58 +221,62 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, - 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x02, 0x0a, 0x05, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, - 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, - 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x45, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, - 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, - 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, - 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x2b, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, - 0x42, 0x08, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, - 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, - 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, - 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, - 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x14, - 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, - 0x54, 0x45, 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, - 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, - 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, - 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, - 0x45, 0x10, 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, - 0x44, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, - 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x59, 0x0a, 0x0d, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x53, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, - 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, - 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, - 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, - 0x42, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, - 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, - 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x62, 0x75, 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, - 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, - 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, - 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, - 0x75, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x02, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, + 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x3d, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x45, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, + 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, + 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x2b, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x42, 0x08, + 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, + 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, + 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, + 0x55, 0x4e, 0x54, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, + 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, + 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, + 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x05, 0x12, 0x14, 0x0a, 0x10, 0x4e, 0x41, 0x4d, 0x45, + 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, 0x12, 0x11, + 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, + 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, + 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x44, + 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x73, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, + 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, + 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x62, 0x75, 0x73, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, + 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x42, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, + 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, + 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, + 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, + 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, + 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, + 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/eventbus/eventbus.pb.gw.go b/eventbus/eventbus.pb.gw.go new file mode 100644 index 0000000..b4d2524 --- /dev/null +++ b/eventbus/eventbus.pb.gw.go @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: eventbus/eventbus.proto + +/* +Package eventbus is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package eventbus + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "github.com/infinimesh/proto/node" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_EventsService_Subscribe_0(ctx context.Context, marshaler runtime.Marshaler, client EventsServiceClient, req *http.Request, pathParams map[string]string) (EventsService_SubscribeClient, runtime.ServerMetadata, error) { + var protoReq node.EmptyMessage + var metadata runtime.ServerMetadata + + stream, err := client.Subscribe(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + +// RegisterEventsServiceHandlerServer registers the http handlers for service EventsService to "mux". +// UnaryRPC :call EventsServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEventsServiceHandlerFromEndpoint instead. +func RegisterEventsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EventsServiceServer) error { + + mux.Handle("GET", pattern_EventsService_Subscribe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") + _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + }) + + return nil +} + +// RegisterEventsServiceHandlerFromEndpoint is same as RegisterEventsServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterEventsServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterEventsServiceHandler(ctx, mux, conn) +} + +// RegisterEventsServiceHandler registers the http handlers for service EventsService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterEventsServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterEventsServiceHandlerClient(ctx, mux, NewEventsServiceClient(conn)) +} + +// RegisterEventsServiceHandlerClient registers the http handlers for service EventsService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EventsServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EventsServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "EventsServiceClient" to call the correct interceptors. +func RegisterEventsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EventsServiceClient) error { + + mux.Handle("GET", pattern_EventsService_Subscribe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/infinimesh.eventbus.EventsService/Subscribe", runtime.WithHTTPPathPattern("/eventbus/stream")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EventsService_Subscribe_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_EventsService_Subscribe_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_EventsService_Subscribe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"eventbus", "stream"}, "")) +) + +var ( + forward_EventsService_Subscribe_0 = runtime.ForwardResponseStream +) diff --git a/eventbus/eventbus.proto b/eventbus/eventbus.proto index df56212..4f7bc82 100644 --- a/eventbus/eventbus.proto +++ b/eventbus/eventbus.proto @@ -7,6 +7,7 @@ import "node/namespaces/namespaces.proto"; import "node/devices/devices.proto"; import "node/node.proto"; import "google/protobuf/struct.proto"; +import "google/api/annotations.proto"; enum EventType{ NONE = 0; @@ -32,5 +33,7 @@ message Event { } service EventsService{ - rpc Subscribe (node.EmptyMessage) returns (stream Event); + rpc Subscribe (node.EmptyMessage) returns (stream Event){ + option (google.api.http) = {get: "/eventbus/stream"}; + } } \ No newline at end of file From d32fd20be8f5482423c102a39740592f40534609 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 08:30:11 +0000 Subject: [PATCH 4/6] Continuous Integration Build Protobuf Client Libraries for ES --- build/es/eventbus/eventbus_connect.d.ts | 27 ++++++ build/es/eventbus/eventbus_connect.js | 27 ++++++ build/es/eventbus/eventbus_pb.d.ts | 118 ++++++++++++++++++++++++ build/es/eventbus/eventbus_pb.js | 43 +++++++++ 4 files changed, 215 insertions(+) create mode 100644 build/es/eventbus/eventbus_connect.d.ts create mode 100644 build/es/eventbus/eventbus_connect.js create mode 100644 build/es/eventbus/eventbus_pb.d.ts create mode 100644 build/es/eventbus/eventbus_pb.js diff --git a/build/es/eventbus/eventbus_connect.d.ts b/build/es/eventbus/eventbus_connect.d.ts new file mode 100644 index 0000000..957e4f3 --- /dev/null +++ b/build/es/eventbus/eventbus_connect.d.ts @@ -0,0 +1,27 @@ +// @generated by protoc-gen-connect-es v1.3.0 with parameter "target=js+dts" +// @generated from file eventbus/eventbus.proto (package infinimesh.eventbus, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { EmptyMessage } from "../node/node_pb.js"; +import { Event } from "./eventbus_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service infinimesh.eventbus.EventsService + */ +export declare const EventsService: { + readonly typeName: "infinimesh.eventbus.EventsService", + readonly methods: { + /** + * @generated from rpc infinimesh.eventbus.EventsService.Subscribe + */ + readonly subscribe: { + readonly name: "Subscribe", + readonly I: typeof EmptyMessage, + readonly O: typeof Event, + readonly kind: MethodKind.ServerStreaming, + }, + } +}; + diff --git a/build/es/eventbus/eventbus_connect.js b/build/es/eventbus/eventbus_connect.js new file mode 100644 index 0000000..e802c7b --- /dev/null +++ b/build/es/eventbus/eventbus_connect.js @@ -0,0 +1,27 @@ +// @generated by protoc-gen-connect-es v1.3.0 with parameter "target=js+dts" +// @generated from file eventbus/eventbus.proto (package infinimesh.eventbus, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { EmptyMessage } from "../node/node_pb.js"; +import { Event } from "./eventbus_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service infinimesh.eventbus.EventsService + */ +export const EventsService = { + typeName: "infinimesh.eventbus.EventsService", + methods: { + /** + * @generated from rpc infinimesh.eventbus.EventsService.Subscribe + */ + subscribe: { + name: "Subscribe", + I: EmptyMessage, + O: Event, + kind: MethodKind.ServerStreaming, + }, + } +}; + diff --git a/build/es/eventbus/eventbus_pb.d.ts b/build/es/eventbus/eventbus_pb.d.ts new file mode 100644 index 0000000..628f0c1 --- /dev/null +++ b/build/es/eventbus/eventbus_pb.d.ts @@ -0,0 +1,118 @@ +// @generated by protoc-gen-es v1.7.2 with parameter "target=js+dts" +// @generated from file eventbus/eventbus.proto (package infinimesh.eventbus, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage, Struct } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { Account } from "../node/accounts/accounts_pb.js"; +import type { Namespace } from "../node/namespaces/namespaces_pb.js"; +import type { Device } from "../node/devices/devices_pb.js"; + +/** + * @generated from enum infinimesh.eventbus.EventType + */ +export declare enum EventType { + /** + * @generated from enum value: NONE = 0; + */ + NONE = 0, + + /** + * @generated from enum value: ACCOUNT_CREATE = 1; + */ + ACCOUNT_CREATE = 1, + + /** + * @generated from enum value: ACCOUNT_UPDATE = 2; + */ + ACCOUNT_UPDATE = 2, + + /** + * @generated from enum value: ACCOUNT_DELETE = 3; + */ + ACCOUNT_DELETE = 3, + + /** + * @generated from enum value: NAMESPACE_CREATE = 4; + */ + NAMESPACE_CREATE = 4, + + /** + * @generated from enum value: NAMESPACE_UPDATE = 5; + */ + NAMESPACE_UPDATE = 5, + + /** + * @generated from enum value: NAMESPACE_DELETE = 6; + */ + NAMESPACE_DELETE = 6, + + /** + * @generated from enum value: DEVICE_CREATE = 7; + */ + DEVICE_CREATE = 7, + + /** + * @generated from enum value: DEVICE_UPDATE = 8; + */ + DEVICE_UPDATE = 8, + + /** + * @generated from enum value: DEVICE_DELETE = 9; + */ + DEVICE_DELETE = 9, +} + +/** + * @generated from message infinimesh.eventbus.Event + */ +export declare class Event extends Message { + /** + * @generated from field: infinimesh.eventbus.EventType event_type = 1; + */ + eventType: EventType; + + /** + * @generated from oneof infinimesh.eventbus.Event.entity + */ + entity: { + /** + * @generated from field: infinimesh.node.accounts.Account account = 2; + */ + value: Account; + case: "account"; + } | { + /** + * @generated from field: infinimesh.node.namespaces.Namespace namespace = 3; + */ + value: Namespace; + case: "namespace"; + } | { + /** + * @generated from field: infinimesh.node.devices.Device device = 4; + */ + value: Device; + case: "device"; + } | { case: undefined; value?: undefined }; + + /** + * @generated from field: google.protobuf.Struct meta = 5; + */ + meta?: Struct; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "infinimesh.eventbus.Event"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Event; + + static fromJson(jsonValue: JsonValue, options?: Partial): Event; + + static fromJsonString(jsonString: string, options?: Partial): Event; + + static equals(a: Event | PlainMessage | undefined, b: Event | PlainMessage | undefined): boolean; +} + diff --git a/build/es/eventbus/eventbus_pb.js b/build/es/eventbus/eventbus_pb.js new file mode 100644 index 0000000..a33bca9 --- /dev/null +++ b/build/es/eventbus/eventbus_pb.js @@ -0,0 +1,43 @@ +// @generated by protoc-gen-es v1.7.2 with parameter "target=js+dts" +// @generated from file eventbus/eventbus.proto (package infinimesh.eventbus, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { proto3, Struct } from "@bufbuild/protobuf"; +import { Account } from "../node/accounts/accounts_pb.js"; +import { Namespace } from "../node/namespaces/namespaces_pb.js"; +import { Device } from "../node/devices/devices_pb.js"; + +/** + * @generated from enum infinimesh.eventbus.EventType + */ +export const EventType = proto3.makeEnum( + "infinimesh.eventbus.EventType", + [ + {no: 0, name: "NONE"}, + {no: 1, name: "ACCOUNT_CREATE"}, + {no: 2, name: "ACCOUNT_UPDATE"}, + {no: 3, name: "ACCOUNT_DELETE"}, + {no: 4, name: "NAMESPACE_CREATE"}, + {no: 5, name: "NAMESPACE_UPDATE"}, + {no: 6, name: "NAMESPACE_DELETE"}, + {no: 7, name: "DEVICE_CREATE"}, + {no: 8, name: "DEVICE_UPDATE"}, + {no: 9, name: "DEVICE_DELETE"}, + ], +); + +/** + * @generated from message infinimesh.eventbus.Event + */ +export const Event = proto3.makeMessageType( + "infinimesh.eventbus.Event", + () => [ + { no: 1, name: "event_type", kind: "enum", T: proto3.getEnumType(EventType) }, + { no: 2, name: "account", kind: "message", T: Account, oneof: "entity" }, + { no: 3, name: "namespace", kind: "message", T: Namespace, oneof: "entity" }, + { no: 4, name: "device", kind: "message", T: Device, oneof: "entity" }, + { no: 5, name: "meta", kind: "message", T: Struct }, + ], +); + From 8cc72c2135aad9a7da000a99a9da0fcdb14a6253 Mon Sep 17 00:00:00 2001 From: Nikita Zhamoidzik Date: Tue, 20 Feb 2024 12:10:29 +0300 Subject: [PATCH 5/6] Fix proto --- api.swagger.json | 37 +-------- eventbus/eventbus.pb.go | 94 +++++++++++---------- eventbus/eventbus.pb.gw.go | 137 ------------------------------- eventbus/eventbus.pb.validate.go | 2 +- eventbus/eventbus.proto | 8 +- 5 files changed, 53 insertions(+), 225 deletions(-) delete mode 100644 eventbus/eventbus.pb.gw.go diff --git a/api.swagger.json b/api.swagger.json index ec7b791..dc9826f 100644 --- a/api.swagger.json +++ b/api.swagger.json @@ -1597,37 +1597,6 @@ ] } }, - "/eventbus/stream": { - "get": { - "operationId": "EventsService_Subscribe", - "responses": { - "200": { - "description": "A successful response.(streaming responses)", - "schema": { - "type": "object", - "properties": { - "result": { - "$ref": "#/definitions/eventbusEvent" - }, - "error": { - "$ref": "#/definitions/rpcStatus" - } - }, - "title": "Stream result of eventbusEvent" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "tags": [ - "EventsService" - ] - } - }, "/handsfree": { "post": { "operationId": "HandsfreeService_Send", @@ -3076,8 +3045,8 @@ "eventbusEvent": { "type": "object", "properties": { - "eventType": { - "$ref": "#/definitions/eventbusEventType" + "eventKind": { + "$ref": "#/definitions/eventbusEventKind" }, "account": { "$ref": "#/definitions/accountsAccount" @@ -3093,7 +3062,7 @@ } } }, - "eventbusEventType": { + "eventbusEventKind": { "type": "string", "enum": [ "NONE", diff --git a/eventbus/eventbus.pb.go b/eventbus/eventbus.pb.go index 9fbcd3d..ec74bca 100644 --- a/eventbus/eventbus.pb.go +++ b/eventbus/eventbus.pb.go @@ -26,24 +26,24 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type EventType int32 +type EventKind int32 const ( - EventType_NONE EventType = 0 - EventType_ACCOUNT_CREATE EventType = 1 - EventType_ACCOUNT_UPDATE EventType = 2 - EventType_ACCOUNT_DELETE EventType = 3 - EventType_NAMESPACE_CREATE EventType = 4 - EventType_NAMESPACE_UPDATE EventType = 5 - EventType_NAMESPACE_DELETE EventType = 6 - EventType_DEVICE_CREATE EventType = 7 - EventType_DEVICE_UPDATE EventType = 8 - EventType_DEVICE_DELETE EventType = 9 + EventKind_NONE EventKind = 0 + EventKind_ACCOUNT_CREATE EventKind = 1 + EventKind_ACCOUNT_UPDATE EventKind = 2 + EventKind_ACCOUNT_DELETE EventKind = 3 + EventKind_NAMESPACE_CREATE EventKind = 4 + EventKind_NAMESPACE_UPDATE EventKind = 5 + EventKind_NAMESPACE_DELETE EventKind = 6 + EventKind_DEVICE_CREATE EventKind = 7 + EventKind_DEVICE_UPDATE EventKind = 8 + EventKind_DEVICE_DELETE EventKind = 9 ) -// Enum value maps for EventType. +// Enum value maps for EventKind. var ( - EventType_name = map[int32]string{ + EventKind_name = map[int32]string{ 0: "NONE", 1: "ACCOUNT_CREATE", 2: "ACCOUNT_UPDATE", @@ -55,7 +55,7 @@ var ( 8: "DEVICE_UPDATE", 9: "DEVICE_DELETE", } - EventType_value = map[string]int32{ + EventKind_value = map[string]int32{ "NONE": 0, "ACCOUNT_CREATE": 1, "ACCOUNT_UPDATE": 2, @@ -69,30 +69,30 @@ var ( } ) -func (x EventType) Enum() *EventType { - p := new(EventType) +func (x EventKind) Enum() *EventKind { + p := new(EventKind) *p = x return p } -func (x EventType) String() string { +func (x EventKind) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (EventType) Descriptor() protoreflect.EnumDescriptor { +func (EventKind) Descriptor() protoreflect.EnumDescriptor { return file_eventbus_eventbus_proto_enumTypes[0].Descriptor() } -func (EventType) Type() protoreflect.EnumType { +func (EventKind) Type() protoreflect.EnumType { return &file_eventbus_eventbus_proto_enumTypes[0] } -func (x EventType) Number() protoreflect.EnumNumber { +func (x EventKind) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use EventType.Descriptor instead. -func (EventType) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use EventKind.Descriptor instead. +func (EventKind) EnumDescriptor() ([]byte, []int) { return file_eventbus_eventbus_proto_rawDescGZIP(), []int{0} } @@ -101,7 +101,7 @@ type Event struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EventType EventType `protobuf:"varint,1,opt,name=event_type,json=eventType,proto3,enum=infinimesh.eventbus.EventType" json:"event_type,omitempty"` + EventKind EventKind `protobuf:"varint,1,opt,name=event_kind,json=eventKind,proto3,enum=infinimesh.eventbus.EventKind" json:"event_kind,omitempty"` // Types that are assignable to Entity: // // *Event_Account @@ -143,11 +143,11 @@ func (*Event) Descriptor() ([]byte, []int) { return file_eventbus_eventbus_proto_rawDescGZIP(), []int{0} } -func (x *Event) GetEventType() EventType { +func (x *Event) GetEventKind() EventKind { if x != nil { - return x.EventType + return x.EventKind } - return EventType_NONE + return EventKind_NONE } func (m *Event) GetEntity() isEvent_Entity { @@ -224,10 +224,10 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x02, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x3d, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x41, 0x63, 0x63, @@ -244,7 +244,7 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x42, 0x08, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2a, 0xcc, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, + 0x6e, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x4f, @@ -256,27 +256,25 @@ var file_eventbus_eventbus_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x07, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x45, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x44, - 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x73, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, + 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x09, 0x32, 0x59, 0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x62, 0x75, 0x73, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, - 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x42, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, - 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, - 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, - 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, - 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, - 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, - 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x30, 0x01, 0x42, 0xbb, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x66, 0x69, 0x6e, + 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x42, 0x0d, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x69, + 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x62, 0x75, 0x73, 0xa2, 0x02, 0x03, 0x49, 0x45, 0x58, 0xaa, 0x02, 0x13, 0x49, 0x6e, + 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, + 0x73, 0xca, 0x02, 0x13, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0xe2, 0x02, 0x1f, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, + 0x6d, 0x65, 0x73, 0x68, 0x5c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x49, 0x6e, 0x66, 0x69, + 0x6e, 0x69, 0x6d, 0x65, 0x73, 0x68, 0x3a, 0x3a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x62, 0x75, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -294,7 +292,7 @@ func file_eventbus_eventbus_proto_rawDescGZIP() []byte { var file_eventbus_eventbus_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_eventbus_eventbus_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_eventbus_eventbus_proto_goTypes = []interface{}{ - (EventType)(0), // 0: infinimesh.eventbus.EventType + (EventKind)(0), // 0: infinimesh.eventbus.EventKind (*Event)(nil), // 1: infinimesh.eventbus.Event (*accounts.Account)(nil), // 2: infinimesh.node.accounts.Account (*namespaces.Namespace)(nil), // 3: infinimesh.node.namespaces.Namespace @@ -303,7 +301,7 @@ var file_eventbus_eventbus_proto_goTypes = []interface{}{ (*node.EmptyMessage)(nil), // 6: infinimesh.node.EmptyMessage } var file_eventbus_eventbus_proto_depIdxs = []int32{ - 0, // 0: infinimesh.eventbus.Event.event_type:type_name -> infinimesh.eventbus.EventType + 0, // 0: infinimesh.eventbus.Event.event_kind:type_name -> infinimesh.eventbus.EventKind 2, // 1: infinimesh.eventbus.Event.account:type_name -> infinimesh.node.accounts.Account 3, // 2: infinimesh.eventbus.Event.namespace:type_name -> infinimesh.node.namespaces.Namespace 4, // 3: infinimesh.eventbus.Event.device:type_name -> infinimesh.node.devices.Device diff --git a/eventbus/eventbus.pb.gw.go b/eventbus/eventbus.pb.gw.go deleted file mode 100644 index b4d2524..0000000 --- a/eventbus/eventbus.pb.gw.go +++ /dev/null @@ -1,137 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: eventbus/eventbus.proto - -/* -Package eventbus is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package eventbus - -import ( - "context" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "github.com/infinimesh/proto/node" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join - -func request_EventsService_Subscribe_0(ctx context.Context, marshaler runtime.Marshaler, client EventsServiceClient, req *http.Request, pathParams map[string]string) (EventsService_SubscribeClient, runtime.ServerMetadata, error) { - var protoReq node.EmptyMessage - var metadata runtime.ServerMetadata - - stream, err := client.Subscribe(ctx, &protoReq) - if err != nil { - return nil, metadata, err - } - header, err := stream.Header() - if err != nil { - return nil, metadata, err - } - metadata.HeaderMD = header - return stream, metadata, nil - -} - -// RegisterEventsServiceHandlerServer registers the http handlers for service EventsService to "mux". -// UnaryRPC :call EventsServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEventsServiceHandlerFromEndpoint instead. -func RegisterEventsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EventsServiceServer) error { - - mux.Handle("GET", pattern_EventsService_Subscribe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") - _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - }) - - return nil -} - -// RegisterEventsServiceHandlerFromEndpoint is same as RegisterEventsServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterEventsServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterEventsServiceHandler(ctx, mux, conn) -} - -// RegisterEventsServiceHandler registers the http handlers for service EventsService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterEventsServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterEventsServiceHandlerClient(ctx, mux, NewEventsServiceClient(conn)) -} - -// RegisterEventsServiceHandlerClient registers the http handlers for service EventsService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EventsServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EventsServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "EventsServiceClient" to call the correct interceptors. -func RegisterEventsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EventsServiceClient) error { - - mux.Handle("GET", pattern_EventsService_Subscribe_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/infinimesh.eventbus.EventsService/Subscribe", runtime.WithHTTPPathPattern("/eventbus/stream")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_EventsService_Subscribe_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_EventsService_Subscribe_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_EventsService_Subscribe_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"eventbus", "stream"}, "")) -) - -var ( - forward_EventsService_Subscribe_0 = runtime.ForwardResponseStream -) diff --git a/eventbus/eventbus.pb.validate.go b/eventbus/eventbus.pb.validate.go index c225ad8..0636082 100644 --- a/eventbus/eventbus.pb.validate.go +++ b/eventbus/eventbus.pb.validate.go @@ -56,7 +56,7 @@ func (m *Event) validate(all bool) error { var errors []error - // no validation rules for EventType + // no validation rules for EventKind if all { switch v := interface{}(m.GetMeta()).(type) { diff --git a/eventbus/eventbus.proto b/eventbus/eventbus.proto index 4f7bc82..c7f0cba 100644 --- a/eventbus/eventbus.proto +++ b/eventbus/eventbus.proto @@ -9,7 +9,7 @@ import "node/node.proto"; import "google/protobuf/struct.proto"; import "google/api/annotations.proto"; -enum EventType{ +enum EventKind{ NONE = 0; ACCOUNT_CREATE = 1; ACCOUNT_UPDATE = 2; @@ -23,7 +23,7 @@ enum EventType{ } message Event { - EventType event_type = 1; + EventKind event_kind = 1; oneof entity { node.accounts.Account account = 2; node.namespaces.Namespace namespace = 3; @@ -33,7 +33,5 @@ message Event { } service EventsService{ - rpc Subscribe (node.EmptyMessage) returns (stream Event){ - option (google.api.http) = {get: "/eventbus/stream"}; - } + rpc Subscribe (node.EmptyMessage) returns (stream Event); } \ No newline at end of file From 0b030b75b25e65bf94518745c85a842dc1c8b985 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:11:30 +0000 Subject: [PATCH 6/6] Continuous Integration Build Protobuf Client Libraries for ES --- build/es/eventbus/eventbus_pb.d.ts | 8 ++++---- build/es/eventbus/eventbus_pb.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/es/eventbus/eventbus_pb.d.ts b/build/es/eventbus/eventbus_pb.d.ts index 628f0c1..605cf40 100644 --- a/build/es/eventbus/eventbus_pb.d.ts +++ b/build/es/eventbus/eventbus_pb.d.ts @@ -10,9 +10,9 @@ import type { Namespace } from "../node/namespaces/namespaces_pb.js"; import type { Device } from "../node/devices/devices_pb.js"; /** - * @generated from enum infinimesh.eventbus.EventType + * @generated from enum infinimesh.eventbus.EventKind */ -export declare enum EventType { +export declare enum EventKind { /** * @generated from enum value: NONE = 0; */ @@ -69,9 +69,9 @@ export declare enum EventType { */ export declare class Event extends Message { /** - * @generated from field: infinimesh.eventbus.EventType event_type = 1; + * @generated from field: infinimesh.eventbus.EventKind event_kind = 1; */ - eventType: EventType; + eventKind: EventKind; /** * @generated from oneof infinimesh.eventbus.Event.entity diff --git a/build/es/eventbus/eventbus_pb.js b/build/es/eventbus/eventbus_pb.js index a33bca9..fffbe60 100644 --- a/build/es/eventbus/eventbus_pb.js +++ b/build/es/eventbus/eventbus_pb.js @@ -9,10 +9,10 @@ import { Namespace } from "../node/namespaces/namespaces_pb.js"; import { Device } from "../node/devices/devices_pb.js"; /** - * @generated from enum infinimesh.eventbus.EventType + * @generated from enum infinimesh.eventbus.EventKind */ -export const EventType = proto3.makeEnum( - "infinimesh.eventbus.EventType", +export const EventKind = proto3.makeEnum( + "infinimesh.eventbus.EventKind", [ {no: 0, name: "NONE"}, {no: 1, name: "ACCOUNT_CREATE"}, @@ -33,7 +33,7 @@ export const EventType = proto3.makeEnum( export const Event = proto3.makeMessageType( "infinimesh.eventbus.Event", () => [ - { no: 1, name: "event_type", kind: "enum", T: proto3.getEnumType(EventType) }, + { no: 1, name: "event_kind", kind: "enum", T: proto3.getEnumType(EventKind) }, { no: 2, name: "account", kind: "message", T: Account, oneof: "entity" }, { no: 3, name: "namespace", kind: "message", T: Namespace, oneof: "entity" }, { no: 4, name: "device", kind: "message", T: Device, oneof: "entity" },