Tasks - Data Source "test"

Options
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.

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     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?
  • Mauro Mequelussi-1595850
    Options
     Does this option have any plans to be implemented?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    yep - should be coming this week.
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    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.
  • Mauro Mequelussi-1595850
    Options
     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.
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    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.
  • Mauro Mequelussi-1595850
    Options
     Can you give a practical example?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    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.
  • Mauro Mequelussi-1595850
    Options
     [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.
  • Mauro Mequelussi-1595850
    Options
    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.
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    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
  • Mauro Mequelussi-1595850
    Options
     Now it was perfect. I've already made the adjustments here. Thank you so much again.