uber / zanzibar

A build system & configuration system to generate versioned API gateways.
MIT License
464 stars 68 forks source link

Support custom import path #901

Closed chirayu closed 1 year ago

chirayu commented 1 year ago

CustomImportPath is used by Zanzibar in its "wiring logic" for clients and middlewares. With a custom import path, the source code of middlewares and clients can reside in path different from the location of the config files.

CustomImportPath is only supported for middlewares and clients with CustomInitialisation set to true. This is done to reduce testing complexity since there are multiple path variables already in place in the configuration with varying degree of support.

Middlewares:

To include middleware code that resides in a custom path, the following config needs to be in place:

  1. CustomInitialisation is set to true
  2. config.path is set to the import path - this is required to include the middleware in the various endpoint files
  3. CustomImportPath is set to the import path - this is required to support middleware initialisation

Clients

To include client code that resides in a custom path, the following config needs to be in place:

  1. CustomInitialisation is set to true
  2. CustomImportPath is set to the import path - this is required to support client initialisation

Note for future

This approach is a stopgap to support inclusion of externally located middlewares and clients. Path handling should be much simpler. A component should have a config to specify if it is auto generated or user provided. For auto generated components, the path is Zanzibar provided and for the other one it is user provided. For the second case, user provided code must also provide initialisation logic - there is no value in Zanzibar generating that bit.

With this simplification - CustomInitialisation and CustomImportPath variables will no longer be required.