Beispiel #1
0
        internal static async Task <Manifest> GetManifest(this IConnection connection)
        {
            var completionSource = new TaskCompletionSource <IMemoryOwner <byte> >();

            using (var manifestOp = new GetManifest
            {
                Converter = new DefaultConverter(),
                Transcoder = new DefaultTranscoder(new DefaultConverter()),
                Opaque = SequenceGenerator.GetNext(),
                Completed = s =>
                {
                    completionSource.TrySetResult(s.ExtractData());
                    return(completionSource.Task);
                }
            })
            {
                await manifestOp.SendAsync(connection).ConfigureAwait(false);

                var manifestBytes = await completionSource.Task.ConfigureAwait(false);

                await manifestOp.ReadAsync(manifestBytes).ConfigureAwait(false);

                var manifestResult = manifestOp.GetResultWithValue();
                return(manifestResult.Content);
            }
        }
Beispiel #2
0
        private async Task GetManifest(IConnection connection)
        {
            var completionSource = new TaskCompletionSource <IMemoryOwner <byte> >();

            using (var manifestOp = new GetManifest
            {
                Converter = new DefaultConverter(),
                Transcoder = new DefaultTranscoder(new DefaultConverter()),
                Opaque = SequenceGenerator.GetNext(),
                Completed = s =>
                {
                    //Status will be Success if bucket select was bueno
                    completionSource.SetResult(s.ExtractData());
                    return(completionSource.Task);
                }
            })
            {
                await manifestOp.SendAsync(connection).ConfigureAwait(false);

                var manifestBytes = await completionSource.Task.ConfigureAwait(false);

                await manifestOp.ReadAsync(manifestBytes).ConfigureAwait(false);

                var manifestResult = manifestOp.GetResultWithValue();
                _manifest = manifestResult.Content;
            }

            //warmup the scopes/collections and cache them
            foreach (var scopeDef in _manifest.scopes)
            {
                var collections = new List <ICollection>();
                foreach (var collectionDef in scopeDef.collections)
                {
                    collections.Add(new CouchbaseCollection(this,
                                                            Convert.ToUInt32(collectionDef.uid), collectionDef.name));
                }

                _scopes.TryAdd(scopeDef.name, new Scope(scopeDef.name, scopeDef.uid, collections, this));
            }
        }