GODT-2108: implement C++ Focus gRPC service client in bridge-gui.

This commit is contained in:
Xavier Michelon
2022-11-18 09:28:19 +01:00
committed by James Houlahan
parent 24a0ed41b9
commit 204e320df4
12 changed files with 1375 additions and 58 deletions

View File

@ -17,19 +17,18 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v3.19.4
// protoc-gen-go v1.28.0
// protoc v3.21.3
// source: focus.proto
package proto
import (
reflect "reflect"
sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
@ -89,8 +88,8 @@ func (x *VersionResponse) GetVersion() string {
var File_focus_proto protoreflect.FileDescriptor
var file_focus_proto_rawDesc = []byte{
0x0a, 0x0b, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f,
0x0a, 0x0b, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x66,
0x6f, 0x63, 0x75, 0x73, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x2b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18,
@ -101,7 +100,7 @@ var file_focus_proto_rawDesc = []byte{
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x12, 0x39, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x65, 0x72, 0x73,
0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x2e, 0x56, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x6e,
0x4d, 0x61, 0x69, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6e, 0x2d, 0x62, 0x72, 0x69, 0x64,
@ -124,14 +123,14 @@ func file_focus_proto_rawDescGZIP() []byte {
var file_focus_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_focus_proto_goTypes = []interface{}{
(*VersionResponse)(nil), // 0: proto.VersionResponse
(*VersionResponse)(nil), // 0: focus.VersionResponse
(*emptypb.Empty)(nil), // 1: google.protobuf.Empty
}
var file_focus_proto_depIdxs = []int32{
1, // 0: proto.Focus.Raise:input_type -> google.protobuf.Empty
1, // 1: proto.Focus.Version:input_type -> google.protobuf.Empty
1, // 2: proto.Focus.Raise:output_type -> google.protobuf.Empty
0, // 3: proto.Focus.Version:output_type -> proto.VersionResponse
1, // 0: focus.Focus.Raise:input_type -> google.protobuf.Empty
1, // 1: focus.Focus.Version:input_type -> google.protobuf.Empty
1, // 2: focus.Focus.Raise:output_type -> google.protobuf.Empty
0, // 3: focus.Focus.Version:output_type -> focus.VersionResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name

View File

@ -21,7 +21,7 @@ import "google/protobuf/empty.proto";
option go_package = "github.com/ProtonMail/proton-bridge/v2/internal/focus/proto";
package proto;
package focus; // ignored by Go, used as namespace name in C++.
//**********************************************************************************************************************
// Service Declaration

View File

@ -1,14 +1,13 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// - protoc v3.21.3
// source: focus.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
@ -38,7 +37,7 @@ func NewFocusClient(cc grpc.ClientConnInterface) FocusClient {
func (c *focusClient) Raise(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/proto.Focus/Raise", in, out, opts...)
err := c.cc.Invoke(ctx, "/focus.Focus/Raise", in, out, opts...)
if err != nil {
return nil, err
}
@ -47,7 +46,7 @@ func (c *focusClient) Raise(ctx context.Context, in *emptypb.Empty, opts ...grpc
func (c *focusClient) Version(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*VersionResponse, error) {
out := new(VersionResponse)
err := c.cc.Invoke(ctx, "/proto.Focus/Version", in, out, opts...)
err := c.cc.Invoke(ctx, "/focus.Focus/Version", in, out, opts...)
if err != nil {
return nil, err
}
@ -96,7 +95,7 @@ func _Focus_Raise_Handler(srv interface{}, ctx context.Context, dec func(interfa
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Focus/Raise",
FullMethod: "/focus.Focus/Raise",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(FocusServer).Raise(ctx, req.(*emptypb.Empty))
@ -114,7 +113,7 @@ func _Focus_Version_Handler(srv interface{}, ctx context.Context, dec func(inter
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Focus/Version",
FullMethod: "/focus.Focus/Version",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(FocusServer).Version(ctx, req.(*emptypb.Empty))
@ -126,7 +125,7 @@ func _Focus_Version_Handler(srv interface{}, ctx context.Context, dec func(inter
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Focus_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.Focus",
ServiceName: "focus.Focus",
HandlerType: (*FocusServer)(nil),
Methods: []grpc.MethodDesc{
{

View File

@ -89,6 +89,10 @@ func (service *Service) GetRaiseCh() <-chan struct{} {
// Close closes the service.
func (service *Service) Close() {
service.server.Stop()
close(service.raiseCh)
go func() {
// we do this in a goroutine, as on Windows, the gRPC shutdown may take minutes if something tries to
// interact with it in an invalid way (e.g. HTTP GET request from a Qt QNetworkManager instance).
service.server.Stop()
close(service.raiseCh)
}()
}