couchbase 3.9.0-aarch64-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +154 -0
- data/ext/extconf.rb +0 -0
- data/lib/active_support/cache/couchbase_store.rb +407 -0
- data/lib/couchbase/3.2/libcouchbase.so +0 -0
- data/lib/couchbase/3.3/libcouchbase.so +0 -0
- data/lib/couchbase/3.4/libcouchbase.so +0 -0
- data/lib/couchbase/4.0/libcouchbase.so +0 -0
- data/lib/couchbase/analytics_options.rb +109 -0
- data/lib/couchbase/authenticator.rb +80 -0
- data/lib/couchbase/binary_collection.rb +145 -0
- data/lib/couchbase/binary_collection_options.rb +26 -0
- data/lib/couchbase/bucket.rb +173 -0
- data/lib/couchbase/cluster.rb +555 -0
- data/lib/couchbase/cluster_registry.rb +49 -0
- data/lib/couchbase/collection.rb +770 -0
- data/lib/couchbase/collection_options.rb +401 -0
- data/lib/couchbase/config_profiles.rb +57 -0
- data/lib/couchbase/configuration.rb +58 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
- data/lib/couchbase/datastructures.rb +26 -0
- data/lib/couchbase/deprecations.rb +61 -0
- data/lib/couchbase/diagnostics.rb +183 -0
- data/lib/couchbase/errors.rb +438 -0
- data/lib/couchbase/fork_hooks.rb +41 -0
- data/lib/couchbase/get_replica_strategy.rb +89 -0
- data/lib/couchbase/json_transcoder.rb +41 -0
- data/lib/couchbase/key_value_scan.rb +119 -0
- data/lib/couchbase/libcouchbase.rb +6 -0
- data/lib/couchbase/logger.rb +87 -0
- data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
- data/lib/couchbase/management/bucket_manager.rb +479 -0
- data/lib/couchbase/management/collection_manager.rb +515 -0
- data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
- data/lib/couchbase/management/query_index_manager.rb +671 -0
- data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
- data/lib/couchbase/management/search_index_manager.rb +649 -0
- data/lib/couchbase/management/user_manager.rb +639 -0
- data/lib/couchbase/management/view_index_manager.rb +332 -0
- data/lib/couchbase/management.rb +31 -0
- data/lib/couchbase/metrics/logging_meter.rb +108 -0
- data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
- data/lib/couchbase/metrics/meter.rb +27 -0
- data/lib/couchbase/metrics/noop_meter.rb +30 -0
- data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
- data/lib/couchbase/metrics/value_recorder.rb +25 -0
- data/lib/couchbase/mutation_state.rb +65 -0
- data/lib/couchbase/options.rb +3097 -0
- data/lib/couchbase/protostellar/binary_collection.rb +55 -0
- data/lib/couchbase/protostellar/bucket.rb +59 -0
- data/lib/couchbase/protostellar/client.rb +97 -0
- data/lib/couchbase/protostellar/cluster.rb +182 -0
- data/lib/couchbase/protostellar/collection.rb +156 -0
- data/lib/couchbase/protostellar/connect_options.rb +63 -0
- data/lib/couchbase/protostellar/error_handling.rb +204 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
- data/lib/couchbase/protostellar/generated.rb +9 -0
- data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
- data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
- data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
- data/lib/couchbase/protostellar/management.rb +24 -0
- data/lib/couchbase/protostellar/request.rb +79 -0
- data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
- data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
- data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
- data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
- data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
- data/lib/couchbase/protostellar/request_generator.rb +26 -0
- data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
- data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
- data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
- data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
- data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
- data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
- data/lib/couchbase/protostellar/response_converter.rb +26 -0
- data/lib/couchbase/protostellar/retry/action.rb +38 -0
- data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
- data/lib/couchbase/protostellar/retry/reason.rb +67 -0
- data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
- data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
- data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
- data/lib/couchbase/protostellar/retry.rb +28 -0
- data/lib/couchbase/protostellar/scope.rb +61 -0
- data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
- data/lib/couchbase/protostellar/timeouts.rb +83 -0
- data/lib/couchbase/protostellar.rb +29 -0
- data/lib/couchbase/query_options.rb +122 -0
- data/lib/couchbase/railtie.rb +47 -0
- data/lib/couchbase/raw_binary_transcoder.rb +39 -0
- data/lib/couchbase/raw_json_transcoder.rb +40 -0
- data/lib/couchbase/raw_string_transcoder.rb +42 -0
- data/lib/couchbase/scope.rb +272 -0
- data/lib/couchbase/search_options.rb +1744 -0
- data/lib/couchbase/subdoc.rb +293 -0
- data/lib/couchbase/tracing/noop_span.rb +29 -0
- data/lib/couchbase/tracing/noop_tracer.rb +29 -0
- data/lib/couchbase/tracing/request_span.rb +34 -0
- data/lib/couchbase/tracing/request_tracer.rb +28 -0
- data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
- data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
- data/lib/couchbase/transcoder_flags.rb +64 -0
- data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
- data/lib/couchbase/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +263 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
- data/lib/couchbase/utils/time.rb +71 -0
- data/lib/couchbase/utils.rb +23 -0
- data/lib/couchbase/version.rb +25 -0
- data/lib/couchbase/view_options.rb +67 -0
- data/lib/couchbase.rb +32 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
- metadata +228 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# Source: couchbase/transactions/v1/transactions.proto for package 'Couchbase.Protostellar.Generated.Transactions.V1'
|
|
3
|
+
# Original file comments:
|
|
4
|
+
# Transactions Service
|
|
5
|
+
#
|
|
6
|
+
# Provides server-managed distributed ACID transactions against a
|
|
7
|
+
# Couchbase cluster. The transaction lifecycle is:
|
|
8
|
+
# 1. BeginAttempt — start a new transaction attempt.
|
|
9
|
+
# 2. Perform data operations (Get, Insert, Replace, Remove) within
|
|
10
|
+
# the transaction context.
|
|
11
|
+
# 3. Commit or Rollback the transaction attempt.
|
|
12
|
+
# Each attempt is identified by a (transaction_id, attempt_id) pair.
|
|
13
|
+
|
|
14
|
+
require 'grpc'
|
|
15
|
+
require 'couchbase/protostellar/generated/transactions/v1/transactions_pb'
|
|
16
|
+
|
|
17
|
+
module Couchbase
|
|
18
|
+
module Protostellar
|
|
19
|
+
module Generated
|
|
20
|
+
module Transactions
|
|
21
|
+
module V1
|
|
22
|
+
module TransactionsService
|
|
23
|
+
# TransactionsService provides distributed ACID transactions.
|
|
24
|
+
# All data operations must reference a valid transaction_id and attempt_id
|
|
25
|
+
# obtained from TransactionBeginAttempt.
|
|
26
|
+
class Service
|
|
27
|
+
|
|
28
|
+
include ::GRPC::GenericService
|
|
29
|
+
|
|
30
|
+
self.marshal_class_method = :encode
|
|
31
|
+
self.unmarshal_class_method = :decode
|
|
32
|
+
self.service_name = 'couchbase.transactions.v1.TransactionsService'
|
|
33
|
+
|
|
34
|
+
# TransactionBeginAttempt starts a new transaction attempt. Returns
|
|
35
|
+
# a transaction_id and attempt_id to use for all subsequent operations.
|
|
36
|
+
# If transaction_id is provided, this begins a retry attempt for an
|
|
37
|
+
# existing transaction.
|
|
38
|
+
rpc :TransactionBeginAttempt, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionBeginAttemptRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionBeginAttemptResponse
|
|
39
|
+
# TransactionCommit commits all mutations made within the transaction
|
|
40
|
+
# attempt, making them visible to other operations.
|
|
41
|
+
rpc :TransactionCommit, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionCommitRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionCommitResponse
|
|
42
|
+
# TransactionRollback aborts the transaction attempt and discards
|
|
43
|
+
# all uncommitted mutations.
|
|
44
|
+
rpc :TransactionRollback, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionRollbackRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionRollbackResponse
|
|
45
|
+
# TransactionGet retrieves a document within the transaction context.
|
|
46
|
+
# The returned CAS must be used for subsequent Replace or Remove
|
|
47
|
+
# operations on this document within the same transaction.
|
|
48
|
+
rpc :TransactionGet, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionGetRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionGetResponse
|
|
49
|
+
# TransactionInsert creates a new document within the transaction.
|
|
50
|
+
# Fails if the document already exists.
|
|
51
|
+
rpc :TransactionInsert, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionInsertRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionInsertResponse
|
|
52
|
+
# TransactionReplace replaces an existing document within the transaction.
|
|
53
|
+
# Requires the CAS from a prior TransactionGet.
|
|
54
|
+
rpc :TransactionReplace, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionReplaceRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionReplaceResponse
|
|
55
|
+
# TransactionRemove removes a document within the transaction.
|
|
56
|
+
# Requires the CAS from a prior TransactionGet.
|
|
57
|
+
rpc :TransactionRemove, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionRemoveRequest, ::Couchbase::Protostellar::Generated::Transactions::V1::TransactionRemoveResponse
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
Stub = Service.rpc_stub_class
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: couchbase/view/v1/view.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
descriptor_data = "\n\x1c\x63ouchbase/view/v1/view.proto\x12\x11\x63ouchbase.view.v1\"\xa0\t\n\x10ViewQueryRequest\x12\x13\n\x0b\x62ucket_name\x18\x08 \x01(\t\x12\x1c\n\x14\x64\x65sign_document_name\x18\x01 \x01(\t\x12\x11\n\tview_name\x18\x02 \x01(\t\x12\x11\n\x04skip\x18\x03 \x01(\rH\x00\x88\x01\x01\x12\x12\n\x05limit\x18\x04 \x01(\rH\x01\x88\x01\x01\x12R\n\x10scan_consistency\x18\x05 \x01(\x0e\x32\x33.couchbase.view.v1.ViewQueryRequest.ScanConsistencyH\x02\x88\x01\x01\x12\x13\n\x06reduce\x18\x06 \x01(\x08H\x03\x88\x01\x01\x12\x12\n\x05group\x18\x07 \x01(\x08H\x04\x88\x01\x01\x12\x18\n\x0bgroup_level\x18\t \x01(\rH\x05\x88\x01\x01\x12\x10\n\x03key\x18\n \x01(\x0cH\x06\x88\x01\x01\x12\x0c\n\x04keys\x18\x0b \x03(\x0c\x12\x16\n\tstart_key\x18\x0c \x01(\x0cH\x07\x88\x01\x01\x12\x14\n\x07\x65nd_key\x18\r \x01(\x0cH\x08\x88\x01\x01\x12\x1a\n\rinclusive_end\x18\x0e \x01(\x08H\t\x88\x01\x01\x12\x1d\n\x10start_key_doc_id\x18\x0f \x01(\tH\n\x88\x01\x01\x12\x1b\n\x0e\x65nd_key_doc_id\x18\x10 \x01(\tH\x0b\x88\x01\x01\x12\x44\n\x08on_error\x18\x11 \x01(\x0e\x32-.couchbase.view.v1.ViewQueryRequest.ErrorModeH\x0c\x88\x01\x01\x12\x12\n\x05\x64\x65\x62ug\x18\x12 \x01(\x08H\r\x88\x01\x01\x12\x45\n\tnamespace\x18\x13 \x01(\x0e\x32-.couchbase.view.v1.ViewQueryRequest.NamespaceH\x0e\x88\x01\x01\x12=\n\x05order\x18\x14 \x01(\x0e\x32).couchbase.view.v1.ViewQueryRequest.OrderH\x0f\x88\x01\x01\"y\n\x0fScanConsistency\x12 \n\x1cSCAN_CONSISTENCY_NOT_BOUNDED\x10\x00\x12!\n\x1dSCAN_CONSISTENCY_REQUEST_PLUS\x10\x01\x12!\n\x1dSCAN_CONSISTENCY_UPDATE_AFTER\x10\x02\"9\n\tErrorMode\x12\x17\n\x13\x45RROR_MODE_CONTINUE\x10\x00\x12\x13\n\x0f\x45RROR_MODE_STOP\x10\x01\"@\n\tNamespace\x12\x18\n\x14NAMESPACE_PRODUCTION\x10\x00\x12\x19\n\x15NAMESPACE_DEVELOPMENT\x10\x01\"2\n\x05Order\x12\x13\n\x0fORDER_ASCENDING\x10\x00\x12\x14\n\x10ORDER_DESCENDING\x10\x01\x42\x07\n\x05_skipB\x08\n\x06_limitB\x13\n\x11_scan_consistencyB\t\n\x07_reduceB\x08\n\x06_groupB\x0e\n\x0c_group_levelB\x06\n\x04_keyB\x0c\n\n_start_keyB\n\n\x08_end_keyB\x10\n\x0e_inclusive_endB\x13\n\x11_start_key_doc_idB\x11\n\x0f_end_key_doc_idB\x0b\n\t_on_errorB\x08\n\x06_debugB\x0c\n\n_namespaceB\x08\n\x06_order\"\xfe\x01\n\x11ViewQueryResponse\x12\x36\n\x04rows\x18\x01 \x03(\x0b\x32(.couchbase.view.v1.ViewQueryResponse.Row\x12\x45\n\tmeta_data\x18\x02 \x01(\x0b\x32-.couchbase.view.v1.ViewQueryResponse.MetaDataH\x00\x88\x01\x01\x1a-\n\x03Row\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0b\n\x03key\x18\x02 \x01(\x0c\x12\r\n\x05value\x18\x03 \x01(\x0c\x1a-\n\x08MetaData\x12\x12\n\ntotal_rows\x18\x01 \x01(\x04\x12\r\n\x05\x64\x65\x62ug\x18\x02 \x01(\x0c\x42\x0c\n\n_meta_data2i\n\x0bViewService\x12Z\n\tViewQuery\x12#.couchbase.view.v1.ViewQueryRequest\x1a$.couchbase.view.v1.ViewQueryResponse\"\x00\x30\x01\x42\xe6\x01\n)com.couchbase.client.protostellar.view.v1P\x01Z<github.com/couchbase/goprotostellar/genproto/view_v1;view_v1\xaa\x02\x1e\x43ouchbase.Protostellar.View.V1\xca\x02(Couchbase\\Protostellar\\Generated\\View\\V1\xea\x02,Couchbase::Protostellar::Generated::View::V1b\x06proto3"
|
|
9
|
+
|
|
10
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
|
11
|
+
pool.add_serialized_file(descriptor_data)
|
|
12
|
+
|
|
13
|
+
module Couchbase
|
|
14
|
+
module Protostellar
|
|
15
|
+
module Generated
|
|
16
|
+
module View
|
|
17
|
+
module V1
|
|
18
|
+
ViewQueryRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryRequest").msgclass
|
|
19
|
+
ViewQueryRequest::ScanConsistency = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryRequest.ScanConsistency").enummodule
|
|
20
|
+
ViewQueryRequest::ErrorMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryRequest.ErrorMode").enummodule
|
|
21
|
+
ViewQueryRequest::Namespace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryRequest.Namespace").enummodule
|
|
22
|
+
ViewQueryRequest::Order = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryRequest.Order").enummodule
|
|
23
|
+
ViewQueryResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryResponse").msgclass
|
|
24
|
+
ViewQueryResponse::Row = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryResponse.Row").msgclass
|
|
25
|
+
ViewQueryResponse::MetaData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("couchbase.view.v1.ViewQueryResponse.MetaData").msgclass
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# Source: couchbase/view/v1/view.proto for package 'Couchbase.Protostellar.Generated.View.V1'
|
|
3
|
+
# Original file comments:
|
|
4
|
+
# View Service
|
|
5
|
+
#
|
|
6
|
+
# Provides MapReduce view query execution against a Couchbase cluster.
|
|
7
|
+
# Views are defined in design documents and produce key-value results
|
|
8
|
+
# via map and optional reduce functions. Results are server-streamed.
|
|
9
|
+
|
|
10
|
+
require 'grpc'
|
|
11
|
+
require 'couchbase/protostellar/generated/view/v1/view_pb'
|
|
12
|
+
|
|
13
|
+
module Couchbase
|
|
14
|
+
module Protostellar
|
|
15
|
+
module Generated
|
|
16
|
+
module View
|
|
17
|
+
module V1
|
|
18
|
+
module ViewService
|
|
19
|
+
# ViewService provides MapReduce view query execution.
|
|
20
|
+
class Service
|
|
21
|
+
|
|
22
|
+
include ::GRPC::GenericService
|
|
23
|
+
|
|
24
|
+
self.marshal_class_method = :encode
|
|
25
|
+
self.unmarshal_class_method = :decode
|
|
26
|
+
self.service_name = 'couchbase.view.v1.ViewService'
|
|
27
|
+
|
|
28
|
+
# ViewQuery executes a MapReduce view query and streams back result rows
|
|
29
|
+
# and metadata. The final streamed response contains MetaData.
|
|
30
|
+
rpc :ViewQuery, ::Couchbase::Protostellar::Generated::View::V1::ViewQueryRequest, stream(::Couchbase::Protostellar::Generated::View::V1::ViewQueryResponse)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Stub = Service.rpc_stub_class
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require "couchbase/management/bucket_manager"
|
|
18
|
+
require "couchbase/options"
|
|
19
|
+
|
|
20
|
+
require_relative "../request_generator/admin/bucket"
|
|
21
|
+
require_relative "../response_converter/admin/bucket"
|
|
22
|
+
|
|
23
|
+
module Couchbase
|
|
24
|
+
module Protostellar
|
|
25
|
+
module Management
|
|
26
|
+
class BucketManager
|
|
27
|
+
def initialize(client)
|
|
28
|
+
@client = client
|
|
29
|
+
@request_generator = RequestGenerator::Admin::Bucket.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def create_bucket(settings, options = Couchbase::Management::Options::Bucket::CreateBucket.new)
|
|
33
|
+
req = @request_generator.create_bucket_request(settings, options)
|
|
34
|
+
@client.send_request(req)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def update_bucket(settings, options = Couchbase::Management::Options::Bucket::UpdateBucket.new)
|
|
38
|
+
req = @request_generator.update_bucket_request(settings, options)
|
|
39
|
+
@client.send_request(req)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def drop_bucket(settings, options = Couchbase::Management::Options::Bucket::DropBucket.new)
|
|
43
|
+
req = @request_generator.delete_bucket_request(settings, options)
|
|
44
|
+
@client.send_request(req)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def get_all_buckets(options = Couchbase::Management::Options::Bucket::GetAllBuckets.new)
|
|
48
|
+
req = @request_generator.list_buckets_request(options)
|
|
49
|
+
resp = @client.send_request(req)
|
|
50
|
+
ResponseConverter::Admin::Bucket.to_bucket_settings_array(resp)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def get_bucket(bucket_name, options = Couchbase::Management::Options::Bucket::GetBucket.new)
|
|
54
|
+
buckets = get_all_buckets(options)
|
|
55
|
+
bucket = buckets.find { |b| b.name == bucket_name }
|
|
56
|
+
raise Couchbase::Error::BucketNotFound, "Could not find bucket '#{bucket_name}'" if bucket.nil?
|
|
57
|
+
|
|
58
|
+
bucket
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def flush_bucket(_bucket_name, _options = Couchbase::Management::Options::Bucket::FlushBucket.new)
|
|
62
|
+
raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support flush_bucket yet"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require "couchbase/management/collection_manager"
|
|
18
|
+
|
|
19
|
+
require_relative "../request_generator/admin/collection"
|
|
20
|
+
require_relative "../response_converter/admin/collection"
|
|
21
|
+
|
|
22
|
+
module Couchbase
|
|
23
|
+
module Protostellar
|
|
24
|
+
module Management
|
|
25
|
+
class CollectionManager
|
|
26
|
+
def initialize(client:, bucket_name:)
|
|
27
|
+
@client = client
|
|
28
|
+
@bucket_name = bucket_name
|
|
29
|
+
@request_generator = RequestGenerator::Admin::Collection.new(bucket_name: @bucket_name)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_all_scopes(options = Couchbase::Management::Options::Collection::GetAllScopes.new)
|
|
33
|
+
req = @request_generator.list_collections_request(options)
|
|
34
|
+
resp = @client.send_request(req)
|
|
35
|
+
ResponseConverter::Admin::Collection.to_scope_spec_array(resp)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def create_scope(scope_name, options = Couchbase::Management::Options::Collection::CreateScope.new)
|
|
39
|
+
req = @request_generator.create_scope_request(scope_name, options)
|
|
40
|
+
@client.send_request(req)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def drop_scope(scope_name, options = Couchbase::Management::Options::Collection::DropScope.new)
|
|
44
|
+
req = @request_generator.delete_scope_request(scope_name, options)
|
|
45
|
+
@client.send_request(req)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def create_collection(*args)
|
|
49
|
+
req =
|
|
50
|
+
if args[0].is_a?(Couchbase::Management::CollectionSpec)
|
|
51
|
+
collection = args[0]
|
|
52
|
+
options = args[1] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
|
|
53
|
+
settings = Couchbase::Management::CreateCollectionSettings.new(max_expiry: collection.max_expiry, history: collection.history)
|
|
54
|
+
|
|
55
|
+
warn "Calling create_collection with a CollectionSpec object has been deprecated, supply scope name, " \
|
|
56
|
+
"collection name and optionally a CreateCollectionSettings instance"
|
|
57
|
+
|
|
58
|
+
@request_generator.create_collection_request(collection.scope_name, collection.name, settings, options)
|
|
59
|
+
else
|
|
60
|
+
scope_name = args[0]
|
|
61
|
+
collection_name = args[1]
|
|
62
|
+
settings = args[2] || Couchbase::Management::CreateCollectionSettings::DEFAULT
|
|
63
|
+
options = args[3] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
|
|
64
|
+
@request_generator.create_collection_request(scope_name, collection_name, settings, options)
|
|
65
|
+
end
|
|
66
|
+
@client.send_request(req)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def drop_collection(*args)
|
|
70
|
+
req =
|
|
71
|
+
if args[0].is_a?(Couchbase::Management::CollectionSpec)
|
|
72
|
+
collection = args[0]
|
|
73
|
+
options = args[1] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
|
|
74
|
+
|
|
75
|
+
warn "Calling drop_collection with a CollectionSpec object has been deprecated, supply scope name and collection name"
|
|
76
|
+
|
|
77
|
+
@request_generator.delete_collection_request(collection.scope_name, collection.name, options)
|
|
78
|
+
else
|
|
79
|
+
scope_name = args[0]
|
|
80
|
+
collection_name = args[1]
|
|
81
|
+
options = args[2] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
|
|
82
|
+
@request_generator.delete_collection_request(scope_name, collection_name, options)
|
|
83
|
+
end
|
|
84
|
+
@client.send_request(req)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def update_collection(_scope_name, _collection_name, _settings = UpdateCollectionSettings::DEFAULT,
|
|
88
|
+
_options = Couchbase::Management::Options::Collection::UpdateCollection::DEFAULT)
|
|
89
|
+
raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support update_collection"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require "couchbase/management/query_index_manager"
|
|
18
|
+
|
|
19
|
+
require_relative "../request_generator/admin/query"
|
|
20
|
+
require_relative "../response_converter/admin/query"
|
|
21
|
+
|
|
22
|
+
module Couchbase
|
|
23
|
+
module Protostellar
|
|
24
|
+
module Management
|
|
25
|
+
class CollectionQueryIndexManager
|
|
26
|
+
def initialize(client:, bucket_name:, scope_name:, collection_name:)
|
|
27
|
+
@client = client
|
|
28
|
+
@bucket_name = bucket_name
|
|
29
|
+
@scope_name = scope_name
|
|
30
|
+
@collection_name = collection_name
|
|
31
|
+
@request_generator = RequestGenerator::Admin::Query.new(
|
|
32
|
+
bucket_name: @bucket_name, scope_name: @scope_name, collection_name: @collection_name,
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_all_indexes(options = Couchbase::Management::Options::Query::GetAllIndexes.new)
|
|
37
|
+
validate_options(options)
|
|
38
|
+
|
|
39
|
+
req = @request_generator.get_all_indexes_request(options)
|
|
40
|
+
resp = @client.send_request(req)
|
|
41
|
+
ResponseConverter::Admin::Query.to_query_index_array(resp)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_index(index_name, fields, options = Couchbase::Management::Options::Query::CreateIndex.new)
|
|
45
|
+
validate_options(options)
|
|
46
|
+
|
|
47
|
+
req = @request_generator.create_index_request(index_name, fields, options)
|
|
48
|
+
@client.send_request(req)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def create_primary_index(options = Couchbase::Management::Options::Query::CreatePrimaryIndex.new)
|
|
52
|
+
validate_options(options)
|
|
53
|
+
|
|
54
|
+
req = @request_generator.create_primary_index_request(options)
|
|
55
|
+
@client.send_request(req)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def drop_index(index_name, options = Couchbase::Management::Options::Query::DropIndex.new)
|
|
59
|
+
validate_options(options)
|
|
60
|
+
|
|
61
|
+
req = @request_generator.drop_index_request(index_name, options)
|
|
62
|
+
@client.send_request(req)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def drop_primary_index(options = Couchbase::Management::Options::Query::DropPrimaryIndex.new)
|
|
66
|
+
validate_options(options)
|
|
67
|
+
|
|
68
|
+
req = @request_generator.drop_primary_index_request(options)
|
|
69
|
+
@client.send_request(req)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def build_deferred_indexes(options = Couchbase::Management::Options::Query::BuildDeferredIndexes.new)
|
|
73
|
+
validate_options(options)
|
|
74
|
+
|
|
75
|
+
req = @request_generator.build_deferred_indexes_request(options)
|
|
76
|
+
@client.send_request(req)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def watch_indexes(index_names, timeout, options = Couchbase::Management::Options::Query::WatchIndexes.new)
|
|
80
|
+
validate_options(options)
|
|
81
|
+
|
|
82
|
+
# TODO: Will this be implemented in the gateway instead?
|
|
83
|
+
|
|
84
|
+
index_names.append("#primary") if options.watch_primary
|
|
85
|
+
|
|
86
|
+
interval_millis = 50
|
|
87
|
+
deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
|
|
88
|
+
|
|
89
|
+
while Time.now <= deadline
|
|
90
|
+
get_all_opts = Couchbase::Management::Options::Query::GetAllIndexes.new(timeout: ((deadline - Time.now) * 1000).round)
|
|
91
|
+
indexes = get_all_indexes(get_all_opts).select { |idx| index_names.include? idx.name }
|
|
92
|
+
indexes_not_found = index_names - indexes.map(&:name)
|
|
93
|
+
unless indexes_not_found.empty?
|
|
94
|
+
raise Couchbase::Error::IndexNotFound,
|
|
95
|
+
"Failed to find the indexes: #{indexes_not_found.join(', ')}"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
all_online = indexes.all? { |idx| idx.state == :online }
|
|
99
|
+
return if all_online
|
|
100
|
+
|
|
101
|
+
sleep(interval_millis / 1000)
|
|
102
|
+
interval_millis += 500
|
|
103
|
+
interval_millis = 1000 if interval_millis > 1000
|
|
104
|
+
end
|
|
105
|
+
raise Couchbase::Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def validate_options(options)
|
|
111
|
+
unless options.scope_name.nil?
|
|
112
|
+
raise Couchbase::Error::InvalidArgument,
|
|
113
|
+
"Scope name cannot be set in the options when using the Query Index manager at the collection level"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
return if options.collection_name.nil?
|
|
117
|
+
|
|
118
|
+
raise Couchbase::Error::InvalidArgument,
|
|
119
|
+
"Collection name cannot be set in the options when using the Query Index manager at the collection level"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require "couchbase/management/query_index_manager"
|
|
18
|
+
|
|
19
|
+
require_relative "../request_generator/admin/query"
|
|
20
|
+
require_relative "../response_converter/admin/query"
|
|
21
|
+
|
|
22
|
+
module Couchbase
|
|
23
|
+
module Protostellar
|
|
24
|
+
module Management
|
|
25
|
+
class QueryIndexManager
|
|
26
|
+
def initialize(client:)
|
|
27
|
+
@client = client
|
|
28
|
+
@request_generator = RequestGenerator::Admin::Query.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_all_indexes(bucket_name, options = Couchbase::Management::Options::Query::GetAllIndexes.new)
|
|
32
|
+
validate_options(options)
|
|
33
|
+
|
|
34
|
+
req = @request_generator.get_all_indexes_request(options, bucket_name)
|
|
35
|
+
resp = @client.send_request(req)
|
|
36
|
+
ResponseConverter::Admin::Query.to_query_index_array(resp)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def create_index(bucket_name, index_name, fields, options = Couchbase::Management::Options::Query::CreateIndex.new)
|
|
40
|
+
validate_options(options)
|
|
41
|
+
|
|
42
|
+
req = @request_generator.create_index_request(index_name, fields, options, bucket_name)
|
|
43
|
+
@client.send_request(req)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def create_primary_index(bucket_name, options = Couchbase::Management::Options::Query::CreatePrimaryIndex.new)
|
|
47
|
+
validate_options(options)
|
|
48
|
+
|
|
49
|
+
req = @request_generator.create_primary_index_request(options, bucket_name)
|
|
50
|
+
@client.send_request(req)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def drop_index(bucket_name, index_name, options = Couchbase::Management::Options::Query::DropIndex.new)
|
|
54
|
+
validate_options(options)
|
|
55
|
+
|
|
56
|
+
req = @request_generator.drop_index_request(index_name, options, bucket_name)
|
|
57
|
+
@client.send_request(req)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def drop_primary_index(bucket_name, options = Couchbase::Management::Options::Query::DropPrimaryIndex.new)
|
|
61
|
+
validate_options(options)
|
|
62
|
+
|
|
63
|
+
req = @request_generator.drop_primary_index_request(options, bucket_name)
|
|
64
|
+
@client.send_request(req)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def build_deferred_indexes(bucket_name, options = Couchbase::Management::Options::Query::BuildDeferredIndexes.new)
|
|
68
|
+
validate_options(options)
|
|
69
|
+
|
|
70
|
+
req = @request_generator.build_deferred_indexes_request(options, bucket_name)
|
|
71
|
+
@client.send_request(req)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def watch_indexes(bucket_name, index_names, timeout, options = Couchbase::Management::Options::Query::WatchIndexes.new)
|
|
75
|
+
validate_options(options)
|
|
76
|
+
|
|
77
|
+
# TODO: Will this be implemented in the gateway instead?
|
|
78
|
+
|
|
79
|
+
index_names.append("#primary") if options.watch_primary
|
|
80
|
+
|
|
81
|
+
interval_millis = 50
|
|
82
|
+
deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
|
|
83
|
+
while Time.now <= deadline
|
|
84
|
+
get_all_opts = Couchbase::Management::Options::Query::GetAllIndexes.new(timeout: ((deadline - Time.now) * 1000).round)
|
|
85
|
+
indexes = get_all_indexes(bucket_name, get_all_opts).select { |idx| index_names.include? idx.name }
|
|
86
|
+
indexes_not_found = index_names - indexes.map(&:name)
|
|
87
|
+
unless indexes_not_found.empty?
|
|
88
|
+
raise Couchbase::Error::IndexNotFound,
|
|
89
|
+
"Failed to find the indexes: #{indexes_not_found.join(', ')}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
all_online = indexes.all? { |idx| idx.state == :online }
|
|
93
|
+
return if all_online
|
|
94
|
+
|
|
95
|
+
sleep(interval_millis / 1000)
|
|
96
|
+
interval_millis += 500
|
|
97
|
+
interval_millis = 1000 if interval_millis > 1000
|
|
98
|
+
end
|
|
99
|
+
raise Couchbase::Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
def validate_options(options)
|
|
105
|
+
return if options.scope_name.nil? && options.collection_name.nil?
|
|
106
|
+
|
|
107
|
+
warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require_relative "management/collection_manager"
|
|
18
|
+
|
|
19
|
+
module Couchbase
|
|
20
|
+
module Protostellar
|
|
21
|
+
module Management
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Copyright 2023. Couchbase, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# frozen_string_literal: true
|
|
16
|
+
|
|
17
|
+
require "couchbase/utils/time"
|
|
18
|
+
require_relative "retry/strategies/best_effort"
|
|
19
|
+
require_relative "retry/strategies/fail_fast"
|
|
20
|
+
|
|
21
|
+
module Couchbase
|
|
22
|
+
module Protostellar
|
|
23
|
+
# @api private
|
|
24
|
+
class Request
|
|
25
|
+
attr_reader :service
|
|
26
|
+
attr_reader :rpc
|
|
27
|
+
attr_reader :timeout
|
|
28
|
+
attr_reader :proto_request
|
|
29
|
+
attr_reader :idempotent
|
|
30
|
+
attr_reader :retry_attempts
|
|
31
|
+
attr_reader :retry_reasons
|
|
32
|
+
attr_reader :retry_strategy
|
|
33
|
+
attr_accessor :context
|
|
34
|
+
|
|
35
|
+
def initialize(
|
|
36
|
+
service:,
|
|
37
|
+
rpc:,
|
|
38
|
+
proto_request:,
|
|
39
|
+
timeout:,
|
|
40
|
+
retry_strategy: Retry::Strategies::BestEffort::DEFAULT,
|
|
41
|
+
idempotent: false
|
|
42
|
+
)
|
|
43
|
+
@service = service
|
|
44
|
+
@rpc = rpc
|
|
45
|
+
@timeout = timeout
|
|
46
|
+
@deadline = nil
|
|
47
|
+
@proto_request = proto_request
|
|
48
|
+
@idempotent = idempotent
|
|
49
|
+
@retry_attempts = 0
|
|
50
|
+
@retry_reasons = Set.new
|
|
51
|
+
@retry_strategy = retry_strategy
|
|
52
|
+
@context = {}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def deadline
|
|
56
|
+
if @deadline.nil?
|
|
57
|
+
timeout_secs = 0.001 * Utils::Time.extract_duration(@timeout)
|
|
58
|
+
@deadline = Time.now + timeout_secs
|
|
59
|
+
end
|
|
60
|
+
@deadline
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def add_retry_attempt(reason)
|
|
64
|
+
@retry_reasons.add(reason)
|
|
65
|
+
@retry_attempts += 1
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def error_context
|
|
69
|
+
@context.merge({retry_reasons: @retry_reasons.to_a, retry_attempts: @retry_attempts})
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def set_timeout_from_defaults(timeouts)
|
|
73
|
+
return unless @timeout.nil?
|
|
74
|
+
|
|
75
|
+
@timeout = timeouts.timeout_for_request(self)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|