-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Labels
enhancementNew feature or requestNew feature or requestserverRust server SDKRust server SDKtypescript-serverTypescript server SDKTypescript server SDKx-large
Description
napi-rs will allow us to generate an idiomatic Python implementation which is exported from Rust as a shared library.
The framework heavy-lifting will be handled completely in Rust, while the business logic will be implemented in pure Typescript.
Example
import {
App,
Handlers,
GetPokemonSpeciesInput,
GetPokemonSpeciesOutput,
Language,
DoNothingInput,
DoNothingOutput,
Socket,
CheckHealthOutput,
CheckHealthInput,
GetServerStatisticsInput,
GetServerStatisticsOutput,
} from ".";
class HandlerImpl implements Handlers {
// TODO: implement
async doNothing(input: DoNothingInput): Promise<DoNothingOutput> {
return {};
}
// TODO: implement
async checkHealth(input: CheckHealthInput): Promise<CheckHealthOutput> {
return {};
}
// TODO: implement
async getServerStatistics(
input: GetServerStatisticsInput
): Promise<GetServerStatisticsOutput> {
return { callsCount: 0 };
}
async getPokemonSpecies(
input: GetPokemonSpeciesInput
): Promise<GetPokemonSpeciesOutput> {
return {
name: input.name,
flavorTextEntries: [
{
language: Language.English,
flavorText:
"When several of these Pokémon gather, their electricity could build and cause lightning storms.",
},
{
language: Language.Italian,
flavorText:
"Quando vari Pokémon di questo tipo si radunano, la loro energia può causare forti tempeste.",
},
{
language: Language.Spanish,
flavorText:
"Cuando varios de estos Pokémon se juntan, su energía puede causar fuertes tormentas.",
},
{
language: Language.Japanese,
flavorText:
"ほっぺたの りょうがわに ちいさい でんきぶくろを もつ。ピンチのときに ほうでんする。",
},
],
};
}
}
// Pass the handlers to the App.
const app = new App(new HandlerImpl());
// Start the app 🤘
const numCPUs = cpus().length / 2;
const socket = new Socket("127.0.0.1", 9090);
app.start(socket);
// TODO: This part should be abstracted out and done directly in Rust.
// We could take an optional number of workers and the socket as input
// of the App.start() method.
if (cluster.isPrimary) {
// Fork workers.
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
}
Features
- Typescript subproject scaffolding - Initial implementation of Typescript server bindings #2277
- Runtime crate and shared socket - Initial implementation of Typescript server bindings #2277
- Code sharing between :codegen-core, :codegen-server and :codegen-server:typescript Gradle projects. - Initial implementation of Typescript server bindings #2277
- Object model for input / outputs / errors. - Initial implementation of Typescript server bindings #2277
- Operation wrappers to execute Typescript code inside Rust. - Initial implementation of Typescript server bindings #2277
- Support spawning multiple interpreters using a shared socket. - Initial implementation of Typescript server bindings #2277
- Enum support - Initial implementation of Typescript server bindings #2277
- Support type hinting - Initial implementation of Typescript server bindings #2277
- Shared state/context support.
- Handle Typescript exceptions inside infallible and fallible operations (Cast Typescript exceptions into Rust errors).
- Inject tracing into the Typescript logger system.
- Signal handling.
- Typescript API example.
- Integration testing in CI.
- Generate Typescript application example.
- Cast Typescript non-primitive types into types coming from
aws-smithy-types
during deserialization. -
DateTime
type support. - Streaming body support.
- Support for custom pure-Typescript request middleware.
- Support for custom pure-Typescript response middleware.
- Lambda support.
- HTTPS support.
- Middleware customisation support, or the ability to configure different Rust middlewares from Typescript.
- Union support.
- Build for different OS and arch.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestserverRust server SDKRust server SDKtypescript-serverTypescript server SDKTypescript server SDKx-large