-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from XavierGeerinck/api-shutdown
feat: Add shutdown API
- Loading branch information
Showing
5 changed files
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import GRPCClient from './GRPCClient'; | ||
import IClientSidecar from "../../../interfaces/Client/IClientSidecar"; | ||
import { Empty } from "google-protobuf/google/protobuf/empty_pb"; | ||
|
||
// https://docs.dapr.io/reference/api/secrets_api/ | ||
export default class GRPCClientSidecar implements IClientSidecar { | ||
client: GRPCClient; | ||
|
||
constructor(client: GRPCClient) { | ||
this.client = client; | ||
} | ||
|
||
async shutdown(): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const client = this.client.getClient(); | ||
client.shutdown(new Empty(), (err, res: Empty) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
|
||
return resolve(); | ||
}); | ||
}); | ||
} | ||
} |
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 @@ | ||
import HTTPClient from './HTTPClient'; | ||
import IClientSidecar from '../../../interfaces/Client/IClientSidecar'; | ||
|
||
// https://docs.dapr.io/reference/api/bindings_api/ | ||
export default class HTTPClientSidecar implements IClientSidecar { | ||
client: HTTPClient; | ||
|
||
constructor(client: HTTPClient) { | ||
this.client = client; | ||
} | ||
|
||
async shutdown(): Promise<void> { | ||
await this.client.execute(`/shutdown`, { | ||
method: 'POST' | ||
}); | ||
} | ||
} |
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,3 @@ | ||
export default interface IClientSidecar { | ||
shutdown(): Promise<void>; | ||
} |