-
Notifications
You must be signed in to change notification settings - Fork 159
Fix the custom function documentation #962
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
Comments
@ricardozanini @matthias-pichler-warrify @JBBianchi @fjtirado Should we maybe also add a new This would allow users to easily reference functions from imported catalogs, using the convenience concatenation feature. |
I think it might be useful indeed. I would still recommend the runtimes to also have a global configuration for catalogs (optional). For instance, if at the global level the runtime is configured with:
All workflows, by default, will be able to lookup those catalogs. Now, if the authors specifies the following in a definition:
It takes over the global configuration in favor of those. As I see it, the lookup order should be:
|
So for every function, I'll have to fetch all the catalogs to find the one? Custom functions must have a direct link to their catalog. I'd say an URI in this case fits better, like we do on GHA. function: mycatalog.com/repo/function-name |
If you added a catalog, yes. But you'd only need to fetch all cataloged functions only once at workflow start, so IMHO it's not really an issue. |
That's the default behavior indeed, as inspired by GHA 😉 |
I'm not sure what you mean by "fetch all the catalogs" but you'll have to consecutively lookup the function. For each custom function, it can lead to 0 request, if the function is declared within the workflow definition (or hosted locally), up to N requests, N being the number of catalogs configured (so in my examples above, up to 3 requests per custom function). In the end, nothing prevents the runtime from having a local cache for already resolved functions, but I don't think it needs to be covered by the spec. (On a side note, I don't find the doc in GHA about the use of fully qualified URI, it seems to either be |
@JBBianchi You are right, and we should probably do the same than GH to ensure that the referenced function always reside in a (GH) repository. So, good point, I believe we should only allow URIs relative to GH. |
I'm not so sure. Why can't a user have an internal catalog to share privately in the company? Or use gitlab (👿 )? Regarding the An import in the DSL complicates things; the cost/benefit here doesn't seem right. I don't see why not just using the URI reference straight to the function would be a problem. We should focus on keeping things simple. Adding more ways of doing the same is the opposite. Once we have it well established and from usage feedback, we understand that it's important to have such a feature, and we can easily add it to the spec later. Let's reference a free URI, not even defaulting to GH, to avoid bad practices like in container tags where people won't specify the |
We cannot fo that, because a custom function, just like in GHA, is a definition file, namely In other words, and while I think leaving free form URI reference is a dangerous and error prone, I think you are right in saying we need a broader use case than just GH.
I disagree. That's a feature we introduced in v0.8 (external resources) and it really simplifies the life of authors. Instead of having a potentially huge url to write, they can choose to import a catalog and drastically shorten references. IMHO, we should focus on that exactly: convenience for authors. Plus, if one doesn't like the overhead, she can choose to just not use that additional property in To conclude that feature is imho really cool and painless to implement, and could drastically shorten some definitions, so I think we should include it. |
Can we include Something like: uses github/serverlessworkflow/catalog as catalog
function:
call: catalog/log |
@ricardozanini yes, that is IMHO a great idea! |
I understand it might have an impact on execution time but I think iteration is a fundamental feature, not a limitation. As far as I know, most package managers operate this way: you have a list of registries, and when you install a package, the system iterates through them. Let me try to sum-up the different possibilities we mentioned so far, therefore we can maybe list the pros and cons of each approach. Embedded function declarationUse a custom function declared in the definition: document:
use:
functions:
myLogFn: //...
do:
- callCustomFn:
call: myLogFn Load a remote function directly from an URILoad the function directly from an URI: do:
- callCustomFn:
call: https://server.com/my-functions/my-log-fn/function.yaml Load a function using the default catalogWe assume runtime implement do:
- callCustomFn:
call: myLogFn:1.0.0 The runtime will fetch * Raises the question of the possibility to override the default and/or add other global catalogs. Load a function using a named catalogLoad the function from a specific catalog: document:
use:
catalogs:
myPrivateCatalog: https://private-catalog.com
do:
- callCustomFn:
call: myPrivateCatalog/myLogFn:1.0.0 The runtime will fetch (and only?*) * What if there is another global catalog with the same name ? In all cases, the one in the definition have the precedence. But should we ignore the global one or fallback onto it ? (I'd rather go for the fallback to be consistent with the next approach) Load a function using fallbacksWe assume runtime implement document:
use:
catalogs:
myPrivateCatalog: https://private-catalog.com
do:
- callCustomFn:
call: myLogFn:1.0.0 The runtime will fetch first Load a function using an aliasI assume we could "abuse" the system with aliases, by redefining a local function that calls a remote one: document:
use:
functions:
myLogFn:
call: https://private-catalog.com/myLogFn/1.0.0/function.yaml
//call: myLogFn/1.0.0
do:
- callCustomFn:
call: myLogFn Let's not forget the priority of constituencies, it "doesn't matter" if it's harder to implement, the usability comes first. From a user point of view, I assume all the examples above are valid. |
The issue in the catalog related to the topic: |
I think I prefer Load a function using a named catalog one, with a note. |
What would you like to be added:
Fix the documentation for custom functions.
Namely, we need to:
function.yaml
, as the name is defined by the function's directoryfunction.yaml
OR using the concatenation{name}:{version}
. This is however only be supported for cataloged functions.Why is this needed:
The documentation drifted away from latest changes made to the SW Catalog.
The text was updated successfully, but these errors were encountered: