Skip to content

Commit

Permalink
Use new method to get HttpExecutor (#122)
Browse files Browse the repository at this point in the history
Motivation
------------
The latest Couchbase SDK is getting errors where we were accessing an
internal member to make HTTP requests.

Modifications
---------------
Use the new surface that is a bit less hacky, though still involves accessing an
unexported file from the SDK.

Fixes #118
  • Loading branch information
brantburnett committed Nov 27, 2023
1 parent bca7fba commit 0223c7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions packages/couchbase-index-manager/app/index-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ interface IndexCreatePlanUnnormalized {
}
}

/**
* Extended version of the QueryIndexManager which lets us cheat and get to internals.
*/
interface QueryIndexManagerInternal extends Omit<QueryIndexManager, "_http"> {
get _http(): HttpExecutor;
}

/**
* Subset of fields returned on a query plan for CREATE INDEX
*/
Expand Down Expand Up @@ -144,7 +137,7 @@ export function getKeyspace(bucket: string, scope = DEFAULT_SCOPE, collection =
* Manages Couchbase indexes
*/
export class IndexManager {
private manager: QueryIndexManagerInternal;
private manager: QueryIndexManager;

/**
* @param {Bucket} bucket
Expand All @@ -153,7 +146,7 @@ export class IndexManager {
constructor(private bucket: Bucket, private cluster: Cluster) {
this.bucket = bucket;
this.cluster = cluster;
this.manager = cluster.queryIndexes() as unknown as QueryIndexManagerInternal;
this.manager = cluster.queryIndexes();
}

/**
Expand Down Expand Up @@ -183,7 +176,9 @@ export class IndexManager {
* Gets index statuses for the bucket via the cluster manager
*/
private async getIndexStatuses(): Promise<IndexStatusNormalized[]> {
const resp = await this.manager._http.request({
const httpExecutor = new HttpExecutor(this.cluster.conn);

const resp = await httpExecutor.request({
type: HttpServiceType.Management,
method: HttpMethod.Get,
path: '/indexStatus',
Expand Down Expand Up @@ -414,7 +409,9 @@ export class IndexManager {
* Gets the version of the cluster
*/
async getClusterVersion(): Promise<Version> {
const resp = await this.manager._http.request({
const httpExecutor = new HttpExecutor(this.cluster.conn)

const resp = await httpExecutor.request({
type: HttpServiceType.Management,
method: HttpMethod.Get,
path: '/pools/default',
Expand Down
2 changes: 1 addition & 1 deletion packages/couchbase-index-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"dependencies": {
"chalk": "^2.3.1",
"couchbase": "^4.1.1",
"couchbase": "^4.2.8",
"js-yaml": "^4.1.0",
"lodash": "^4.17.15",
"tslib": "^2.6.2"
Expand Down

0 comments on commit 0223c7e

Please sign in to comment.