Tasks - Data Source "test"
Options
![Mauro Mequelussi-1595850](https://us.v-cdn.net/6037124/user_avatars/1595850.jpg)
Mauro Mequelussi-1595850
Member ✭
I saw that it is not possible to use the Data Source "test" in a task.
This is very important, to validate an environment or an update before putting it into production.
If I had a Utility Function that could be set as a Data Source it would be very practical, because we could use a generic conditional logic:
For example: Utility Function (Set Data-Source)
If datasource = test then
Set Data-Source
Or it could even be used in the Utility Function (Set Header) with the parameters that we already used in the X-Data-Source endpoint.
This is very important, to validate an environment or an update before putting it into production.
If I had a Utility Function that could be set as a Data Source it would be very practical, because we could use a generic conditional logic:
For example: Utility Function (Set Data-Source)
If datasource = test then
Set Data-Source
Or it could even be used in the Utility Function (Set Header) with the parameters that we already used in the X-Data-Source endpoint.
Comments
-
the issue with that is that it would potentially allow you to mix/match data sources which doesn't work. Good idea though. We 100% want to support this.
I think the solution will be to just have it be an option in the task settings. -
This would be perfect too, because we can leave it as a test when creating and then change it to production.
And in an update it is possible to duplicate and test and then change. Do you have any predictions of this being possible? -
Does this option have any plans to be implemented?
-
yep - should be coming this week.
-
this is now live.... you can set this in the task settings.
there will also be a label on the task so you know if there is a data source other than the primary live one. -
One question I had is about REDIS. When the data-source is "test" the redis server is separate, otherwise it will cause problems with tasks if it stays in a single one, because it won't fetch the data and won't have it.
I usually use the following logic:
I create actions in the endppoints and some tasks I play in redis to execute through a background action. -
Good point! We need to have an environment variable that represents the datasource. Then you can use that in your cache key if you want.
-
Can you give a practical example?
-
sure - lets say you are storing something named vault for a user in redis.
You would pick a key called this.
vault:%d, !auth id
So user 1 would have a key vault:1, and user 2 would have a key vault:2.
When a datasource is involved, then you would just update the key to the following.
vault:%d:%s, auth id, env datasource
So user 1 would be vault:1:live for the live datasource and vault:1:test for the test datasource. -
[Captura de Tela 2022-05-07 às 15.46.57.png]That's the only way to get the data source, right?
It doesn't have an Environment Variables for that. -
But how will he know the data source if a taks comes, it won't come in the header. It would be interesting to create this environment variable by default.
-
whoops - issue with the build. Just fixed this.
There is a new environment variable you can use. https://docs.xano.com/working-with-data/variables#environment-variables -
Now it was perfect. I've already made the adjustments here. Thank you so much again.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback