Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
cluster.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
22#include <couchbase/bucket.hxx>
35
36#include <memory>
37
38namespace couchbase
39{
40#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
41namespace core
42{
43class cluster;
44
45namespace transactions
46{
47class transactions;
48}
49} // namespace core
50class cluster_impl;
51#endif
52
60{
61public:
73 static void connect(const std::string& connection_string,
74 const cluster_options& options,
75 cluster_connect_handler&& handler);
76
89 [[nodiscard]] static auto connect(const std::string& connection_string,
90 const cluster_options& options)
91 -> std::future<std::pair<error, cluster>>;
92
93 cluster() = default;
94 cluster(const cluster& other) = default;
95 cluster(cluster&& other) = default;
96 ~cluster() = default;
97 auto operator=(const cluster& other) -> cluster& = default;
98 auto operator=(cluster&& other) -> cluster& = default;
99
101
102 void close(std::function<void()>&& handler);
103 [[nodiscard]] auto close() -> std::future<void>;
104
114 [[nodiscard]] auto bucket(std::string_view bucket_name) const -> bucket;
115
129 void query(std::string statement, const query_options& options, query_handler&& handler) const;
130
141 [[nodiscard]] auto query(std::string statement, const query_options& options) const
142 -> std::future<std::pair<error, query_result>>;
143
162 void search(std::string index_name,
163 search_request request,
164 const search_options& options,
165 search_handler&& handler) const;
166
185 [[nodiscard]] auto search(std::string index_name,
186 search_request request,
187 const search_options& options = {}) const
188 -> std::future<std::pair<error, search_result>>;
189
205 void analytics_query(std::string statement,
206 const analytics_options& options,
207 analytics_handler&& handler) const;
208
221 [[nodiscard]] auto analytics_query(std::string statement, const analytics_options& options = {})
222 const -> std::future<std::pair<error, analytics_result>>;
223
236 void ping(const ping_options& options, ping_handler&& handler) const;
237
250 [[nodiscard]] auto ping(const ping_options& options = {}) const
251 -> std::future<std::pair<error, ping_result>>;
252
269 void diagnostics(const diagnostics_options& options, diagnostics_handler&& handler) const;
270
287 [[nodiscard]] auto diagnostics(const diagnostics_options& options = {}) const
288 -> std::future<std::pair<error, diagnostics_result>>;
289
298 [[nodiscard]] auto query_indexes() const -> query_index_manager;
299
308 [[nodiscard]] auto analytics_indexes() const -> analytics_index_manager;
309
318 [[nodiscard]] auto buckets() const -> bucket_manager;
319
328 [[nodiscard]] auto search_indexes() const -> search_index_manager;
329
340 [[nodiscard]] auto transactions() const -> std::shared_ptr<couchbase::transactions::transactions>;
341
342private:
343#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
344 friend class cluster_impl;
345 explicit cluster(std::shared_ptr<cluster_impl> impl);
346#endif
347
348 std::shared_ptr<cluster_impl> impl_{};
349};
350} // namespace couchbase
Definition analytics_index_manager.hxx:54
Definition bucket_manager.hxx:47
Definition cluster_options.hxx:44
The cluster is the main entry point when connecting to a Couchbase cluster.
Definition cluster.hxx:60
cluster(cluster &&other)=default
auto ping(const ping_options &options={}) const -> std::future< std::pair< error, ping_result > >
Performs application-level ping requests against services in the Couchbase cluster.
auto analytics_indexes() const -> analytics_index_manager
Provides access ot the Analytics index management services.
auto query_indexes() const -> query_index_manager
Provides access to the N1QL index management services.
auto search(std::string index_name, search_request request, const search_options &options={}) const -> std::future< std::pair< error, search_result > >
Performs a request against the full text search services.
static void connect(const std::string &connection_string, const cluster_options &options, cluster_connect_handler &&handler)
Connect to a Couchbase cluster.
auto query(std::string statement, const query_options &options) const -> std::future< std::pair< error, query_result > >
Performs a query against the query (N1QL) services.
auto analytics_query(std::string statement, const analytics_options &options={}) const -> std::future< std::pair< error, analytics_result > >
Performs a query against the analytics services.
void close(std::function< void()> &&handler)
auto bucket(std::string_view bucket_name) const -> bucket
Opens a bucket with the given name.
auto close() -> std::future< void >
void search(std::string index_name, search_request request, const search_options &options, search_handler &&handler) const
Performs a request against the full text search services.
auto diagnostics(const diagnostics_options &options={}) const -> std::future< std::pair< error, diagnostics_result > >
Assembles a diagnostics report on the current state of the cluster from the SDK's point of view.
void ping(const ping_options &options, ping_handler &&handler) const
Performs application-level ping requests against services in the Couchbase cluster.
cluster(const cluster &other)=default
void notify_fork(fork_event event)
auto operator=(const cluster &other) -> cluster &=default
void query(std::string statement, const query_options &options, query_handler &&handler) const
Performs a query against the query (N1QL) services.
auto search_indexes() const -> search_index_manager
Provides access to search index management services.
void diagnostics(const diagnostics_options &options, diagnostics_handler &&handler) const
Assembles a diagnostics report on the current state of the cluster from the SDK's point of view.
void analytics_query(std::string statement, const analytics_options &options, analytics_handler &&handler) const
Performs a query against the analytics services.
auto transactions() const -> std::shared_ptr< couchbase::transactions::transactions >
Provides access to transaction services.
auto buckets() const -> bucket_manager
Provides access to the bucket management services.
auto operator=(cluster &&other) -> cluster &=default
static auto connect(const std::string &connection_string, const cluster_options &options) -> std::future< std::pair< error, cluster > >
Connect to a Couchbase cluster.
The Query Index Manager interface contains the means for managing indexes used for queries.
Definition query_index_manager.hxx:49
Definition search_index_manager.hxx:52
A search_request is used to perform operations against the Full Text Search (FTS) Couchbase service.
Definition search_request.hxx:46
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, cluster)> cluster_connect_handler
The signature for the handler of the cluster::connect()
Definition cluster_options.hxx:309
std::function< void(error, search_result)> search_handler
The signature for the handler of the cluster::search() and scope::search() operations.
Definition search_options.hxx:528
fork_event
Definition fork_event.hxx:22
std::function< void(error, diagnostics_result)> diagnostics_handler
Definition diagnostics_options.hxx:75
std::function< void(error, query_result)> query_handler
The signature for the handler of the cluster::query() and scope::query() operations.
Definition query_options.hxx:612
std::function< void(error, ping_result)> ping_handler
Definition ping_options.hxx:93
std::function< void(error, analytics_result)> analytics_handler
The signature for the handler of the cluster::analytics_query() and scope::analytics_query() operatio...
Definition analytics_options.hxx:400
Options for cluster::analytics_query() and scope::analytics_query().
Definition analytics_options.hxx:45
Definition diagnostics_options.hxx:28
Definition ping_options.hxx:32
Options for cluster::query() and scope::query().
Definition query_options.hxx:46
Options for cluster::search() and scope::search().
Definition search_options.hxx:47