-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Code] Use callWithInternalUser to manipulate worker queue index (#36715
- Loading branch information
Showing
6 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
x-pack/plugins/code/server/utils/esclient_with_internal_request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Server } from 'hapi'; | ||
import { AnyObject, EsClient } from '../lib/esqueue'; | ||
import { EsIndexClient } from './es_index_client'; | ||
import { WithInternalRequest } from './with_internal_request'; | ||
|
||
export class EsClientWithInternalRequest extends WithInternalRequest implements EsClient { | ||
public readonly indices = new EsIndexClient(this); | ||
|
||
constructor(server: Server) { | ||
super(server); | ||
} | ||
|
||
public bulk(params: AnyObject): Promise<any> { | ||
return this.callCluster('bulk', params); | ||
} | ||
|
||
public delete(params: AnyObject): Promise<any> { | ||
return this.callCluster('delete', params); | ||
} | ||
|
||
public deleteByQuery(params: AnyObject): Promise<any> { | ||
return this.callCluster('deleteByQuery', params); | ||
} | ||
|
||
public get(params: AnyObject): Promise<any> { | ||
return this.callCluster('get', params); | ||
} | ||
|
||
public index(params: AnyObject): Promise<any> { | ||
return this.callCluster('index', params); | ||
} | ||
|
||
public ping(): Promise<void> { | ||
return this.callCluster('ping'); | ||
} | ||
|
||
public reindex(params: AnyObject): Promise<any> { | ||
return this.callCluster('reindex', params); | ||
} | ||
|
||
public search(params: AnyObject): Promise<any> { | ||
return this.callCluster('search', params); | ||
} | ||
|
||
public update(params: AnyObject): Promise<any> { | ||
return this.callCluster('update', params); | ||
} | ||
|
||
public updateByQuery(params: AnyObject): Promise<any> { | ||
return this.callCluster('updateByQuery', params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Server } from 'hapi'; | ||
import { AnyObject } from '../lib/esqueue'; | ||
|
||
export class WithInternalRequest { | ||
public readonly callCluster: (endpoint: string, clientOptions?: AnyObject) => Promise<any>; | ||
|
||
constructor(server: Server) { | ||
const cluster = server.plugins.elasticsearch.getCluster('admin'); | ||
this.callCluster = cluster.callWithInternalUser; | ||
} | ||
} |