コード例 #1
0
        private static void StartRpcServer(CliArgs args)
        {
            // Create a factory used to instantiate all the service implementations
            // that are needed to initialize the server.
            Factory factory = new Factory("config/application.conf");

            // Build a gRPC server instance.
            ServerBuilder serverBuilder = ServerBuilder
                                          .ForPort(args.port)
                                          .ReportErrorDetails()
                                          .WithAccountService(factory.AccountService())
                                          .WithAccountLinkingService(factory.AccountLinkingService())
                                          .WithTransferService(factory.TransferService())
                                          .WithStorageService(factory.StorageService())
                                          .WithAccountManagementService(factory.AccountManagementService())
                                          .WithConsentManagementService(factory.ConsentManagementService())
                                          .WithNotificationService(factory.NotificationService());

            if (args.useSsl)
            {
                serverBuilder.WithTls(
                    "config/tls/cert.pem",
                    "config/tls/key.pem",
                    "config/tls/trusted-certs.pem");
            }

            RpcServer server = serverBuilder.Build();

            // You will need to Ctrl-C to exit.
            server.Start();
            logger.Info("Hit return to stop the server ");
            Console.ReadKey();
            logger.Info("Stopping the server....");
            server.Close();
            logger.Info("Server stopped");
        }