private async void gRPCStartIPCTry() { //Config retry var methodConfig = new MethodConfig { Names = { MethodName.Default }, RetryPolicy = new RetryPolicy { MaxAttempts = 10, InitialBackoff = TimeSpan.FromSeconds(10), MaxBackoff = TimeSpan.FromSeconds(100), BackoffMultiplier = 1.5, RetryableStatusCodes = { Grpc.Core.StatusCode.Unavailable } } }; AppendText("Starting IPC gRPC"); var SocketPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "socket.tmp"); AppendText($"Tmp path is {SocketPath}"); var channel = GrpcConnectionFactory.CreateUdsChannel(methodConfig); var client = new Greeter.GreeterClient(channel); var response = await client.SayHelloAsync(new HelloRequest { Name = "First IPC gRPC" }); AppendText(response.Message); }
public void SetUp() { taskContext = new JoinableTaskContext(); mockMemoryMappedFileFactory = Substitute.For <MemoryMappedFileFactory>(); transportSessionFactory = new LldbTransportSession.Factory(mockMemoryMappedFileFactory); mockManagedProcessFactory = Substitute.For <ManagedProcess.Factory>(); mockGrpcCallInvoker = Substitute.ForPartsOf <PipeCallInvoker>(_numGrpcPipePairs); mockGrpcCallInvokerFactory = Substitute.For <PipeCallInvokerFactory>(); mockGrpcCallInvokerFactory.Create().Returns(mockGrpcCallInvoker); mockGrpcConnectionFactory = Substitute.For <GrpcConnectionFactory>(); optionPageGrid = Substitute.For <IExtensionOptions>(); service = new YetiVSIService(optionPageGrid); var mockVsOutputWindow = Substitute.For <IVsOutputWindow>(); mockDialogUtil = Substitute.For <IDialogUtil>(); yetiDebugTransport = new YetiDebugTransport(taskContext, transportSessionFactory, mockGrpcCallInvokerFactory, mockGrpcConnectionFactory, onAsyncRpcCompleted: null, managedProcessFactory: mockManagedProcessFactory, dialogUtil: mockDialogUtil, vsOutputWindow: mockVsOutputWindow, yetiVSIService: service); abortError = null; yetiDebugTransport.OnStop += e => { abortError = e; }; }
protected void BaseSetUp() { Assert.IsNull(serverInfo); var grpcConnectionFactory = new GrpcConnectionFactory(new JoinableTaskContext().Factory); serverInfo = CreateServer(new PipeCallInvokerFactory(), grpcConnectionFactory); exceptions = new List <ExceptionDispatchInfo>(); // Store RPC exceptions keeping stack trace. Connection.RpcException += e => exceptions.Add(ExceptionDispatchInfo.Capture(e)); // Make sure everything gets deleted immediately. We're checking this on shutdown! Connection.BulkDeleteBatchSize = 1; }
private ServerInfo CreateServer( PipeCallInvokerFactory callInvokerFactory, GrpcConnectionFactory connectionFactory) { PipeCallInvoker callInvoker = callInvokerFactory.Create(); GrpcConnection connection = connectionFactory.Create(callInvoker); string[] inPipeHandles, outPipeHandles; callInvoker.GetClientPipeHandles(out inPipeHandles, out outPipeHandles); // Note: The client's out handles are the server's in handles and vice versa. PipeServiceBinder server = new PipeServiceBinder(outPipeHandles, inPipeHandles); var stores = new RemoteObjectStores(); var mockFactories = new LldbMockFactories(); BindServices(server, stores, mockFactories); server.Start(); return(new ServerInfo(server, callInvoker, connection, stores, mockFactories)); }
public YetiDebugTransport(JoinableTaskContext taskContext, LldbTransportSession.Factory transportSessionFactory, PipeCallInvokerFactory grpcCallInvokerFactory, GrpcConnectionFactory grpcConnectionFactory, Action onAsyncRpcCompleted, ManagedProcess.Factory managedProcessFactory, IDialogUtil dialogUtil, IVsOutputWindow vsOutputWindow, IYetiVSIService yetiVSIService) { taskContext.ThrowIfNotOnMainThread(); this.taskContext = taskContext; this.grpcCallInvokerFactory = grpcCallInvokerFactory; this.grpcConnectionFactory = grpcConnectionFactory; this.onAsyncRpcCompleted = onAsyncRpcCompleted; this.managedProcessFactory = managedProcessFactory; this.transportSessionFactory = transportSessionFactory; this.dialogUtil = dialogUtil; Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane; vsOutputWindow?.GetPane(ref debugPaneGuid, out debugPane); this.yetiVSIService = yetiVSIService; }
private async void gRPCIPCBigDataBothStreamTry() { Stopwatch sw1 = new Stopwatch(); Stopwatch sw2 = new Stopwatch(); sw1.Start(); try { AppendText("starting IPC big data Both Steam Calling..."); var channel = GrpcConnectionFactory.CreateUdsChannel(); var client = new StreamShoper.StreamShoperClient(channel); var cancelSource = new CancellationTokenSource(); var token = cancelSource.Token; var call = client.SendingBigDataPackage(null, null, token); AppendText("Start to send data..."); sw2.Start(); AppendText($"Parameters: Send Times is {SendTimes}, Package size is {packageSize}M"); for (int i = SendTimes; i >= 0; i--) { AppendText($"#From Client# the index is {i}"); var request = new BigDataRequest { DataType = $"index{i}" }; var strTmp = new string('A', (int)(1024 * 1024 * packageSize)); var size = ((double)Encoding.UTF8.GetByteCount(strTmp) / (1024 * 1024)).ToString("f3"); AppendText($"Per item size is {size}M"); var times = 1; // total ~1M while (times > 0) { request.Content.Add(strTmp); times--; } await call.RequestStream.WriteAsync(request); await call.ResponseStream.MoveNext(token); var response = call.ResponseStream.Current; AppendText(response.Message); //AppendText("Waiting 2 seconds..."); //await Task.Delay(2000); //await Task.Delay(100); } AppendText("Starting cancelling..."); cancelSource.Cancel(); AppendText("Cancelled"); sw2.Stop(); } catch (Exception ex) { AppendText(ex.Message); AppendText("Exception, Cancelling..."); } sw1.Stop(); AppendText($"Sending data time cost:{sw2.Elapsed.TotalSeconds}"); AppendText($"Total time cost:{sw1.Elapsed.TotalSeconds}"); }