booster icon indicating copy to clipboard operation
booster copied to clipboard

Handle multiple functions per Rocket

Open gonzalogarciajaubert opened this issue 2 years ago • 0 comments

Feature Request

Description

Booster allows to register several functions in the same Rocket using the "registerRocketFunction" method but does not handle it correctly. It not possible to use more than one of those functions.

There are some issues to solve:

Don't use an environment variable to dispatch a Rocket function.

Booster core use the environment variable BOOSTER_ROCKET_FUNCTION_ID to know the id of the function to dispatch:

  public dispatch(request: unknown): Promise<unknown> {
    const rocketFunctionID = process.env[rocketFunctionIDEnvVar]
    if (!rocketFunctionID) {
      throw new Error(
        `Attempt to execute a rocket function but the ID is missing. Did you forget to set the ID in the environment variable "${rocketFunctionIDEnvVar}"?`
      )
    }
    const rocketFunction = this.config.getRegisteredRocketFunction(rocketFunctionID)
    if (!rocketFunction) {
      throw new Error(
        `Rocket function with ID "${rocketFunctionID}" not found. Did you forget registering the function with "config.registerRocketFunction()"?`
      )
    }
    return rocketFunction(this.config, request)
  }

The request object should provide this id

Figure out how to deploy several Azure functions

Azure provider is using the method getFunctionAppName (that should be provided by the Rocket) to know the function name and to deploy one function. We need to figure out how to be able to deploy several functions and remove this method.

gonzalogarciajaubert avatar May 31 '22 08:05 gonzalogarciajaubert