Ejemplo n.º 1
0
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs,
                                                                   LookupInOptions options, IRequestSpan span)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            //Get the collection ID
            await PopulateCidAsync().ConfigureAwait(false);

            //add the virtual xattr attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                specs = specs.Concat(new [] {
                    new LookupInSpec
                    {
                        Path      = VirtualXttrs.DocExpiryTime,
                        OpCode    = OpCode.SubGet,
                        PathFlags = SubdocPathFlags.Xattr,
                        DocFlags  = SubdocDocFlags.None
                    }
                });
            }

            var lookup = new MultiLookup <byte[]>(id, specs)
            {
                Cid      = Cid,
                CName    = Name,
                SName    = ScopeName,
                DocFlags = options.AccessDeletedValue ? SubdocDocFlags.AccessDeleted : SubdocDocFlags.None,
                Span     = span
            };

            try
            {
                _operationConfigurator.Configure(lookup, options);

                using var ctp = CreateRetryTimeoutCancellationTokenSource(options, lookup);
                await _bucket.RetryAsync(lookup, ctp.TokenPair).ConfigureAwait(false);

                return(lookup);
            }
            catch
            {
                // Make sure we cleanup the operation in the error case where it isn't returned
                lookup.Dispose();
                throw;
            }
        }