/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2020-2021 Couchbase, Inc. * * Licensed 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 "diagnostics.hxx" #include "operations_fwd.hxx" #include "origin.hxx" #include "topology/configuration.hxx" #include "utils/movable_function.hxx" #include #include #include #include namespace couchbase { class cluster; } // namespace couchbase namespace couchbase::core { class crud_component; class cluster_impl; namespace mcbp { class queue_request; } // namespace mcbp namespace o = operations; namespace om = operations::management; template using mf = utils::movable_function; class cluster { public: explicit cluster(asio::io_context& ctx); [[nodiscard]] auto io_context() const -> asio::io_context&; [[nodiscard]] auto origin() const -> std::pair; void open(core::origin origin, utils::movable_function&& handler) const; void close(utils::movable_function&& handler) const; void open_bucket(const std::string& bucket_name, utils::movable_function&& handler) const; void close_bucket(const std::string& bucket_name, utils::movable_function&& handler) const; void with_bucket_configuration( const std::string& bucket_name, utils::movable_function&& handler) const; void execute(o::analytics_request request, mf&& handler) const; void execute(o::append_request request, mf&& handler) const; void execute(o::decrement_request request, mf&& handler) const; void execute(o::exists_request request, mf&& handler) const; void execute(o::get_request request, mf&& handler) const; void execute(o::get_all_replicas_request request, mf&& handler) const; void execute(o::get_and_lock_request request, mf&& handler) const; void execute(o::get_and_touch_request request, mf&& handler) const; void execute(o::get_any_replica_request request, mf&& handler) const; void execute(o::get_projected_request request, mf&& handler) const; void execute(o::increment_request request, mf&& handler) const; void execute(o::insert_request request, mf&& handler) const; void execute(o::lookup_in_request request, mf&& handler) const; void execute(o::lookup_in_any_replica_request request, mf&& handler) const; void execute(o::lookup_in_all_replicas_request request, mf&& handler) const; void execute(o::mutate_in_request request, mf&& handler) const; void execute(o::prepend_request request, mf&& handler) const; void execute(o::query_request request, mf&& handler) const; void execute(o::remove_request request, mf&& handler) const; void execute(o::replace_request request, mf&& handler) const; void execute(o::search_request request, mf&& handler) const; void execute(o::touch_request request, mf&& handler) const; void execute(o::unlock_request request, mf&& handler) const; void execute(o::upsert_request request, mf&& handler) const; void execute(o::upsert_request_with_legacy_durability request, mf&& handler) const; void execute(o::append_request_with_legacy_durability request, mf&& handler) const; void execute(o::decrement_request_with_legacy_durability request, mf&& handler) const; void execute(o::increment_request_with_legacy_durability request, mf&& handler) const; void execute(o::insert_request_with_legacy_durability request, mf&& handler) const; void execute(o::mutate_in_request_with_legacy_durability request, mf&& handler) const; void execute(o::prepend_request_with_legacy_durability request, mf&& handler) const; void execute(o::remove_request_with_legacy_durability request, mf&& handler) const; void execute(o::replace_request_with_legacy_durability request, mf&& handler) const; void execute(o::document_view_request request, mf&& handler) const; void execute(o::http_noop_request request, mf&& handler) const; void execute(om::analytics_dataset_create_request request, mf&& handler) const; void execute(om::analytics_dataset_drop_request request, mf&& handler) const; void execute(om::analytics_dataset_get_all_request request, mf&& handler) const; void execute(om::analytics_dataverse_create_request request, mf&& handler) const; void execute(om::analytics_dataverse_drop_request request, mf&& handler) const; void execute(om::analytics_get_pending_mutations_request request, mf&& handler) const; void execute(om::analytics_index_create_request request, mf&& handler) const; void execute(om::analytics_index_drop_request request, mf&& handler) const; void execute(om::analytics_index_get_all_request request, mf&& handler) const; void execute(om::analytics_link_connect_request request, mf&& handler) const; void execute(om::analytics_link_disconnect_request request, mf&& handler) const; void execute(om::analytics_link_drop_request request, mf&& handler) const; void execute(om::analytics_link_get_all_request request, mf&& handler) const; void execute(om::bucket_create_request request, mf&& handler) const; void execute(om::bucket_drop_request request, mf&& handler) const; void execute(om::bucket_flush_request request, mf&& handler) const; void execute(om::bucket_get_request request, mf&& handler) const; void execute(om::bucket_get_all_request request, mf&& handler) const; void execute(om::bucket_update_request request, mf&& handler) const; void execute(om::cluster_developer_preview_enable_request request, mf&& handler) const; void execute(om::collection_create_request request, mf&& handler) const; void execute(om::collection_update_request request, mf&& handler) const; void execute(om::collection_drop_request request, mf&& handler) const; void execute(om::collections_manifest_get_request request, mf&& handler) const; void execute(om::scope_create_request request, mf&& handler) const; void execute(om::scope_drop_request request, mf&& handler) const; void execute(om::scope_get_all_request request, mf&& handler) const; void execute(om::eventing_deploy_function_request request, mf&& handler) const; void execute(om::eventing_drop_function_request request, mf&& handler) const; void execute(om::eventing_get_all_functions_request request, mf&& handler) const; void execute(om::eventing_get_function_request request, mf&& handler) const; void execute(om::eventing_get_status_request request, mf&& handler) const; void execute(om::eventing_pause_function_request request, mf&& handler) const; void execute(om::eventing_resume_function_request request, mf&& handler) const; void execute(om::eventing_undeploy_function_request request, mf&& handler) const; void execute(om::eventing_upsert_function_request request, mf&& handler) const; void execute(om::view_index_drop_request request, mf&& handler) const; void execute(om::view_index_get_request request, mf&& handler) const; void execute(om::view_index_get_all_request request, mf&& handler) const; void execute(om::view_index_upsert_request request, mf&& handler) const; void execute(om::change_password_request request, mf&& handler) const; void execute(om::group_drop_request request, mf&& handler) const; void execute(om::group_get_request request, mf&& handler) const; void execute(om::group_get_all_request request, mf&& handler) const; void execute(om::group_upsert_request request, mf&& handler) const; void execute(om::role_get_all_request request, mf&& handler) const; void execute(om::user_drop_request request, mf&& handler) const; void execute(om::user_get_request request, mf&& handler) const; void execute(om::user_get_all_request request, mf&& handler) const; void execute(om::user_upsert_request request, mf&& handler) const; void execute(om::search_get_stats_request request, mf&& handler) const; void execute(om::search_index_analyze_document_request request, mf&& handler) const; void execute(om::search_index_control_ingest_request request, mf&& handler) const; void execute(om::search_index_control_plan_freeze_request request, mf&& handler) const; void execute(om::search_index_control_query_request request, mf&& handler) const; void execute(om::search_index_drop_request request, mf&& handler) const; void execute(om::search_index_get_request request, mf&& handler) const; void execute(om::search_index_get_all_request request, mf&& handler) const; void execute(om::search_index_get_documents_count_request request, mf&& handler) const; void execute(om::search_index_get_stats_request request, mf&& handler) const; void execute(om::search_index_upsert_request request, mf&& handler) const; void execute(om::query_index_build_request request, mf&& handler) const; void execute(om::query_index_build_deferred_request request, mf&& handler) const; void execute(om::query_index_create_request request, mf&& handler) const; void execute(om::query_index_drop_request request, mf&& handler) const; void execute(om::query_index_get_all_request request, mf&& handler) const; void execute(om::query_index_get_all_deferred_request request, mf&& handler) const; void execute(om::freeform_request request, mf&& handler) const; void execute(om::bucket_describe_request request, mf&& handler) const; void execute(om::cluster_describe_request request, mf&& handler) const; void execute(impl::get_replica_request request, mf&& handler) const; void execute(impl::lookup_in_replica_request request, mf&& handler) const; void execute(impl::observe_seqno_request request, mf&& handler) const; void execute( om::analytics_link_replace_request request, mf&& handler) const; void execute( om::analytics_link_replace_request request, mf&& handler) const; void execute(om::analytics_link_replace_request request, mf&& handler) const; void execute( om::analytics_link_create_request request, mf&& handler) const; void execute( om::analytics_link_create_request request, mf&& handler) const; void execute(om::analytics_link_create_request request, mf&& handler) const; void diagnostics(std::optional report_id, mf&& handler) const; void ping(std::optional report_id, std::optional bucket_name, std::set services, std::optional timeout, utils::movable_function&& handler) const; [[nodiscard]] auto direct_dispatch( const std::string& bucket_name, std::shared_ptr req) const -> std::error_code; [[nodiscard]] auto direct_re_queue(const std::string& bucket_name, std::shared_ptr req, bool is_retry) const -> std::error_code; [[nodiscard]] auto to_string() const -> std::string; private: std::shared_ptr impl_; }; // FIXME: temporary solution for the core API migration. FIT performer needs to access core for KV // range APIs auto get_core_cluster(couchbase::cluster public_api_cluster) -> core::cluster; } // namespace couchbase::core