Repository navigation
feat: add a process-/thread-safe file-based ResourceLocker - #1274
Conversation
No, since the other lockers also don't clear out their files on exit. We might want to have a solution where all lock-related files get removed on server start actually: #1085
Did some historical digging to find the source of the name: #28 (comment) The change to memory/file locker makes sense to me but I'm going to ping @RubenVerborgh since he suggested the original name.
I would change all default configs that use a file-based backend (or at least use one for the internal data such as |
|
I don't mind about the naming, but shall we instead add a warning mechanism to |
I'll look into the kind of scenarios where we can put warnings in. And report back with my suggestions. |
Right now this is present in the RedisLocker too, so I might want to change that then |
It's not that it's a bad thing to do, it's just that it doesn't solve the problem of there being keys in case the server crashed. |
6594b4b to
9f645e3
Compare
9f645e3 to
3453f77
Compare
|
Little update:
|
|
I've pushed two small updates:
|
c16e15a to
a1fa062
Compare
a1fa062 to
d35719e
Compare
jvherweg
left a comment
There was a problem hiding this comment.
Looks good, just some minor comments.
| import type { ResourceLocker } from './ResourceLocker'; | ||
|
|
||
| const defaultLockOptions: LockOptions = { | ||
| /** Resolve symlinks using realpath, defaults to true (note that if true, the file must exist previously) */ |
There was a problem hiding this comment.
Perhaps instead of having a line giving the generic explanation of how the field works, instead have a comment here and below explaining why we set it to false? Are there things that would break if someone sets this to true? If yes this should not be a default option but a forced option in the constructor instead.
Yes, but this is not a constructor object. It is already marked as |
d35719e to
5c0f7eb
Compare
5c0f7eb to
6be6e82
Compare
test: unit test succeeds fix: not quiting loop when releasing unexisting lock refactor: pull wait() function into TimerUtils feat: store all locks inside a single lock folder feat: use md5 hashing for filepath hashes test: coverage back to 100% fix: store locks in proper .internal/locks folder feat: reworked tryfn test: coverage back to 100% buidl: package json types next to lib style: linting dos: add more documentation to Locker classes refactor: SingleThreadedResourceLocker -> MemoryResourceLocker refactor: MultiThreadedResourceLocker -> FileSystemResourceLocker feat: update all file-based backend configs to use the new FileSystemResourceLocker feat: add warning on starting the MemoryResourceLocker in a worker process test: coverage back to 100% fix: finalizer of file.json was configured wrong docs: updated release notes for 5.0.0 refactor: incorporated changes so far refactor: retryFunctions are less complex now test: jitter fix
Ah yea, my mistake. I was mixing it up with the AttemptSettings. |
📁 Related issues
#324
#309
✍️ Description
This PR adds a process- and thread-safe file-based ResourceLocker. It uses the proper-lockfile library.
{rootFilePath}/.internal/locks/+md5hash(identifier.path)+/(yes -- they are directories)config/util/resource-locker/file.jsonfile was added too.❓Open questions
Naming
I've now opted to call this MultiThreadedResourceLocker (in accordance to the existing SingleThreadedResourceLocker).
I wonder if it wouldn't be better to call these ResourceLockers after what they do:
I understand the idea of calling them towards there thread-safety use, but multi and single threaded in a nodejs context is somewhat of a misnomer anyway...
Configs
What kind of top-level configs should be added now that we have this locker? This might be more suited as discussion in the #309 issue though (together with the now existing RedisLocker).
✅ PR check list
Before this pull request can be merged, a core maintainer will check whether