Idempotent creation of Fly Machines

It doesn’t seem possible to efficiently and idempotently create Fly Machines.

After sending out the POST /v1/apps/user-functions/machines request but failing to receive the response due to a network error, the client can retry the request safely and get back an HTTP 422 if the remote end has created the machine (with the same name) previously. But the client still does not know the ID of the machine. It has to query the “List Machines for an App” and find out the ID.

If there are a lot of machines in an app, the list operation would not be efficient - it is an O(n) query.

A solution would be to extend the “Get a Machine” or “List Machines for an App” API, or create a new API endpoint, to provide the ability to query a machine by name instead of ID.

1 Like

We’re working on improving both the “list machines” and “get machine” endpoints.

This is part of the solution we’re implementing.

Hope this helps!

2 Likes

Bringing blueboat to Fly, are we? :slight_smile:

Trying out mvSQLite + Blueboat on Fly :slight_smile:

1 Like

Exciting! Also: Fits the partner with fly anti-roadmap: Edge Workers · Issue #10 · superfly/anti-roadmap · GitHub