In our (future) setup we have many worker nodes executing tests, which want to store log files and artifacts in swift. We want to keep the entire history, thus want to create a pseudo-directory structure like either
- /project/version/67/, i. e. ascending numbers, or
- /project/version/YYYYMMDD-HHMMS.n/, i. e. time stamp based, with an extra suffix if two workers write a log at the same time; that suffix could just be an ascending number or a mktemp-like suffix (which doesn't sort, though).
I did not find any way of either getting a global counter, or atomically creating an object so that other writers won't use the same pseudo-dir-name, or getting a lock for exclusive access.
One could dramatically reduce the probability of collisions by using the format YYYYMMDD-HHMMS.XXXXXX where the Xes are a tmpname() random suffix. But that looks ugly, destroys the sorted order (for traversing from most recent to older logs), and only makes the problem smaller but doesn't fix it.
How does one create unique object names with concurrent writers in swift?
Thanks in advance!