#You and Kyle did all the work there...
1 messages ยท Page 1 of 1 (latest)
All else being equal, it's nicer to have a lot of parameters rather than one single parameter that points to a separate config since parameters show up as part of the Function's schema and thus give any callers nice type-checking when invoking the Function.
However, it's definitely annoying to have to write a ton of parameters to a go function (and IIRC there's some relatively low limit imposed by the go compiler).
One other option is to use a builder pattern to allow users to configure parameters one-at-a-time. These are the With* you'll see some other modules using. I'm looking for a good example...
One example here: https://github.com/quartz-technology/daggerverse/blob/9ce087b83aa8b85f828d7d92ce39bd7c055cfc0f/node/node.go#L12
Basically, you can store state in the struct and let users configure that state via methods like WithVersion there. There's probably better examples out there, that's just the first one I found. Can explain more if helpful
There's also going to be another option available soon thanks to this PR from @drowsy rivet, which will allow you to accept custom structs as inputs to functions https://github.com/dagger/dagger/pull/6102
That should allow you to group parameters together in a struct rather than make them all direct parameters to the function.
very nice example. thank you Erik!
looks promising!
good points about the parameter visibility and type checking. at some point the visibility suffers when you have way too many parameters where everything gets lost ๐ really appreciate your pointers
@lost pawn ๐
Thanks @true drift ! We are in contact now and @ebon mauve graciously agreed to demo it tomorrow during the community call ๐
Sweet!
all good ๐