Stream: general

Topic: composing components vs factories


view this post on Zulip Kristopher Wuollett (Feb 06 2024 at 21:58):

How should one approach building "robot legs", i.e., multiple instances of the same interface, with the component model? Is it like the aliases in the composed component like in the complex-import example? Or should component developers essentially be building a record factory like open_connection in wasi-sql... and then the controller of the runtime/linker then have a proxy component that manages connections and forwards requests to various host implementations?

view this post on Zulip Alex Crichton (Feb 07 2024 at 01:49):

If the interface cannot be statically enumerated then putting the interface behind a resource might be a way to go. That way you'd have a dynamic "load the interface" function.

If you can statically enumerate the interfaces then that's not super well supported right now in the sense that you can't import a WIT interface under multiple names (you'd have to duplicate the interface). That may make sense to use a reosurce and then have static functions returning the resource perhaps

view this post on Zulip Kristopher Wuollett (Feb 07 2024 at 02:23):

Cool, thanks! I'm catching up again with components, I guess I didn't see resource before. I also somehow just misread that the open_connection returned a connection which is a resource type, and not record.

view this post on Zulip Josh Mandel (Mar 25 2024 at 03:40):

Are there standard interfaces or patterns for dynamic instantiation of components implementing a specific interface?

For example (sorry, this is maybe silly) consider a secret store that manages CRUD over secrets, but users upload each "secret" as a WASM component that exposes functions like "getName" and "sign(payload)". This store wants to instantiate each component that's currently stored. Are there standard interfaces for performing this kind of dynamic instantiation from within a wasm component?

view this post on Zulip Alex Crichton (Mar 25 2024 at 14:58):

Currently components themselves cannot model dynamic instantiation, so in some sense this is a feature not specified in the component model. That being said it's always possible for embedders to have extra support on the host itself to do things like this, so there's nothing precluding it in that respect. It'd be a host convention though as opposed to something codified in a component itself.

view this post on Zulip Josh Mandel (Mar 25 2024 at 19:36):

It'd be a host convention though as opposed to something codified in a component itself.

OK, thanks! I'd imagine there might (someday) be interest in standardizing what this interface looks like (similar to filesystem access -- so a host has to participate, but the interface is consistent across components) But in the near term can explore supporting this ad-hoc.


Last updated: Dec 23 2024 at 12:05 UTC