concourse / pool-resource

atomically manages the state of the world (e.g. external environments)
Apache License 2.0
54 stars 36 forks source link

Adds support for weighted lock #35

Open loganmzz opened 6 years ago

loganmzz commented 6 years ago

Description

Sometime a resource (as in lock management) can be split into sub-part. For example, Cloud Foundry quota, nodes in a distributed architecture, ...

So, it will be nice to support easily such kind of lock.

Proposal

Solution 1 : Pool metadata

Pool directory may contain metadata which describe pool & lock capacities. When acquired, lock weight may be specified and recorded into new file. When released, lock weight is read from same file.

Note: When lock weight isn't specified, all capacity is assumed.

Solution 2 : Multi acquire/release (simplest)

Users have to create enough locks as pool capacity. acquire now accepts a number (or adds acquire_count). A new count file is generated providing lock count (and/or a names file with lock names). Then, name.<index> and metadata.<index> are generated as existing.

release doesn't change signature but support new directory structure.

Workaround

Currently I use as enough lock as necessary.

But need: