feat: implement real-time Pub/Sub alert broadcast system and update docs/GRPC.md
This commit is contained in:
@@ -25,6 +25,7 @@ const (
|
||||
IoTService_UploadFile_FullMethodName = "/IoTService/UploadFile"
|
||||
IoTService_ListFiles_FullMethodName = "/IoTService/ListFiles"
|
||||
IoTService_DownloadFile_FullMethodName = "/IoTService/DownloadFile"
|
||||
IoTService_SubscribeAlerts_FullMethodName = "/IoTService/SubscribeAlerts"
|
||||
)
|
||||
|
||||
// IoTServiceClient is the client API for IoTService service.
|
||||
@@ -37,6 +38,7 @@ type IoTServiceClient interface {
|
||||
UploadFile(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[FileChunk, UploadStatus], error)
|
||||
ListFiles(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*FileList, error)
|
||||
DownloadFile(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[FileChunk], error)
|
||||
SubscribeAlerts(ctx context.Context, in *AlertSubscription, opts ...grpc.CallOption) (grpc.ServerStreamingClient[AlertMessage], error)
|
||||
}
|
||||
|
||||
type ioTServiceClient struct {
|
||||
@@ -119,6 +121,25 @@ func (c *ioTServiceClient) DownloadFile(ctx context.Context, in *DownloadRequest
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type IoTService_DownloadFileClient = grpc.ServerStreamingClient[FileChunk]
|
||||
|
||||
func (c *ioTServiceClient) SubscribeAlerts(ctx context.Context, in *AlertSubscription, opts ...grpc.CallOption) (grpc.ServerStreamingClient[AlertMessage], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &IoTService_ServiceDesc.Streams[2], IoTService_SubscribeAlerts_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[AlertSubscription, AlertMessage]{ClientStream: 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
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type IoTService_SubscribeAlertsClient = grpc.ServerStreamingClient[AlertMessage]
|
||||
|
||||
// IoTServiceServer is the server API for IoTService service.
|
||||
// All implementations must embed UnimplementedIoTServiceServer
|
||||
// for forward compatibility.
|
||||
@@ -129,6 +150,7 @@ type IoTServiceServer interface {
|
||||
UploadFile(grpc.ClientStreamingServer[FileChunk, UploadStatus]) error
|
||||
ListFiles(context.Context, *EmptyRequest) (*FileList, error)
|
||||
DownloadFile(*DownloadRequest, grpc.ServerStreamingServer[FileChunk]) error
|
||||
SubscribeAlerts(*AlertSubscription, grpc.ServerStreamingServer[AlertMessage]) error
|
||||
mustEmbedUnimplementedIoTServiceServer()
|
||||
}
|
||||
|
||||
@@ -157,6 +179,9 @@ func (UnimplementedIoTServiceServer) ListFiles(context.Context, *EmptyRequest) (
|
||||
func (UnimplementedIoTServiceServer) DownloadFile(*DownloadRequest, grpc.ServerStreamingServer[FileChunk]) error {
|
||||
return status.Error(codes.Unimplemented, "method DownloadFile not implemented")
|
||||
}
|
||||
func (UnimplementedIoTServiceServer) SubscribeAlerts(*AlertSubscription, grpc.ServerStreamingServer[AlertMessage]) error {
|
||||
return status.Error(codes.Unimplemented, "method SubscribeAlerts not implemented")
|
||||
}
|
||||
func (UnimplementedIoTServiceServer) mustEmbedUnimplementedIoTServiceServer() {}
|
||||
func (UnimplementedIoTServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -268,6 +293,17 @@ func _IoTService_DownloadFile_Handler(srv interface{}, stream grpc.ServerStream)
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type IoTService_DownloadFileServer = grpc.ServerStreamingServer[FileChunk]
|
||||
|
||||
func _IoTService_SubscribeAlerts_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(AlertSubscription)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(IoTServiceServer).SubscribeAlerts(m, &grpc.GenericServerStream[AlertSubscription, AlertMessage]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type IoTService_SubscribeAlertsServer = grpc.ServerStreamingServer[AlertMessage]
|
||||
|
||||
// IoTService_ServiceDesc is the grpc.ServiceDesc for IoTService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -303,6 +339,11 @@ var IoTService_ServiceDesc = grpc.ServiceDesc{
|
||||
Handler: _IoTService_DownloadFile_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "SubscribeAlerts",
|
||||
Handler: _IoTService_SubscribeAlerts_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "protoapi.proto",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user