question

Function container execution

How to execute function container (B) from another function container (A)? More details: I want to execute container A function and inside execution process I want to decide (based on some paramaters passed to the function and additional logic) how many function B I want to execute (how many containers with B function I want to start).

avatar
5
  • Hey Dawid, thats a great question, thanks for asking.

    There are two ways to fire a function container. One is through associating the function to a linked record and letting the load balancer handle the claim/spawn/release sequence. While this is the simplest way, what you're describing actually sounds like you'd want option 2.

    Option 2 is to use the scheduler API directly. In this case you could not only make your decision based on events and parameters, but you can also pass additional information on to the function.

    Let me know if that works out for ya :)

    avatar
    platform
  • the second option should be ok, thanks!

    avatar
  • Hi Chris, can you check the scheduler API link? It looks like the API is not working. Could you confirm the endpoint and authorization process? Thanks

    avatar
  • Thanks cycle.io team for any guidance! First of all - remember to call the scheduler API from inside the cycle environment (cycle container). Example of API call:

    curl --location 'http://env-scheduler/v1/functions/{contianer_id}/claim' --header 'Content-Type: application/json' --header 'X-CYCLE-ACCESS-KEY: ***' --data '{ "payload": "123456789" }'

    and after:

    curl --location 'http://env-scheduler/v1/functions/{conteiner_id}/spawn' --header 'Content-Type: application/json' --header 'X-CYCLE-ACCESS-KEY: ****' --data '{ "token": "123456789", "instance_id": "instance_id_from_previous_call" }'

    avatar
  • Thanks for adding this Dawid! It was great to work through this with y'all!

    avatar
    platform
v2024.12.08.01 © 2024 Petrichor Holdings, Inc.