zookeeper-cpp
ZooKeeper Client for C++
package_registry.hpp
1 #pragma once
2 
3 #include <zk/config.hpp>
4 #include <zk/optional.hpp>
5 
6 #include <cstddef>
7 #include <map>
8 #include <memory>
9 #include <mutex>
10 #include <string>
11 
12 namespace zk::server
13 {
14 
25 class package_registry final
26 {
27 public:
28  using size_type = std::size_t;
29 
30  struct registration_info;
31  using registration = std::shared_ptr<registration_info>;
32 
33 public:
35 
36  ~package_registry() noexcept;
37 
46  registration register_classpath_server(std::string version, std::string classpath);
47 
54  bool unregister_server(registration reg);
55  bool unregister_server(const registration_info& reg);
56 
58  size_type size() const;
59 
61  bool empty() const
62  {
63  return size() == size_type(0);
64  }
65 
72  optional<std::string> find_newest_classpath() const;
73 
74 private:
75  mutable std::mutex _protect;
76  std::shared_ptr<void> _lifetime;
77  std::map<std::string, std::string> _registrations;
78 };
79 
82 }
size_type size() const
How many registrations have been registered?
Controls the import of the optional and nullopt_t types, as well as the nullopt constexpr.
optional< std::string > find_newest_classpath() const
Get the classpath for running the newest registered server version.
bool unregister_server(registration reg)
Attempt to unregister the server associated with the provided registration.
The package registry tracks configuration of classpaths and JARs needed to run various ZooKeeper vers...
registration register_classpath_server(std::string version, std::string classpath)
Register a server that can be created via the specified Java classpath.
bool empty() const
Is this registry empty?
Represents a version of the data.
Definition: types.hpp:131