예제 #1
0
        private async Task <uint?> GetCidAsync(string fullyQualifiedName, bool sendAsBody, bool retryIfFailure)
        {
            using var rootSpan = RootSpan(OuterRequestSpans.ServiceSpan.Internal.GetCid);
            using var getCid   = new GetCid
                  {
                      Opaque = SequenceGenerator.GetNext(),
                      Span   = rootSpan,
                  };

            if (sendAsBody)
            {
                getCid.Content = fullyQualifiedName;
            }
            else
            {
                getCid.Key = fullyQualifiedName;
            }

            var options = new GetOptions();

            _operationConfigurator.Configure(getCid, options.Transcoder(_rawStringTranscoder));
            using var ctp = CreateRetryTimeoutCancellationTokenSource(options, getCid);
            if (retryIfFailure)
            {
                await _bucket.RetryAsync(getCid, ctp.TokenPair).ConfigureAwait(false);
            }
            else
            {
                await _bucket.SendAsync(getCid, ctp.TokenPair).ConfigureAwait(false);
            }

            var resultWithValue = getCid.GetValueAsUint();

            return(resultWithValue);
        }
예제 #2
0
        private async Task <uint?> GetCidAsync(string fullyQualifiedName, bool sendAsBody)
        {
            using var rootSpan = RootSpan(OuterRequestSpans.ServiceSpan.Internal.GetCid);
            using var getCid   = new GetCid
                  {
                      Opaque = SequenceGenerator.GetNext(),
                      Span   = rootSpan,
                  };

            if (sendAsBody)
            {
                getCid.Content = fullyQualifiedName;
            }
            else
            {
                getCid.Key = fullyQualifiedName;
            }

            _operationConfigurator.Configure(getCid, new GetOptions().Transcoder(_rawStringTranscoder));
            await _bucket.RetryAsync(getCid).ConfigureAwait(false);

            var resultWithValue = getCid.GetValueAsUint();

            return(resultWithValue);
        }
예제 #3
0
        public void Test_GetCid_WithValue()
        {
            var packet = new byte[]
            {
                0x18, 0xbb, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1a,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x17
            };

            var response = MemoryPool <byte> .Shared.RentAndSlice(packet.Length);

            packet.AsMemory(0, packet.Length).CopyTo(response.Memory);
            var op = new GetCid()
            {
                Transcoder = new LegacyTranscoder()
            };

            op.Read(response);

            var result = op.GetValueAsUint();

            Assert.NotNull(result);
            Assert.Equal(0x17u, result);
        }