예제 #1
0
        public async Task Upsert <TKey>(TKey key, UpdateOperation[] updateOperations)
        {
            var updateRequest = new UpsertRequest <TKey>(
                SpaceId,
                key,
                updateOperations);

            await LogicalConnection.SendRequestWithEmptyResponse(updateRequest).ConfigureAwait(false);
        }
예제 #2
0
        public async Task <DataResponse <TTuple[]> > Update <TTuple, TKey>(TKey key, UpdateOperation[] updateOperations)
        {
            var updateRequest = new UpdateRequest <TKey>(
                SpaceId,
                Id,
                key,
                updateOperations);

            return(await LogicalConnection.SendRequest <UpdateRequest <TKey>, TTuple>(updateRequest).ConfigureAwait(false));
        }
예제 #3
0
        public async Task <DataResponse <TTuple[]> > Select <TKey, TTuple>(TKey key, SelectOptions options = null)
        {
            var selectRequest = new SelectRequest <TKey>(
                SpaceId,
                Id,
                options?.Limit ?? uint.MaxValue,
                options?.Offset ?? 0,
                options?.Iterator ?? Iterator.Eq,
                key);

            return(await LogicalConnection.SendRequest <SelectRequest <TKey>, TTuple>(selectRequest).ConfigureAwait(false));
        }
예제 #4
0
        public async Task <TTuple> Min <TTuple, TKey>(TKey key)
        {
            if (Type != IndexType.Tree)
            {
                throw ExceptionHelper.WrongIndexType("TREE", "min");
            }
            var iterator = key == null ? Iterator.Eq : Iterator.Ge;

            var selectPacket = new SelectRequest <TKey>(SpaceId, Id, 1, 0, iterator, key);

            var minResponse = await LogicalConnection.SendRequest <SelectRequest <TKey>, TTuple>(selectPacket).ConfigureAwait(false);

            return(minResponse.Data.SingleOrDefault());
        }
        public async Task Connect()
        {
            if (IsConnectedInternal())
            {
                return;
            }

            if (!_reconnectAvailable.WaitOne(_connectionTimeout))
            {
                throw ExceptionHelper.NotConnected();
            }

            try
            {
                if (IsConnectedInternal())
                {
                    return;
                }

                _connected.Reset();

                _clientOptions.LogWriter?.WriteLine($"{nameof(LogicalConnectionManager)}: Connecting...");

                var newConnection = new LogicalConnection(_clientOptions, _requestIdCounter);
                await newConnection.Connect().ConfigureAwait(false);;
                Interlocked.Exchange(ref _droppableLogicalConnection, newConnection)?.Dispose();

                _connected.Set();

                _clientOptions.LogWriter?.WriteLine($"{nameof(LogicalConnectionManager)}: Connected...");

                if (_pingCheckInterval > 0 && _timer == null)
                {
                    _timer = new Timer(x => CheckPing(), null, _pingTimerInterval, Timeout.Infinite);
                }
            }
            finally
            {
                _reconnectAvailable.Set();
            }
        }
예제 #6
0
        ///Note: there is no such method in specification http://tarantool.org/doc/book/box/box_index.html.
        ///But common sense, and sources https://github.com/tarantool/tarantool/blob/1.7/src/box/lua/index.c says that that method sould be
        public async Task <DataResponse <TTuple[]> > Replace <TTuple>(TTuple tuple)
        {
            var replaceRequest = new ReplaceRequest <TTuple>(SpaceId, tuple);

            return(await LogicalConnection.SendRequest <InsertReplaceRequest <TTuple>, TTuple>(replaceRequest).ConfigureAwait(false));
        }
예제 #7
0
        public async Task <DataResponse <TTuple[]> > Delete <TKey, TTuple>(TKey key)
        {
            var deleteRequest = new DeleteRequest <TKey>(SpaceId, Id, key);

            return(await LogicalConnection.SendRequest <DeleteRequest <TKey>, TTuple>(deleteRequest).ConfigureAwait(false));
        }