Coder Social home page Coder Social logo

Comments (6)

lann avatar lann commented on July 22, 2024

Labels are already a sort of variable in the context of a spin manifest. Could you share more about what you're trying to do here?

from spin.

ThorstenHans avatar ThorstenHans commented on July 22, 2024

What do you mean by labels?

What I'm trying to do here:

  • Have multiple components that should use the same key-value store
  • Prevent myself from having the actual name (magic string) of the key-value store in multiple places

Comparing both variants, no. 1 looks cleaner IMO:

Variant 1

#...

[variables]
store = { default = "data" }

[component.a]
source = "a/target/wasm32-wasi/release/a.wasm"
key_value_stores = ["{{ store }}"]

[component.a.variables]
store = "{{ store }}"

[component.b]
source = "b/target/wasm32-wasi/release/b.wasm"
key_value_stores = ["{{ store }}"]

[component.b.variables]
store = "{{ store }}"

# ...

Variant 2

#...

[component.a]
source = "a/target/wasm32-wasi/release/a.wasm"
key_value_stores = ["data"]

[component.a.variables]
store = "data"

[component.b]
source = "b/target/wasm32-wasi/release/b.wasm"
key_value_stores = ["data"]

[component.b.variables]
store = "data"

# ...

from spin.

lann avatar lann commented on July 22, 2024

Variant 3

#...

[component.a]
source = "a/target/wasm32-wasi/release/a.wasm"
key_value_stores = ["data"]

[component.b]
source = "b/target/wasm32-wasi/release/b.wasm"
key_value_stores = ["data"]

# ...

It looks like we aren't using the term "label" consistently in documentation, but it is the term for data in this example at least internally and in spin-cloud.

This label is already a "variable" in the sense that it is a arbitrary user-defined identifier that is shared between the manifest and code.

Actually, I think we want to actively avoid the pattern of making these labels dynamic; the long term goal is to use these labels as component model import names, which need to be static.

from spin.

lann avatar lann commented on July 22, 2024

Prevent myself from having the actual name (magic string) of the key-value store in multiple places

You still have a magic string: "store"; it is just adding an extra layer of indirection.

from spin.

ThorstenHans avatar ThorstenHans commented on July 22, 2024

Prevent myself from having the actual name (magic string) of the key-value store in multiple places

You still have a magic string: "store"; it is just adding an extra layer of indirection.

Yes but I need it only once 😄 which is actually the point I mentioned

from spin.

rylev avatar rylev commented on July 22, 2024

I'm also not so sure I understand what this feature would improve.

In the example above with a store labeled as "data" and a variable named "store" that points to that label, the amount of typing/repetition is the same whether you use the variable or not. I suppose if the store label were to change, you would only need to update it in one place, but this doesn't seem like something that will happen often, so I'm not sure the complexity of supporting a templating system is worth it.

from spin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.