Couchbase C++ SDK 1.4.0 (rev. 59aa900)
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>
36
37#include <chrono>
38#include <memory>
39
40namespace couchbase
41{
42#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
43namespace core
44{
45class cluster;
46
47namespace transactions
48{
49class transactions;
50}
51} // namespace core
52class cluster_impl;
53#endif
54
62{
63public:
83 static void connect(const std::string& connection_string,
84 const cluster_options& options,
85 cluster_connect_handler&& handler);
86
107 [[nodiscard]] static auto connect(const std::string& connection_string,
108 const cluster_options& options)
109 -> std::future<std::pair<error, cluster>>;
110
111 cluster() = default;
112 cluster(const cluster& other) = default;
113 cluster(cluster&& other) = default;
114 ~cluster() = default;
115 auto operator=(const cluster& other) -> cluster& = default;
116 auto operator=(cluster&& other) -> cluster& = default;
117
152
153 void close(std::function<void()>&& handler);
154 [[nodiscard]] auto close() -> std::future<void>;
155
169 auto set_authenticator(const password_authenticator& authenticator) -> error;
170
186 auto set_authenticator(const certificate_authenticator& authenticator) -> error;
187
201 auto set_authenticator(const jwt_authenticator& authenticator) -> error;
202
212 [[nodiscard]] auto bucket(std::string_view bucket_name) const -> bucket;
213
227 void query(std::string statement, const query_options& options, query_handler&& handler) const;
228
239 [[nodiscard]] auto query(std::string statement, const query_options& options) const
240 -> std::future<std::pair<error, query_result>>;
241
264 void query_stream(std::string statement,
265 const query_options& options,
266 query_stream_handler&& handler) const;
267
293 [[nodiscard]] auto query_stream(std::string statement, const query_options& options = {}) const
294 -> std::future<std::pair<error, query_stream_result>>;
295
314 void search(std::string index_name,
315 search_request request,
316 const search_options& options,
317 search_handler&& handler) const;
318
337 [[nodiscard]] auto search(std::string index_name,
338 search_request request,
339 const search_options& options = {}) const
340 -> std::future<std::pair<error, search_result>>;
341
357 void analytics_query(std::string statement,
358 const analytics_options& options,
359 analytics_handler&& handler) const;
360
373 [[nodiscard]] auto analytics_query(std::string statement,
374 const analytics_options& options = {}) const
375 -> std::future<std::pair<error, analytics_result>>;
376
396 void analytics_query_stream(std::string statement,
397 const analytics_options& options,
398 analytics_stream_handler&& handler) const;
399
412 [[nodiscard]] auto analytics_query_stream(std::string statement,
413 const analytics_options& options = {}) const
414 -> std::future<std::pair<error, analytics_stream_result>>;
415
433 void ping(const ping_options& options, ping_handler&& handler) const;
434
452 [[nodiscard]] auto ping(const ping_options& options = {}) const
453 -> std::future<std::pair<error, ping_result>>;
454
477 void diagnostics(const diagnostics_options& options, diagnostics_handler&& handler) const;
478
501 [[nodiscard]] auto diagnostics(const diagnostics_options& options = {}) const
502 -> std::future<std::pair<error, diagnostics_result>>;
503
515 void wait_until_ready(std::chrono::milliseconds timeout,
516 const wait_until_ready_options& options,
517 wait_until_ready_handler&& handler) const;
518
530 [[nodiscard]] auto wait_until_ready(std::chrono::milliseconds timeout,
531 const wait_until_ready_options& options = {}) const
532 -> std::future<error>;
533
542 [[nodiscard]] auto query_indexes() const -> query_index_manager;
543
552 [[nodiscard]] auto analytics_indexes() const -> analytics_index_manager;
553
562 [[nodiscard]] auto buckets() const -> bucket_manager;
563
572 [[nodiscard]] auto search_indexes() const -> search_index_manager;
573
584 [[nodiscard]] auto transactions() const -> std::shared_ptr<couchbase::transactions::transactions>;
585
586private:
587#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
588 friend class cluster_impl;
589 explicit cluster(std::shared_ptr<cluster_impl> impl);
590#endif
591
592 std::shared_ptr<cluster_impl> impl_{};
593};
594} // namespace couchbase
Definition analytics_index_manager.hxx:54
Definition bucket_manager.hxx:47
Definition certificate_authenticator.hxx:25
Definition cluster_options.hxx:52
auto set_authenticator(const password_authenticator &authenticator) -> error
Replaces the current authenticator used by this cluster.
cluster(cluster &&other)=default
void wait_until_ready(std::chrono::milliseconds timeout, const wait_until_ready_options &options, wait_until_ready_handler &&handler) const
Waits until the desired state of the cluster is reached, actively pinging its services until they res...
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 analytics_query_stream(std::string statement, const analytics_options &options={}) const -> std::future< std::pair< error, analytics_stream_result > >
Performs a streaming query against the analytics 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.
auto wait_until_ready(std::chrono::milliseconds timeout, const wait_until_ready_options &options={}) const -> std::future< error >
Waits until the desired state of the cluster is reached, actively pinging its services until they res...
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 set_authenticator(const certificate_authenticator &authenticator) -> error
Replaces the current authenticator used by this cluster.
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)
void query_stream(std::string statement, const query_options &options, query_stream_handler &&handler) const
Performs a streaming query against the query (N1QL) services.
auto bucket(std::string_view bucket_name) const -> bucket
Opens a bucket with the given name.
auto close() -> std::future< void >
auto query_stream(std::string statement, const query_options &options={}) const -> std::future< std::pair< error, query_stream_result > >
Performs a streaming query against the query (N1QL) services.
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.
auto set_authenticator(const jwt_authenticator &authenticator) -> error
Replaces the current authenticator used by this cluster.
cluster(const cluster &other)=default
void notify_fork(fork_event event)
Notify the cluster of a fork-related event, so it can keep its I/O usable across fork().
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.
void analytics_query_stream(std::string statement, const analytics_options &options, analytics_stream_handler &&handler) const
Performs a streaming query against the analytics 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.
Definition error.hxx:31
A JWT authenticator which uses a JSON Web Token (JWT) to authenticate with the cluster.
Definition jwt_authenticator.hxx:31
Definition password_authenticator.hxx:25
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
Definition transaction_get_multi_options.hxx:23
Definition expiry.hxx:24
Represents a single item from the result of scan().
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, cluster)> cluster_connect_handler
The signature for the handler of the connect().
Definition cluster_options.hxx:360
std::function< void(error, query_stream_result)> query_stream_handler
The signature for the handler of a streaming query operation.
Definition query_options.hxx:688
std::function< void(error, search_result)> search_handler
The signature for the handler of the search() and search() operations.
Definition search_options.hxx:529
std::function< void(error, analytics_stream_result)> analytics_stream_handler
The signature for the handler of the analytics_query_stream() and analytics_query_stream() operations...
Definition analytics_options.hxx:476
fork_event
Definition fork_event.hxx:22
std::function< void(error, diagnostics_result)> diagnostics_handler
Definition diagnostics_options.hxx:75
@ timeout
Definition analytics_status.hxx:34
std::function< void(error, query_result)> query_handler
The signature for the handler of the query() and query() operations.
Definition query_options.hxx:680
std::function< void(error, ping_result)> ping_handler
Definition ping_options.hxx:93
std::function< void(error)> wait_until_ready_handler
The signature for the handler of the cluster::wait_until_ready() and bucket::wait_until_ready() opera...
Definition wait_until_ready_options.hxx:110
std::function< void(error, analytics_result)> analytics_handler
The signature for the handler of the analytics_query() and analytics_query() operations.
Definition analytics_options.hxx:467
Options for cluster::analytics_query() and scope::analytics_query().
Definition analytics_options.hxx:46
Definition diagnostics_options.hxx:28
Definition ping_options.hxx:32
Options for cluster::query() and scope::query().
Definition query_options.hxx:47
Options for search() and search().
Definition search_options.hxx:47
Options for wait_until_ready() and wait_until_ready().
Definition wait_until_ready_options.hxx:36