All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.coreos.jetcd.KV Maven / Gradle / Ivy

There is a newer version: 0.0.2
Show newest version
/**
 * Copyright 2017 The jetcd authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.coreos.jetcd;

import com.coreos.jetcd.data.ByteSequence;
import com.coreos.jetcd.internal.impl.CloseableClient;
import com.coreos.jetcd.kv.CompactResponse;
import com.coreos.jetcd.kv.DeleteResponse;
import com.coreos.jetcd.kv.GetResponse;
import com.coreos.jetcd.kv.PutResponse;
import com.coreos.jetcd.options.CompactOption;
import com.coreos.jetcd.options.DeleteOption;
import com.coreos.jetcd.options.GetOption;
import com.coreos.jetcd.options.PutOption;
import com.google.common.annotations.Beta;
import java.util.concurrent.CompletableFuture;

/**
 * Interface of kv client talking to etcd.
 */
@Beta
public interface KV extends CloseableClient {

  /**
   * put a key-value pair into etcd.
   *
   * @param key key in ByteSequence
   * @param value value in ByteSequence
   * @return PutResponse
   */
  CompletableFuture put(ByteSequence key, ByteSequence value);

  /**
   * put a key-value pair into etcd with option.
   *
   * @param key key in ByteSequence
   * @param value value in ByteSequence
   * @param option PutOption
   * @return PutResponse
   */
  CompletableFuture put(ByteSequence key, ByteSequence value,
      PutOption option);

  /**
   * retrieve value for the given key.
   *
   * @param key key in ByteSequence
   * @return GetResponse
   */
  CompletableFuture get(ByteSequence key);

  /**
   * retrieve keys with GetOption.
   *
   * @param key key in ByteSequence
   * @param option GetOption
   * @return GetResponse
   */
  CompletableFuture get(ByteSequence key, GetOption option);

  /**
   * delete a key.
   *
   * @param key key in ByteSequence
   * @return DeleteResponse
   */
  CompletableFuture delete(ByteSequence key);

  /**
   * delete a key or range with option.
   *
   * @param key key in ByteSequence
   * @param option DeleteOption
   * @return DeleteResponse
   */
  CompletableFuture delete(ByteSequence key, DeleteOption option);

  /**
   * compact etcd KV history before the given rev.
   *
   * 

All superseded keys with a revision less than the compaction revision will be removed. * * @param rev the revision to compact. * @return CompactResponse */ CompletableFuture compact(long rev); /** * compact etcd KV history before the given rev with option. * *

All superseded keys with a revision less than the compaction revision will be removed. * * @param rev etcd revision * @param option CompactOption * @return CompactResponse */ CompletableFuture compact(long rev, CompactOption option); /** * creates a transaction. * * @return a Txn */ Txn txn(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy