Пример #1
0
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs,
                                                                   LookupInOptions options, IInternalSpan span)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key      = id,
                Builder  = builder,
                Cid      = Cid,
                CName    = Name,
                DocFlags = options.AccessDeletedValue ? SubdocDocFlags.AccessDeleted : SubdocDocFlags.None,
                Span     = span
            };

            _operationConfigurator.Configure(lookup, options);

            await RetryUntilTimeoutOrSuccessAsync(options.TokenValue, options.TimeoutValue, lookup).ConfigureAwait(false);

            return(lookup);
        }
        public static Task <ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id,
                                                           IEnumerable <LookupInSpec> specs, Action <LookupInOptions> configureOptions)
        {
            var options = new LookupInOptions();

            configureOptions(options);

            return(collection.LookupInAsync(id, specs, options));
        }
        public static Task <ILookupInResult <TDocument> > LookupInAsync <TDocument>(this ICouchbaseCollection collection,
                                                                                    string id, Action <LookupInSpecBuilder <TDocument> > configureBuilder,
                                                                                    Action <LookupInOptions> configureOptions)
        {
            var options = new LookupInOptions();

            configureOptions(options);

            return(collection.LookupInAsync(id, configureBuilder, options));
        }
        public static Task <ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id,
                                                           Action <LookupInSpecBuilder> configureBuilder, Action <LookupInOptions> configureOptions)
        {
            var builder = new LookupInSpecBuilder();

            configureBuilder(builder);

            var options = new LookupInOptions();

            configureOptions(options);

            return(collection.LookupInAsync(id, builder.Specs, options));
        }
Пример #5
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;
            }
        }
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs, LookupInOptions options)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key        = id,
                Builder    = builder,
                Cid        = Cid,
                CName      = Name,
                Transcoder = _transcoder
            };

            await _bucket.RetryAsync(lookup, options.TokenValue, options.TimeoutValue).ConfigureAwait(false);

            return(lookup);
        }
Пример #7
0
        public static Task <ILookupInResult> LookupInAsync(this ICouchbaseCollection collection, string id,
                                                           Action <LookupInSpecBuilder> configureBuilder, LookupInOptions options)
        {
            var lookupInSpec = new LookupInSpecBuilder();

            configureBuilder(lookupInSpec);

            return(collection.LookupInAsync(id, lookupInSpec.Specs, options));
        }
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <OperationSpec> specs, LookupInOptions options)
        {
            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.Expiry)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key        = id,
                Builder    = builder,
                Cid        = Cid,
                Transcoder = _transcoder
            };

            await _bucket.RetryAsync(lookup, options.Token, options.Timeout);

            return(lookup);
        }
 public async Task <ILookupInResult> LookupInAsync(string id, IEnumerable <OperationSpec> specs, LookupInOptions options)
 {
     using (var lookup = await ExecuteLookupIn(id, specs, options))
     {
         return(new LookupInResult(lookup.ExtractData(), lookup.Cas, null));
     }
 }