Applications
Reboot applications are defined using an instance of Application
, and launched from the file
configured as your --application
in .rbtrc
.
Application
Your entrypoint will construct an Application
and then run
it:
- Python
- TypeScript
async def main():
await Application(
servicers=[HelloServicer],
initialize=initialize,
).run()
if __name__ == '__main__':
asyncio.run(main())
new Application({
servicers: [HelloServicer],
initialize,
}).run();
initialize
functions
The optional initialize
argument to the Application
constructor is a function that
runs every time your application starts up.
Initializers can be used to create any initial state that your application needs. In particular, they are usually where any singleton states used by your application are created.
- Python
- TypeScript
async def initialize(context: InitializeContext):
hello = Hello.ref(EXAMPLE_STATE_MACHINE_ID)
# Implicitly construct state machine upon first write.
await hello.Send(
context,
message="Hello, World!",
)
const initialize = async (context) => {
const hello = Hello.ref("hello-nodejs");
await hello.send(context, { message: "Hello, World!" });
};
If you have declared an initialize
function, then you can additionally pass an
initialize_bearer_token
(initializeBearerToken
in TypeScript) which the initialize
method
should use to authenticate itself to your application.