public void SucceedWithExpiration() { var apiCall = ApiBidirectionalStreamingCall.Create <int, int>( callOptions => null, CallSettings.FromCallTiming(CallTiming.FromExpiration(Expiration.FromTimeout(TimeSpan.FromSeconds(100)))), new BidirectionalStreamingSettings(100), new FakeClock()); Assert.Null(apiCall.Call(null)); }
public void FailWithRetry() { var apiCall = ApiBidirectionalStreamingCall.Create <int, int>( callOptions => null, CallSettings.FromRetry(new RetrySettings(5, TimeSpan.Zero, TimeSpan.Zero, 1.0, e => false, RetrySettings.RandomJitter)), new BidirectionalStreamingSettings(100), new FakeClock()); Assert.Throws <InvalidOperationException>(() => apiCall.Call(null)); }
public void FailWithRetry() { var apiCall = ApiBidirectionalStreamingCall.Create <int, int>( callOptions => null, CallSettings.FromCallTiming(CallTiming.FromRetry(new RetrySettings( new BackoffSettings(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(100), 2.0), new BackoffSettings(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(100), 2.0), Expiration.FromTimeout(TimeSpan.FromSeconds(100))))), new BidirectionalStreamingSettings(100), new FakeClock()); Assert.Throws <InvalidOperationException>(() => apiCall.Call(null)); }
/// <summary> /// Constructs a client wrapper for the Speech service, with the specified gRPC client and settings. /// </summary> /// <param name="grpcClient">The underlying gRPC client.</param> /// <param name="settings">The base <see cref="SpeechSettings"/> used within this client </param> public SpeechClientImpl(Speech.SpeechClient grpcClient, SpeechSettings settings) { this.GrpcClient = grpcClient; SpeechSettings effectiveSettings = settings ?? SpeechSettings.GetDefault(); LongRunningOperationsClient = new OperationsClientImpl( grpcClient.CreateOperationsClient(), effectiveSettings.LongRunningOperationsSettings); _clientHelper = new ClientHelper(effectiveSettings); _callSyncRecognize = _clientHelper.BuildApiCall <SyncRecognizeRequest, SyncRecognizeResponse>( GrpcClient.SyncRecognizeAsync, GrpcClient.SyncRecognize, effectiveSettings.SyncRecognizeSettings); _callAsyncRecognize = _clientHelper.BuildApiCall <AsyncRecognizeRequest, Operation>( GrpcClient.AsyncRecognizeAsync, GrpcClient.AsyncRecognize, effectiveSettings.AsyncRecognizeSettings); _callStreamingRecognize = _clientHelper.BuildApiCall <StreamingRecognizeRequest, StreamingRecognizeResponse>( GrpcClient.StreamingRecognize, effectiveSettings.StreamingRecognizeSettings, effectiveSettings.StreamingRecognizeStreamingSettings); }
public void WithLogging() { var logger = new MemoryLogger("category"); var apiCall = ApiBidirectionalStreamingCall.Create <int, int>( "BidiStreamingMethod", callOptions => null, null, new BidirectionalStreamingSettings(100), new FakeClock()).WithLogging(logger); apiCall.Call(null); var logs = logger.ListLogEntries(); var entry = Assert.Single(logger.ListLogEntries()); Assert.Contains("BidiStreamingMethod", entry.Message); }
/// <summary> /// Constructs a client wrapper for the Speech service, with the specified gRPC client and settings. /// </summary> /// <param name="grpcClient">The underlying gRPC client.</param> /// <param name="settings">The base <see cref="SpeechSettings"/> used within this client </param> public SpeechClientImpl(Speech.SpeechClient grpcClient, SpeechSettings settings) { GrpcClient = grpcClient; SpeechSettings effectiveSettings = settings ?? SpeechSettings.GetDefault(); ClientHelper clientHelper = new ClientHelper(effectiveSettings); LongRunningRecognizeOperationsClient = new OperationsClientImpl( grpcClient.CreateOperationsClient(), effectiveSettings.LongRunningRecognizeOperationsSettings); _callRecognize = clientHelper.BuildApiCall <RecognizeRequest, RecognizeResponse>( GrpcClient.RecognizeAsync, GrpcClient.Recognize, effectiveSettings.RecognizeSettings); _callLongRunningRecognize = clientHelper.BuildApiCall <LongRunningRecognizeRequest, Operation>( GrpcClient.LongRunningRecognizeAsync, GrpcClient.LongRunningRecognize, effectiveSettings.LongRunningRecognizeSettings); _callStreamingRecognize = clientHelper.BuildApiCall <StreamingRecognizeRequest, StreamingRecognizeResponse>( GrpcClient.StreamingRecognize, effectiveSettings.StreamingRecognizeSettings, effectiveSettings.StreamingRecognizeStreamingSettings); OnConstruction(grpcClient, effectiveSettings, clientHelper); }