Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The relationship between routes, modules, and entrypoints #19

Closed
radu-matei opened this issue Jan 26, 2022 · 1 comment · Fixed by #57
Closed

The relationship between routes, modules, and entrypoints #19

radu-matei opened this issue Jan 26, 2022 · 1 comment · Fixed by #57
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@radu-matei
Copy link
Member

radu-matei commented Jan 26, 2022

Currently, Spin defines its triggers through a WebAssembly interface (through a WIT file).
Implementing a component (Wasm module) for a particular trigger means implementing its interface.

Because a module can only contain at most one implementation of the same interface (the function that implements the trigger is the "entrypoint" function, and is exported by name), it cannot export more than one such "entrypoint".
(the entrypoint can contain logic and call other functions, but directly, a trigger can currently only execute the one entrypoint).

With the HTTP trigger, one common scenario is writing multiple route handlers within the same "project".

How should this be handled with Spin? The two clear options at first are:

  • the entrypoint handles all routes / subroutes, and it should contain logic to call other functions in the module
  • one module corresponds to one route, each with an entrypoint that handles the single route, and it should be the responsibility of a higher level tool + configuration (ref Configuration for Spin applications #17) to assemble multiple such routes.

Note that this requires no actual implementation changes to the current HTTP trigger, but has an impact on configuration, documentation, and templates.

@radu-matei radu-matei added discussion documentation Improvements or additions to documentation labels Feb 7, 2022
@radu-matei
Copy link
Member Author

One thing that should be mentioned is that the same Wasm module can implement multiple interfaces at the same time, and could potentially be used as the entrypoint module for multiple triggers.

@radu-matei radu-matei added this to the v0.1.0 milestone Feb 7, 2022
This was referenced Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant