Skip to content

Commit 7e60898

Browse files
committed
ABI WIP
1 parent 763e1dc commit 7e60898

31 files changed

+1882
-1101
lines changed

.github/workflows/tests.yml

Lines changed: 743 additions & 743 deletions
Large diffs are not rendered by default.

.github/workflows/versions.yml

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

Couchbase/BinaryCollection.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public function name(): string
8080
*/
8181
public function append(string $id, string $value, ?AppendOptions $options = null): MutationResult
8282
{
83-
$response = Extension\documentAppend(
83+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentAppend';
84+
$response = $function(
8485
$this->core,
8586
$this->bucketName,
8687
$this->scopeName,
@@ -107,7 +108,8 @@ public function append(string $id, string $value, ?AppendOptions $options = null
107108
*/
108109
public function prepend(string $id, string $value, ?PrependOptions $options = null): MutationResult
109110
{
110-
$response = Extension\documentPrepend(
111+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentPrepend';
112+
$response = $function(
111113
$this->core,
112114
$this->bucketName,
113115
$this->scopeName,
@@ -133,7 +135,8 @@ public function prepend(string $id, string $value, ?PrependOptions $options = nu
133135
*/
134136
public function increment(string $id, ?IncrementOptions $options = null): CounterResult
135137
{
136-
$response = Extension\documentIncrement(
138+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentIncrement';
139+
$response = $function(
137140
$this->core,
138141
$this->bucketName,
139142
$this->scopeName,
@@ -158,7 +161,8 @@ public function increment(string $id, ?IncrementOptions $options = null): Counte
158161
*/
159162
public function decrement(string $id, ?DecrementOptions $options = null): CounterResult
160163
{
161-
$response = Extension\documentDecrement(
164+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentDecrement';
165+
$response = $function(
162166
$this->core,
163167
$this->bucketName,
164168
$this->scopeName,

Couchbase/Bucket.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public function __construct(string $name, $core)
5050
{
5151
$this->name = $name;
5252
$this->core = $core;
53-
Extension\openBucket($this->core, $this->name);
53+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\openBucket';
54+
$function($this->core, $this->name);
5455
}
5556

5657
/**
@@ -128,7 +129,9 @@ public function viewQuery(string $designDoc, string $viewName, ?ViewOptions $opt
128129
$opts = ViewOptions::export($options);
129130
$namespace = $opts["namespace"];
130131

131-
$result = Extension\viewQuery($this->core, $this->name, $designDoc, $viewName, $namespace, $opts);
132+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\viewQuery';
133+
134+
$result = $function($this->core, $this->name, $designDoc, $viewName, $namespace, $opts);
132135

133136
return new ViewResult($result);
134137
}
@@ -183,7 +186,9 @@ public function ping($services = null, $reportId = null)
183186
if ($reportId != null) {
184187
$options['reportId'] = $reportId;
185188
}
186-
return Extension\ping($this->core, $options);
189+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\ping';
190+
191+
return $function($this->core, $options);
187192
}
188193

189194
/**
@@ -200,6 +205,7 @@ public function diagnostics(?string $reportId = null)
200205
if ($reportId == null) {
201206
$reportId = uniqid();
202207
}
203-
return Extension\diagnostics($this->core, $reportId);
208+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\diagnostics';
209+
return $function($this->core, $reportId);
204210
}
205211
}

Couchbase/Cluster.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ public function __construct(string $connectionString, ClusterOptions $options)
5959
) {
6060
throw new InvalidArgumentException("Please use Cluster::connect() to connect to CNG.");
6161
}
62-
$this->connectionHash = hash("sha256", sprintf("--%s--%s--", $connectionString, $options->authenticatorHash()));
63-
$this->core = Extension\createConnection($this->connectionHash, $connectionString, $options->export());
62+
ExtensionNamespaceResolver::defineExtensionNamespace();
63+
$this->connectionHash = hash("sha256", sprintf("--%s--%s--%s--", $connectionString, $options->authenticatorHash(), COUCHBASE_EXTENSION_NAMESPACE));
64+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\createConnection';
65+
$this->core = $function($this->connectionHash, $connectionString, $options->export());
6466
$this->options = $options;
6567
}
6668

@@ -136,7 +138,8 @@ function (string $connectionString, ClusterOptions $options) {
136138
*/
137139
public static function notifyFork(string $event)
138140
{
139-
return Extension\notifyFork($event);
141+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\notifyFork';
142+
return $function($event);
140143
}
141144

142145
/**
@@ -167,7 +170,8 @@ public function bucket(string $name): BucketInterface
167170
*/
168171
public function query(string $statement, ?QueryOptions $options = null): QueryResult
169172
{
170-
$result = Extension\query($this->core, $statement, QueryOptions::export($options));
173+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\query';
174+
$result = $function($this->core, $statement, QueryOptions::export($options));
171175

172176
return new QueryResult($result, QueryOptions::getTranscoder($options));
173177
}
@@ -186,7 +190,8 @@ public function query(string $statement, ?QueryOptions $options = null): QueryRe
186190
*/
187191
public function analyticsQuery(string $statement, ?AnalyticsOptions $options = null): AnalyticsResult
188192
{
189-
$result = Extension\analyticsQuery($this->core, $statement, AnalyticsOptions::export($options));
193+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\analyticsQuery';
194+
$result = $function($this->core, $statement, AnalyticsOptions::export($options));
190195

191196
return new AnalyticsResult($result, AnalyticsOptions::getTranscoder($options));
192197
}
@@ -204,7 +209,8 @@ public function analyticsQuery(string $statement, ?AnalyticsOptions $options = n
204209
*/
205210
public function searchQuery(string $indexName, SearchQuery $query, ?SearchOptions $options = null): SearchResult
206211
{
207-
$result = Extension\searchQuery($this->core, $indexName, json_encode($query), SearchOptions::export($options));
212+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\searchQuery';
213+
$result = $function($this->core, $indexName, json_encode($query), SearchOptions::export($options));
208214

209215
return new SearchResult($result);
210216
}
@@ -230,12 +236,14 @@ public function search(string $indexName, SearchRequest $request, ?SearchOptions
230236
$query = $exportedRequest['searchQuery'];
231237

232238
if (!$exportedRequest['vectorSearch']) {
233-
$result = Extension\searchQuery($this->core, $indexName, json_encode($query), $exportedOptions);
239+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\searchQuery';
240+
$result = $function($this->core, $indexName, json_encode($query), $exportedOptions);
234241
return new SearchResult($result);
235242
}
236243

237244
$vectorSearch = $exportedRequest['vectorSearch'];
238-
$result = Extension\vectorSearch($this->core, $indexName, json_encode($query), json_encode($vectorSearch), $exportedOptions, VectorSearchOptions::export($vectorSearch->options()));
245+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\vectorSearch';
246+
$result = $function($this->core, $indexName, json_encode($query), json_encode($vectorSearch), $exportedOptions, VectorSearchOptions::export($vectorSearch->options()));
239247
return new SearchResult($result);
240248
}
241249

@@ -318,7 +326,8 @@ public function ping($services = null, $reportId = null)
318326
if ($reportId != null) {
319327
$options['reportId'] = $reportId;
320328
}
321-
return Extension\ping($this->core, $options);
329+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\ping';
330+
return $function($this->core, $options);
322331
}
323332

324333
/**
@@ -334,7 +343,8 @@ public function diagnostics(?string $reportId = null)
334343
if ($reportId == null) {
335344
$reportId = uniqid();
336345
}
337-
return Extension\diagnostics($this->core, $reportId);
346+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\diagnostics';
347+
return $function($this->core, $reportId);
338348
}
339349

340350
/**
@@ -359,7 +369,8 @@ public function transactions(?TransactionsConfiguration $config = null): Transac
359369
*/
360370
public function version(string $bucketName): ?string
361371
{
362-
return Extension\clusterVersion($this->core, $bucketName);
372+
$function = COUCHBASE_EXTENSION_NAMESPACE . "\\clusterVersion";
373+
return $function($this->core, $bucketName);
363374
}
364375

365376
/**
@@ -371,7 +382,8 @@ public function version(string $bucketName): ?string
371382
*/
372383
public function replicasConfiguredFor(string $bucketName): bool
373384
{
374-
return Extension\replicasConfiguredForBucket($this->core, $bucketName);
385+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\replicasConfiguredForBucket';
386+
return $function($this->core, $bucketName);
375387
}
376388

377389
/**

Couchbase/Collection.php

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public function name(): string
115115
*/
116116
public function get(string $id, ?GetOptions $options = null): GetResult
117117
{
118-
$response = Extension\documentGet(
119-
$this->core,
118+
$function = COUCHBASE_EXTENSION_NAMESPACE . "\\documentGet";
119+
$response = $function($this->core,
120120
$this->bucketName,
121121
$this->scopeName,
122122
$this->name,
@@ -139,7 +139,8 @@ public function get(string $id, ?GetOptions $options = null): GetResult
139139
*/
140140
public function exists(string $id, ?ExistsOptions $options = null): ExistsResult
141141
{
142-
$response = Extension\documentExists(
142+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentExists';
143+
$response = $function(
143144
$this->core,
144145
$this->bucketName,
145146
$this->scopeName,
@@ -166,7 +167,8 @@ public function exists(string $id, ?ExistsOptions $options = null): ExistsResult
166167
*/
167168
public function getAndLock(string $id, int $lockTimeSeconds, ?GetAndLockOptions $options = null): GetResult
168169
{
169-
$response = Extension\documentGetAndLock(
170+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentGetAndLock';
171+
$response = $function(
170172
$this->core,
171173
$this->bucketName,
172174
$this->scopeName,
@@ -198,7 +200,8 @@ public function getAndTouch(string $id, $expiry, ?GetAndTouchOptions $options =
198200
} else {
199201
$expirySeconds = (int)$expiry;
200202
}
201-
$response = Extension\documentGetAndTouch(
203+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentGetAndTouch';
204+
$response = $function(
202205
$this->core,
203206
$this->bucketName,
204207
$this->scopeName,
@@ -225,7 +228,8 @@ public function getAndTouch(string $id, $expiry, ?GetAndTouchOptions $options =
225228
*/
226229
public function getAnyReplica(string $id, ?GetAnyReplicaOptions $options = null): GetReplicaResult
227230
{
228-
$response = Extension\documentGetAnyReplica(
231+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentGetAnyReplica';
232+
$response = $function(
229233
$this->core,
230234
$this->bucketName,
231235
$this->scopeName,
@@ -250,7 +254,8 @@ public function getAnyReplica(string $id, ?GetAnyReplicaOptions $options = null)
250254
*/
251255
public function getAllReplicas(string $id, ?GetAllReplicasOptions $options = null): array
252256
{
253-
$responses = Extension\documentGetAllReplicas(
257+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentGetAllReplicas';
258+
$responses = $function(
254259
$this->core,
255260
$this->bucketName,
256261
$this->scopeName,
@@ -281,7 +286,8 @@ function (array $response) use ($options) {
281286
public function upsert(string $id, $value, ?UpsertOptions $options = null): MutationResult
282287
{
283288
$encoded = UpsertOptions::encodeDocument($options, $value);
284-
$response = Extension\documentUpsert(
289+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentUpsert';
290+
$response = $function(
285291
$this->core,
286292
$this->bucketName,
287293
$this->scopeName,
@@ -310,7 +316,8 @@ public function upsert(string $id, $value, ?UpsertOptions $options = null): Muta
310316
public function insert(string $id, $value, ?InsertOptions $options = null): MutationResult
311317
{
312318
$encoded = InsertOptions::encodeDocument($options, $value);
313-
$response = Extension\documentInsert(
319+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentInsert';
320+
$response = $function(
314321
$this->core,
315322
$this->bucketName,
316323
$this->scopeName,
@@ -340,7 +347,8 @@ public function insert(string $id, $value, ?InsertOptions $options = null): Muta
340347
public function replace(string $id, $value, ?ReplaceOptions $options = null): MutationResult
341348
{
342349
$encoded = ReplaceOptions::encodeDocument($options, $value);
343-
$response = Extension\documentReplace(
350+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentReplace';
351+
$response = $function(
344352
$this->core,
345353
$this->bucketName,
346354
$this->scopeName,
@@ -368,7 +376,8 @@ public function replace(string $id, $value, ?ReplaceOptions $options = null): Mu
368376
*/
369377
public function remove(string $id, ?RemoveOptions $options = null): MutationResult
370378
{
371-
$response = Extension\documentRemove(
379+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentRemove';
380+
$response = $function(
372381
$this->core,
373382
$this->bucketName,
374383
$this->scopeName,
@@ -396,7 +405,8 @@ public function remove(string $id, ?RemoveOptions $options = null): MutationResu
396405
*/
397406
public function unlock(string $id, string $cas, ?UnlockOptions $options = null): Result
398407
{
399-
$response = Extension\documentUnlock(
408+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentUnlock';
409+
$response = $function(
400410
$this->core,
401411
$this->bucketName,
402412
$this->scopeName,
@@ -428,7 +438,8 @@ public function touch(string $id, $expiry, ?TouchOptions $options = null): Mutat
428438
} else {
429439
$expirySeconds = (int)$expiry;
430440
}
431-
$response = Extension\documentTouch(
441+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentTouch';
442+
$response = $function(
432443
$this->core,
433444
$this->bucketName,
434445
$this->scopeName,
@@ -464,7 +475,8 @@ function (LookupInSpec $item) {
464475
if ($options != null && $options->needToFetchExpiry()) {
465476
$encoded[] = ['opcode' => 'get', 'isXattr' => true, 'path' => LookupInMacro::EXPIRY_TIME];
466477
}
467-
$response = Extension\documentLookupIn(
478+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentLookupIn';
479+
$response = $function(
468480
$this->core,
469481
$this->bucketName,
470482
$this->scopeName,
@@ -500,7 +512,8 @@ function (LookupInSpec $item) {
500512
if ($options != null && $options->needToFetchExpiry()) {
501513
$encoded[] = ['opcode' => 'get', 'isXattr' => true, 'path' => LookupInMacro::EXPIRY_TIME];
502514
}
503-
$response = Extension\documentLookupInAnyReplica(
515+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentLookupInAnyReplica';
516+
$response = $function(
504517
$this->core,
505518
$this->bucketName,
506519
$this->scopeName,
@@ -537,7 +550,8 @@ function (LookupInSpec $item) {
537550
if ($options != null && $options->needToFetchExpiry()) {
538551
$encoded[] = ['opcode' => 'get', 'isXattr' => true, 'path' => LookupInMacro::EXPIRY_TIME];
539552
}
540-
$responses = Extension\documentLookupInAllReplicas(
553+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentLookupInAllReplicas';
554+
$responses = $function(
541555
$this->core,
542556
$this->bucketName,
543557
$this->scopeName,
@@ -576,7 +590,8 @@ function (MutateInSpec $item) use ($options) {
576590
},
577591
$specs
578592
);
579-
$response = Extension\documentMutateIn(
593+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentMutateIn';
594+
$response = $function(
580595
$this->core,
581596
$this->bucketName,
582597
$this->scopeName,
@@ -600,7 +615,8 @@ function (MutateInSpec $item) use ($options) {
600615
*/
601616
public function getMulti(array $ids, ?GetOptions $options = null): array
602617
{
603-
$responses = Extension\documentGetMulti(
618+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentGetMulti';
619+
$responses = $function(
604620
$this->core,
605621
$this->bucketName,
606622
$this->scopeName,
@@ -666,7 +682,8 @@ public function scan(ScanType $scanType, ?ScanOptions $options = null): ScanResu
666682
*/
667683
public function removeMulti(array $entries, ?RemoveOptions $options = null): array
668684
{
669-
$responses = Extension\documentRemoveMulti(
685+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentRemoveMulti';
686+
$responses = $function(
670687
$this->core,
671688
$this->bucketName,
672689
$this->scopeName,
@@ -712,7 +729,8 @@ function (array $entry) use ($options) {
712729
},
713730
$entries
714731
);
715-
$responses = Extension\documentUpsertMulti(
732+
$function = COUCHBASE_EXTENSION_NAMESPACE . '\\documentUpsertMulti';
733+
$responses = $function(
716734
$this->core,
717735
$this->bucketName,
718736
$this->scopeName,

0 commit comments

Comments
 (0)