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,42 @@
|
|
|
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
|
+
module Couchbase
|
|
18
|
+
module Protostellar
|
|
19
|
+
# @api private
|
|
20
|
+
class RequestBehaviour
|
|
21
|
+
attr_reader :retry_duration
|
|
22
|
+
attr_reader :error
|
|
23
|
+
|
|
24
|
+
def initialize(retry_duration: nil, error: nil)
|
|
25
|
+
@retry_duration = retry_duration
|
|
26
|
+
@error = error
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.fail(error)
|
|
30
|
+
RequestBehaviour.new(error: error)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.retry(retry_duration)
|
|
34
|
+
RequestBehaviour.new(retry_duration: retry_duration)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.success
|
|
38
|
+
RequestBehaviour.new(retry_duration: nil, error: nil)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
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_relative "../../request"
|
|
18
|
+
require_relative "../../generated/admin/bucket/v1/bucket_pb"
|
|
19
|
+
require_relative "../kv"
|
|
20
|
+
|
|
21
|
+
module Couchbase
|
|
22
|
+
module Protostellar
|
|
23
|
+
module RequestGenerator
|
|
24
|
+
module Admin
|
|
25
|
+
class Bucket
|
|
26
|
+
BUCKET_TYPE_MAP = {
|
|
27
|
+
:couchbase => :BUCKET_TYPE_COUCHBASE,
|
|
28
|
+
:memcached => :BUCKET_TYPE_MEMCACHED,
|
|
29
|
+
:ephemeral => :BUCKET_TYPE_EPHEMERAL,
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
EVICTION_MODE_MAP = {
|
|
33
|
+
:full => :EVICTION_MODE_FULL,
|
|
34
|
+
:value_only => :EVICTION_MODE_VALUE_ONLY,
|
|
35
|
+
:no_eviction => :EVICTION_MODE_NONE,
|
|
36
|
+
:not_recently_used => :EVICTION_MODE_NOT_RECENTLY_USED,
|
|
37
|
+
}.freeze
|
|
38
|
+
|
|
39
|
+
COMPRESSION_MODE_MAP = {
|
|
40
|
+
:off => :COMPRESSION_MODE_OFF,
|
|
41
|
+
:passive => :COMPRESSION_MODE_PASSIVE,
|
|
42
|
+
:active => :COMPRESSION_MODE_ACTIVE,
|
|
43
|
+
}.freeze
|
|
44
|
+
|
|
45
|
+
STORAGE_BACKEND_MAP = {
|
|
46
|
+
:couchstore => :STORAGE_BACKEND_COUCHSTORE,
|
|
47
|
+
:magma => :STORAGE_BACKEND_MAGMA,
|
|
48
|
+
}.freeze
|
|
49
|
+
|
|
50
|
+
CONFLICT_RESOLUTION_TYPE_MAP = {
|
|
51
|
+
:timestamp => :CONFLICT_RESOLUTION_TYPE_TIMESTAMP,
|
|
52
|
+
:sequence_number => :CONFLICT_RESOLUTION_TYPE_SEQUENCE_NUMBER,
|
|
53
|
+
:custom => :CONFLICT_RESOLUTION_TYPE_CUSTOM,
|
|
54
|
+
}.freeze
|
|
55
|
+
|
|
56
|
+
DURABILITY_LEVEL_MAP = RequestGenerator::KV::DURABILITY_LEVEL_MAP
|
|
57
|
+
|
|
58
|
+
def list_buckets_request(options)
|
|
59
|
+
proto_req = Generated::Admin::Bucket::V1::ListBucketsRequest.new
|
|
60
|
+
create_request(proto_req, :list_buckets, options, idempotent: true)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def create_bucket_request(settings, options)
|
|
64
|
+
proto_req = Generated::Admin::Bucket::V1::CreateBucketRequest.new(
|
|
65
|
+
extract_bucket_settings(settings, create: true),
|
|
66
|
+
)
|
|
67
|
+
create_request(proto_req, :create_bucket, options)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def update_bucket_request(settings, options)
|
|
71
|
+
proto_req = Generated::Admin::Bucket::V1::UpdateBucketRequest.new(
|
|
72
|
+
extract_bucket_settings(settings, create: false),
|
|
73
|
+
)
|
|
74
|
+
create_request(proto_req, :update_bucket, options)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def delete_bucket_request(bucket_name, options)
|
|
78
|
+
proto_req = Generated::Admin::Bucket::V1::DeleteBucketRequest.new(
|
|
79
|
+
bucket_name: bucket_name,
|
|
80
|
+
)
|
|
81
|
+
create_request(proto_req, :delete_bucket, options)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def extract_bucket_settings(settings, create: false)
|
|
87
|
+
s = {bucket_name: settings.name}
|
|
88
|
+
|
|
89
|
+
if create
|
|
90
|
+
s[:bucket_type] = BUCKET_TYPE_MAP[settings.bucket_type]
|
|
91
|
+
s[:storage_backend] = STORAGE_BACKEND_MAP[settings.storage_backend] unless settings.storage_backend.nil?
|
|
92
|
+
unless settings.conflict_resolution_type.nil?
|
|
93
|
+
s[:conflict_resolution_type] = CONFLICT_RESOLUTION_TYPE_MAP[settings.conflict_resolution_type]
|
|
94
|
+
end
|
|
95
|
+
s[:replica_indexes] = settings.replica_indexes unless settings.replica_indexes.nil?
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
s[:ram_quota_mb] = settings.ram_quota_mb unless settings.ram_quota_mb.nil?
|
|
99
|
+
s[:num_replicas] = settings.num_replicas unless settings.num_replicas.nil?
|
|
100
|
+
s[:flush_enabled] = settings.flush_enabled unless settings.flush_enabled.nil?
|
|
101
|
+
s[:eviction_mode] = EVICTION_MODE_MAP[settings.eviction_policy] unless settings.eviction_policy.nil?
|
|
102
|
+
s[:max_expiry_secs] = settings.max_expiry unless settings.max_expiry.nil?
|
|
103
|
+
s[:compression_mode] = COMPRESSION_MODE_MAP[settings.compression_mode] unless settings.compression_mode.nil?
|
|
104
|
+
unless settings.minimum_durability_level.nil?
|
|
105
|
+
s[:minimum_durability_level] = DURABILITY_LEVEL_MAP[settings.minimum_durability_level]
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
s
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def create_request(proto_request, rpc, options, idempotent: false)
|
|
112
|
+
Request.new(
|
|
113
|
+
service: :bucket_admin,
|
|
114
|
+
rpc: rpc,
|
|
115
|
+
proto_request: proto_request,
|
|
116
|
+
idempotent: idempotent,
|
|
117
|
+
timeout: options.timeout,
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
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/protostellar/request"
|
|
18
|
+
require "couchbase/protostellar/generated/admin/collection/v1/collection_pb"
|
|
19
|
+
|
|
20
|
+
module Couchbase
|
|
21
|
+
module Protostellar
|
|
22
|
+
module RequestGenerator
|
|
23
|
+
module Admin
|
|
24
|
+
class Collection
|
|
25
|
+
attr_reader :client
|
|
26
|
+
|
|
27
|
+
def initialize(bucket_name:)
|
|
28
|
+
@bucket_name = bucket_name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def list_collections_request(options)
|
|
32
|
+
proto_req = Generated::Admin::Collection::V1::ListCollectionsRequest.new(
|
|
33
|
+
bucket_name: @bucket_name,
|
|
34
|
+
)
|
|
35
|
+
create_request(proto_req, :list_collections, options, idempotent: true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def create_scope_request(scope_name, options)
|
|
39
|
+
proto_req = Generated::Admin::Collection::V1::CreateScopeRequest.new(
|
|
40
|
+
bucket_name: @bucket_name,
|
|
41
|
+
scope_name: scope_name,
|
|
42
|
+
)
|
|
43
|
+
create_request(proto_req, :create_scope, options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def delete_scope_request(scope_name, options)
|
|
47
|
+
proto_req = Generated::Admin::Collection::V1::DeleteScopeRequest.new(
|
|
48
|
+
bucket_name: @bucket_name,
|
|
49
|
+
scope_name: scope_name,
|
|
50
|
+
)
|
|
51
|
+
create_request(proto_req, :delete_scope, options)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def create_collection_request(scope_name, collection_name, settings, options)
|
|
55
|
+
unless settings.history.nil?
|
|
56
|
+
raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support the history setting"
|
|
57
|
+
end
|
|
58
|
+
raise Couchbase::Error::InvalidArgument, "max_expiry must be a non-negative integer" if settings.max_expiry&.negative?
|
|
59
|
+
|
|
60
|
+
proto_opts = {}
|
|
61
|
+
proto_opts[:max_expiry_secs] = settings.max_expiry unless settings.max_expiry.nil?
|
|
62
|
+
|
|
63
|
+
proto_req = Generated::Admin::Collection::V1::CreateCollectionRequest.new(
|
|
64
|
+
bucket_name: @bucket_name,
|
|
65
|
+
scope_name: scope_name,
|
|
66
|
+
collection_name: collection_name,
|
|
67
|
+
**proto_opts,
|
|
68
|
+
)
|
|
69
|
+
create_request(proto_req, :create_collection, options)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def delete_collection_request(scope_name, collection_name, options)
|
|
73
|
+
proto_req = Generated::Admin::Collection::V1::DeleteCollectionRequest.new(
|
|
74
|
+
bucket_name: @bucket_name,
|
|
75
|
+
scope_name: scope_name,
|
|
76
|
+
collection_name: collection_name,
|
|
77
|
+
)
|
|
78
|
+
create_request(proto_req, :delete_collection, options)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def create_request(proto_request, rpc, options, idempotent: false)
|
|
84
|
+
Request.new(
|
|
85
|
+
service: :collection_admin,
|
|
86
|
+
rpc: rpc,
|
|
87
|
+
proto_request: proto_request,
|
|
88
|
+
idempotent: idempotent,
|
|
89
|
+
timeout: options.timeout,
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
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/protostellar/generated/admin/query/v1/query_pb"
|
|
18
|
+
require "couchbase/protostellar/request"
|
|
19
|
+
|
|
20
|
+
module Couchbase
|
|
21
|
+
module Protostellar
|
|
22
|
+
module RequestGenerator
|
|
23
|
+
module Admin
|
|
24
|
+
class Query
|
|
25
|
+
def initialize(bucket_name: nil, scope_name: nil, collection_name: nil)
|
|
26
|
+
@bucket_name = bucket_name
|
|
27
|
+
@scope_name = scope_name
|
|
28
|
+
@collection_name = collection_name
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_all_indexes_request(options, bucket_name = nil)
|
|
32
|
+
proto_req = Generated::Admin::Query::V1::GetAllIndexesRequest.new(
|
|
33
|
+
**location(
|
|
34
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
create_request(proto_req, :get_all_indexes, options, idempotent: true)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_primary_index_request(options, bucket_name = nil)
|
|
42
|
+
proto_opts = {
|
|
43
|
+
deferred: options.deferred,
|
|
44
|
+
ignore_if_exists: options.ignore_if_exists,
|
|
45
|
+
}
|
|
46
|
+
proto_opts[:name] = options.index_name unless options.index_name.nil?
|
|
47
|
+
proto_opts[:num_replicas] = options.num_replicas unless options.num_replicas.nil?
|
|
48
|
+
|
|
49
|
+
proto_req = Generated::Admin::Query::V1::CreatePrimaryIndexRequest.new(
|
|
50
|
+
**location(
|
|
51
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
52
|
+
),
|
|
53
|
+
**proto_opts,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
create_request(proto_req, :create_primary_index, options)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_index_request(index_name, fields, options, bucket_name = nil)
|
|
60
|
+
proto_opts = {
|
|
61
|
+
deferred: options.deferred,
|
|
62
|
+
ignore_if_exists: options.ignore_if_exists,
|
|
63
|
+
}
|
|
64
|
+
proto_opts[:num_replicas] = options.num_replicas unless options.num_replicas.nil?
|
|
65
|
+
|
|
66
|
+
proto_req = Generated::Admin::Query::V1::CreateIndexRequest.new(
|
|
67
|
+
**location(
|
|
68
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
69
|
+
),
|
|
70
|
+
name: index_name,
|
|
71
|
+
fields: fields,
|
|
72
|
+
**proto_opts,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
create_request(proto_req, :create_index, options)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def drop_primary_index_request(options, bucket_name = nil)
|
|
79
|
+
proto_req = Generated::Admin::Query::V1::DropPrimaryIndexRequest.new(
|
|
80
|
+
**location(
|
|
81
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
create_request(proto_req, :drop_primary_index, options)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def drop_index_request(index_name, options, bucket_name = nil)
|
|
89
|
+
proto_req = Generated::Admin::Query::V1::DropIndexRequest.new(
|
|
90
|
+
**location(
|
|
91
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
92
|
+
),
|
|
93
|
+
name: index_name,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
create_request(proto_req, :drop_index, options)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def build_deferred_indexes_request(options, bucket_name = nil)
|
|
100
|
+
proto_req = Generated::Admin::Query::V1::BuildDeferredIndexesRequest.new(
|
|
101
|
+
**location(
|
|
102
|
+
bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name,
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
create_request(proto_req, :build_deferred_indexes, options)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
def location(bucket_name: nil, scope_name: nil, collection_name: nil)
|
|
112
|
+
{
|
|
113
|
+
bucket_name: @bucket_name || bucket_name,
|
|
114
|
+
scope_name: @scope_name || scope_name,
|
|
115
|
+
collection_name: @collection_name || collection_name,
|
|
116
|
+
}.compact
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def create_request(proto_request, rpc, options, idempotent: false)
|
|
120
|
+
Request.new(
|
|
121
|
+
service: :query_admin,
|
|
122
|
+
rpc: rpc,
|
|
123
|
+
proto_request: proto_request,
|
|
124
|
+
idempotent: idempotent,
|
|
125
|
+
timeout: options.timeout,
|
|
126
|
+
)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
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
|
+
module Couchbase
|
|
18
|
+
module Protostellar
|
|
19
|
+
module RequestGenerator
|
|
20
|
+
module Admin
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|