feat: implement real-time Pub/Sub alert broadcast system and update docs/GRPC.md

This commit is contained in:
2026-07-17 19:24:25 +09:00
parent 8bb11fe205
commit 20a818520c
6 changed files with 444 additions and 24 deletions
+157 -24
View File
@@ -613,6 +613,126 @@ func (x *DownloadRequest) GetFileName() string {
return ""
}
type AlertSubscription struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClientId string `protobuf:"bytes,1,opt,name=ClientId,proto3" json:"ClientId,omitempty"`
Topic string `protobuf:"bytes,2,opt,name=Topic,proto3" json:"Topic,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AlertSubscription) Reset() {
*x = AlertSubscription{}
mi := &file_protoapi_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AlertSubscription) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AlertSubscription) ProtoMessage() {}
func (x *AlertSubscription) ProtoReflect() protoreflect.Message {
mi := &file_protoapi_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AlertSubscription.ProtoReflect.Descriptor instead.
func (*AlertSubscription) Descriptor() ([]byte, []int) {
return file_protoapi_proto_rawDescGZIP(), []int{12}
}
func (x *AlertSubscription) GetClientId() string {
if x != nil {
return x.ClientId
}
return ""
}
func (x *AlertSubscription) GetTopic() string {
if x != nil {
return x.Topic
}
return ""
}
type AlertMessage struct {
state protoimpl.MessageState `protogen:"open.v1"`
AlertId string `protobuf:"bytes,1,opt,name=AlertId,proto3" json:"AlertId,omitempty"`
DeviceId string `protobuf:"bytes,2,opt,name=DeviceId,proto3" json:"DeviceId,omitempty"`
Message string `protobuf:"bytes,3,opt,name=Message,proto3" json:"Message,omitempty"`
Timestamp int64 `protobuf:"varint,4,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AlertMessage) Reset() {
*x = AlertMessage{}
mi := &file_protoapi_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AlertMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AlertMessage) ProtoMessage() {}
func (x *AlertMessage) ProtoReflect() protoreflect.Message {
mi := &file_protoapi_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AlertMessage.ProtoReflect.Descriptor instead.
func (*AlertMessage) Descriptor() ([]byte, []int) {
return file_protoapi_proto_rawDescGZIP(), []int{13}
}
func (x *AlertMessage) GetAlertId() string {
if x != nil {
return x.AlertId
}
return ""
}
func (x *AlertMessage) GetDeviceId() string {
if x != nil {
return x.DeviceId
}
return ""
}
func (x *AlertMessage) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *AlertMessage) GetTimestamp() int64 {
if x != nil {
return x.Timestamp
}
return 0
}
var File_protoapi_proto protoreflect.FileDescriptor
const file_protoapi_proto_rawDesc = "" +
@@ -652,7 +772,15 @@ const file_protoapi_proto_rawDesc = "" +
"\bFileList\x12#\n" +
"\x05Files\x18\x01 \x03(\v2\r.FileMetadataR\x05Files\"-\n" +
"\x0fDownloadRequest\x12\x1a\n" +
"\bFileName\x18\x01 \x01(\tR\bFileName2\x97\x02\n" +
"\bFileName\x18\x01 \x01(\tR\bFileName\"E\n" +
"\x11AlertSubscription\x12\x1a\n" +
"\bClientId\x18\x01 \x01(\tR\bClientId\x12\x14\n" +
"\x05Topic\x18\x02 \x01(\tR\x05Topic\"|\n" +
"\fAlertMessage\x12\x18\n" +
"\aAlertId\x18\x01 \x01(\tR\aAlertId\x12\x1a\n" +
"\bDeviceId\x18\x02 \x01(\tR\bDeviceId\x12\x18\n" +
"\aMessage\x18\x03 \x01(\tR\aMessage\x12\x1c\n" +
"\tTimestamp\x18\x04 \x01(\x03R\tTimestamp2\xcf\x02\n" +
"\n" +
"IoTService\x12&\n" +
"\aGetDate\x12\x10.RequestDateTime\x1a\t.DateTime\x123\n" +
@@ -663,7 +791,8 @@ const file_protoapi_proto_rawDesc = "" +
".FileChunk\x1a\r.UploadStatus(\x01\x12%\n" +
"\tListFiles\x12\r.EmptyRequest\x1a\t.FileList\x12.\n" +
"\fDownloadFile\x12\x10.DownloadRequest\x1a\n" +
".FileChunk0\x01B\x16Z\x14./protoapi/;protoapib\x06proto3"
".FileChunk0\x01\x126\n" +
"\x0fSubscribeAlerts\x12\x12.AlertSubscription\x1a\r.AlertMessage0\x01B\x16Z\x14./protoapi/;protoapib\x06proto3"
var (
file_protoapi_proto_rawDescOnce sync.Once
@@ -677,20 +806,22 @@ func file_protoapi_proto_rawDescGZIP() []byte {
return file_protoapi_proto_rawDescData
}
var file_protoapi_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_protoapi_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_protoapi_proto_goTypes = []any{
(*FileChunk)(nil), // 0: FileChunk
(*UploadStatus)(nil), // 1: UploadStatus
(*SensingData)(nil), // 2: SensingData
(*SensingResponse)(nil), // 3: SensingResponse
(*DateTime)(nil), // 4: DateTime
(*RequestDateTime)(nil), // 5: RequestDateTime
(*RequestPass)(nil), // 6: RequestPass
(*RandomPass)(nil), // 7: RandomPass
(*EmptyRequest)(nil), // 8: EmptyRequest
(*FileMetadata)(nil), // 9: FileMetadata
(*FileList)(nil), // 10: FileList
(*DownloadRequest)(nil), // 11: DownloadRequest
(*FileChunk)(nil), // 0: FileChunk
(*UploadStatus)(nil), // 1: UploadStatus
(*SensingData)(nil), // 2: SensingData
(*SensingResponse)(nil), // 3: SensingResponse
(*DateTime)(nil), // 4: DateTime
(*RequestDateTime)(nil), // 5: RequestDateTime
(*RequestPass)(nil), // 6: RequestPass
(*RandomPass)(nil), // 7: RandomPass
(*EmptyRequest)(nil), // 8: EmptyRequest
(*FileMetadata)(nil), // 9: FileMetadata
(*FileList)(nil), // 10: FileList
(*DownloadRequest)(nil), // 11: DownloadRequest
(*AlertSubscription)(nil), // 12: AlertSubscription
(*AlertMessage)(nil), // 13: AlertMessage
}
var file_protoapi_proto_depIdxs = []int32{
9, // 0: FileList.Files:type_name -> FileMetadata
@@ -700,14 +831,16 @@ var file_protoapi_proto_depIdxs = []int32{
0, // 4: IoTService.UploadFile:input_type -> FileChunk
8, // 5: IoTService.ListFiles:input_type -> EmptyRequest
11, // 6: IoTService.DownloadFile:input_type -> DownloadRequest
4, // 7: IoTService.GetDate:output_type -> DateTime
3, // 8: IoTService.UpdateSensingData:output_type -> SensingResponse
7, // 9: IoTService.GetRandomPass:output_type -> RandomPass
1, // 10: IoTService.UploadFile:output_type -> UploadStatus
10, // 11: IoTService.ListFiles:output_type -> FileList
0, // 12: IoTService.DownloadFile:output_type -> FileChunk
7, // [7:13] is the sub-list for method output_type
1, // [1:7] is the sub-list for method input_type
12, // 7: IoTService.SubscribeAlerts:input_type -> AlertSubscription
4, // 8: IoTService.GetDate:output_type -> DateTime
3, // 9: IoTService.UpdateSensingData:output_type -> SensingResponse
7, // 10: IoTService.GetRandomPass:output_type -> RandomPass
1, // 11: IoTService.UploadFile:output_type -> UploadStatus
10, // 12: IoTService.ListFiles:output_type -> FileList
0, // 13: IoTService.DownloadFile:output_type -> FileChunk
13, // 14: IoTService.SubscribeAlerts:output_type -> AlertMessage
8, // [8:15] is the sub-list for method output_type
1, // [1:8] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
@@ -724,7 +857,7 @@ func file_protoapi_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_protoapi_proto_rawDesc), len(file_protoapi_proto_rawDesc)),
NumEnums: 0,
NumMessages: 12,
NumMessages: 14,
NumExtensions: 0,
NumServices: 1,
},