Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:10

0001 /**
0002  * Copyright (c) 2017-present, Facebook, Inc.
0003  * All rights reserved.
0004  *
0005  * This source code is licensed under the BSD-style license found in the
0006  * LICENSE file in the root directory of this source tree.
0007  */
0008 
0009 #pragma once
0010 
0011 #include <chrono>
0012 #include <string>
0013 #include <vector>
0014 
0015 #include "gloo/common/logging.h"
0016 #include "gloo/common/error.h"
0017 #include "gloo/common/store.h"
0018 
0019 //can be used by upstream users to know whether this is available or not.
0020 #define GLOO_STORE_HAS_STORE_V2 1
0021 
0022 namespace gloo {
0023 namespace rendezvous {
0024 
0025 class Store: public IStore {
0026  public:
0027   static constexpr std::chrono::milliseconds kDefaultTimeout =
0028       std::chrono::seconds(30);
0029 
0030   virtual ~Store();
0031 
0032   virtual void set(const std::string& key, const std::vector<char>& data) = 0;
0033 
0034   virtual std::vector<char> get(const std::string& key) = 0;
0035 
0036   virtual void wait(
0037       const std::vector<std::string>& keys) = 0;
0038 
0039   virtual void wait(
0040       const std::vector<std::string>& keys,
0041       const std::chrono::milliseconds& /*timeout*/) {
0042     // Base implementation ignores the timeout for backward compatibility.
0043     // Derived Store implementations should override this function.
0044     wait(keys);
0045   }
0046 
0047   virtual bool has_v2_support() {
0048     // If True, the following operations are guaranteed to be efficiently and correclty implemented.
0049     return false;
0050   }
0051 
0052   virtual std::vector<std::vector<char>> multi_get(const std::vector<std::string>& /*keys*/) {
0053     GLOO_THROW_INVALID_OPERATION_EXCEPTION("this store doesn't support multi_get");
0054   }
0055 
0056   virtual void multi_set(const std::vector<std::string>& /*keys*/, const std::vector<std::vector<char>>& /*values*/) {
0057     GLOO_THROW_INVALID_OPERATION_EXCEPTION("this store doesn't support multi_set");
0058   }
0059 
0060   virtual void append(const std::string& key, const std::vector<char>& /*data*/) {
0061     GLOO_THROW_INVALID_OPERATION_EXCEPTION("this store doesn't support append");
0062   }
0063 
0064   virtual int64_t add(const std::string& key, int64_t value) {
0065     GLOO_THROW_INVALID_OPERATION_EXCEPTION("this store doesn't support add");
0066   }
0067 
0068 };
0069 
0070 } // namespace rendezvous
0071 } // namespace gloo