Open seungjin opened 12 months ago
Spin plugin for this?
@seungjin A plugin is an interesting idea. It could be something the user just remembers to run, or I think @cardoso designed the spin let
plugin (https://developer.fermyon.com/hub/preview/plugin_spinlet) to allow hooks so possibly it could be configured to automagically combine "includes" on spin let build
or spin let up
. But I'm not sure exactly what hooks spinlet provides.
@fibonacci1729 @michelleN I think you some ideas about this - do you have time to weigh in?
@seungjin I like this idea! I'm curious to hear more about your usecase and how you would like to use such a feature.
Are you thinking something like a new component section key (i.e. include
) in the spin.toml
that allows you to modularize components out into their own manifests, for example:
In spin.toml
:
spin_manifest_version = "1"
name = "my-app"
version = "0.1.0"
trigger = { type = "http", base = "/" }
[[component]]
include = "path/to/component.toml"
Where path/to/component.toml
looks like:
id = "my-component"
source = "path/to/wasm"
[trigger]
route = "/..."
# ... other component specific sections ...
@fibonacci1729 Exactly what I meant. Originally, I was thinking it's somewhat like a cargo workspace. Basically, it's the same concept, as you say.
My spin.toml is currently 170 lines and growing very fast. I can see it easily expanding to a few thousand lines.
So, having a dedicated spin config for each component with a root spin file that includes statements would give me a more organized and manageable development experience.
Currently, my structure is as follows: having one single spin file for dozens (possibly hundreds of components) is a pain to manage.
# tree -L 2
.
├── assets
│ ├── x.css
│ └── yew-app
├── bots
│ ├── rssbot_nyt (*)
│ └── rssbot_wsj (*)
├── Cargo.lock
├── Cargo.toml
├── common
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── src
│ └── target
├── my
│ ├── cert_checker (*)
│ ├── geoip (*)
│ ├── health (*)
│ ├── ifconfig (*)
│ ├── weather (*)
│ └── whoami (*)
├── root
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── src
│ └── target
├── spin.toml
├── templates
│ ├── 404.hbs
│ ├── 500.hbs
│ ├── cert_checker
│ ├── ifconfig
│ └── root
└── todos.md
(*): Individual cargo project/wasm component. Actually I have more than above and growing fast.
@seungjin A plugin is an interesting idea. It could be something the user just remembers to run, or I think @cardoso designed the
spin let
plugin ([developer.fermyon.com/hub/preview/plugin_spinlet]
@itowlson yep, that's exactly the sort of use case I was looking to explore first
@cardoso do you think this usecase is something that would be a good fit for spin let
? If so, because I'm not super familiar with the implementation of spin let
do you have an idea for how this might work/look as part of that experience?
Alternatively, since 2.0
is just around the corner, a few of us have been discussing baking "manifest modularity" into the manifest redesign. Something (hand-wavy) that looks like what was mentioned above. I'm going to start a proposal to further discuss this approach in the next few weeks.
Spin 2 is out. Is this feature in Spin 2? I am converting/improving my project to spin 2.0. It the feature is in spin 2. love to see it.
Correct: we weren't able to deliver everything in the time available, and we felt we could do this in a later minor version without breaking backward compatibility.
I can wait! Thanks!!
Okay, looking to define this more closely, particularly in the light of Spin 2 manifest changes.
Requirements
spin.toml
at runtime.What have I missed?
Challenges
This is going to need more than naive text inclusion, because:
[variables]
map. We can't interleave this the way we do triggers and components.Any others that come to mind?
Planning
[component.cart] definition = "cart/mod.toml"
but not write an entire trigger-plus-component in a child file. (This would also mean a child could not include its own child files). I'm not sure this delivers though, since I imagine triggers and components will often want to go together in child files.Other ideas for how to approach it?
We have discussed the possibility of adding a "component manifest" format for standalone reusable "library" component projects. It may be that the same idea could serve this purpose as well with the component projects appearing in subdirectories rather than separate repos.
After Spin 2 and getting an idea of component model, things changed. "Component manifest" format for reusable "library" component makes much sense to me. Thanks!
My spin.toml is getting bigger and bigger (A couple of hundred lines). If I can implement some sort of 'include' feature that allows me to modularize spin.toml's content into separate TOML files, it would be more organized and productive.