This is an automated email from the ASF dual-hosted git repository.

isapego pushed a commit to branch ignite-17424
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit f97d215260154c6f6880ab0a591d2011135adce0
Author: Igor Sapego <[email protected]>
AuthorDate: Tue Aug 30 18:33:24 2022 +0400

    IGNITE-17424 Add IgniteClientConfiguration
---
 .../cpp/client/include/ignite/ignite_client.h      | 41 +++++++++-
 .../include/ignite/ignite_client_configuration.h   | 91 ++++++++++++++++++++++
 modules/platforms/cpp/client/src/ignite_client.cpp |  5 ++
 3 files changed, 135 insertions(+), 2 deletions(-)

diff --git a/modules/platforms/cpp/client/include/ignite/ignite_client.h 
b/modules/platforms/cpp/client/include/ignite/ignite_client.h
index 03dbfe0ce3..3c47c31641 100644
--- a/modules/platforms/cpp/client/include/ignite/ignite_client.h
+++ b/modules/platforms/cpp/client/include/ignite/ignite_client.h
@@ -17,22 +17,59 @@
 
 #pragma once
 
+#include <future>
+#include <memory>
+
+#include <ignite/ignite_client_configuration.h>
+
 namespace ignite
 {
 
+namespace impl
+{
+class IgniteClientImpl;
+}
+
 /**
  * Ignite client.
  */
 class IgniteClient
 {
 public:
+    // Deleted
     IgniteClient() = delete;
-    IgniteClient(IgniteClient&) = delete;
-    IgniteClient& operator=(IgniteClient&) = delete;
 
+    // Default
+    ~IgniteClient() = default;
+    IgniteClient(IgniteClient&&) = default;
+    IgniteClient(const IgniteClient&) = default;
+    IgniteClient& operator=(IgniteClient&&) = default;
+    IgniteClient& operator=(const IgniteClient&) = default;
 
+    /**
+     * Start client asynchronously.
+     *
+     * Client tries to establish connection to every endpoint. First endpoint 
is
+     * selected randomly. After that round-robin is used to determine the next
+     * address to establish connection to.
+     *
+     * System means are used to resolve endpoint IP addresses. If more than one
+     * IP address is returned, client attempts to connect to them in random 
order.
+     *
+     * Only one connection establishment can be in process at the same time.
+     *
+     * Client considered connected to a cluster when there is at least one
+     * connection to any node of the cluster. Upon this event, future will be 
set
+     * with a usable IgniteClient instance.
+     *
+     * @param configuration Client configuration.
+     * @return Future with either Ignite client or exception.
+     */
+    static std::future<IgniteClient> startAsync(IgniteClientConfiguration 
configuration);
 
 private:
+    /** Implementation. */
+    std::shared_ptr<impl::IgniteClientImpl> m_impl;
 };
 
 } // namespace ignite
\ No newline at end of file
diff --git 
a/modules/platforms/cpp/client/include/ignite/ignite_client_configuration.h 
b/modules/platforms/cpp/client/include/ignite/ignite_client_configuration.h
new file mode 100644
index 0000000000..3212a0e9cf
--- /dev/null
+++ b/modules/platforms/cpp/client/include/ignite/ignite_client_configuration.h
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+#pragma once
+
+#include <initializer_list>
+#include <string>
+#include <vector>
+
+namespace ignite
+{
+
+/**
+ * Ignite client configuration.
+ */
+class IgniteClientConfiguration
+{
+public:
+    /**
+     * TCP port used by client by default if not specified explicitly.
+     */
+    static constexpr uint16_t DEFAULT_PORT = 10800;
+
+    // Default
+    IgniteClientConfiguration() = default;
+    ~IgniteClientConfiguration() = default;
+    IgniteClientConfiguration(IgniteClientConfiguration&&) = default;
+    IgniteClientConfiguration(const IgniteClientConfiguration&) = default;
+    IgniteClientConfiguration& operator=(IgniteClientConfiguration&&) = 
default;
+    IgniteClientConfiguration& operator=(const IgniteClientConfiguration&) = 
default;
+
+    /**
+     * Constructor.
+     *
+     * @param endpoint Endpoints list.
+     */
+    IgniteClientConfiguration(std::initializer_list<std::string> endpoints) :
+        m_endpoints(endpoints) { }
+
+    /**
+     * Get endpoints.
+     *
+     * @see setEndpoints() for more detailed description.
+     *
+     * @return Endpoints.
+     */
+    [[nodiscard]]
+    const std::vector<std::string>& getEndpoints() const
+    {
+        return m_endpoints;
+    }
+
+    /**
+     * Set endpoints.
+     *
+     * Examples of supported formats:
+     * - 192.168.1.25 - Default port is used, see DEFAULT_PORT;
+     * - 192.168.1.25:780 - Custom port;
+     * - 192.168.1.25:780..787  - Custom port range - ports are checked from
+     *      lesser to greater until an open port is found;
+     * - my-host.com - Default port is used, see DEFAULT_PORT;
+     * - my-host.com:780 - Custom port;
+     * - my-host.com:780..787 - Custom port range.
+     *
+     * @param endpoints Endpoints.
+     */
+    void setEndpoints(std::initializer_list<std::string> endpoints)
+    {
+        IgniteClientConfiguration::m_endpoints = endpoints;
+    }
+
+private:
+    /** Endpoints. */
+    std::vector<std::string> m_endpoints;
+};
+
+} // namespace ignite
\ No newline at end of file
diff --git a/modules/platforms/cpp/client/src/ignite_client.cpp 
b/modules/platforms/cpp/client/src/ignite_client.cpp
index bcc60eb2c1..e94dd89d1e 100644
--- a/modules/platforms/cpp/client/src/ignite_client.cpp
+++ b/modules/platforms/cpp/client/src/ignite_client.cpp
@@ -20,4 +20,9 @@
 namespace ignite
 {
 
+std::future<IgniteClient> IgniteClient::startAsync(IgniteClientConfiguration 
configuration)
+{
+    return {};
+}
+
 } // namespace ignite

Reply via email to