-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support binding gRPC services that are defined as object literals.
This commit allows binding gRPC services directly, in the following way: const greeter = { greet: (req) => TestResponse.create({ greeting: `Hello` }) };
- Loading branch information
1 parent
bee23ae
commit 08458c0
Showing
2 changed files
with
54 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
* | ||
* This file is part of the Restate SDK for Node.js/TypeScript, | ||
* which is released under the MIT license. | ||
* | ||
* You can find a copy of the license in file LICENSE in the root | ||
* directory of this repository or package, or at | ||
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE | ||
*/ | ||
|
||
import { | ||
TestGreeter, | ||
TestRequest, | ||
TestResponse, | ||
} from "../src/generated/proto/test"; | ||
import * as restate from "../src/public_api"; | ||
import { describe } from "@jest/globals"; | ||
import { TestDriver } from "./testdriver"; | ||
import { greetRequest, inputMessage, startMessage } from "./protoutils"; | ||
|
||
const greeter: TestGreeter = { | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
greet: async (req: TestRequest): Promise<TestResponse> => { | ||
restate.useContext(this); | ||
return TestResponse.create({ greeting: `Hello` }); | ||
}, | ||
}; | ||
|
||
describe("BindService", () => { | ||
it("should bind object literals", async () => { | ||
await new TestDriver(greeter, [ | ||
startMessage(1), | ||
inputMessage(greetRequest("Pete")), | ||
]).run(); | ||
}); | ||
}); |