Shared lock service
Allows other services to work with shared locks
Setup
Use the template EVA_DIR/share/svc-tpl/svc-tpl-locker.yml:
# Locker service
command: svc/eva-svc-locker
bus:
path: var/bus.ipc
config:
locks:
- lock1
- lock2
- lock3
user: nobody
Create the service using eva-shell:
eva svc create eva.svc.locker1 /opt/eva4/share/svc-tpl/svc-tpl-locker.yml
or using the bus CLI client:
cd /opt/eva4
cat DEPLOY.yml | ./bin/yml2mp | \
./sbin/bus ./var/bus.ipc rpc call eva.core svc.deploy -
(see eva.core::svc.deploy for more info)
EAPI methods
See EAPI commons for the common information about the bus, types, errors and RPC calls.
list
Description |
List status of all locks |
Parameters |
none |
Returns |
List of lock status |
Return payload example:
[
{
"id": "lock1",
"locked": false
},
{
"id": "lock2",
"locked": true
},
]
lock
Description |
Acquire a shared lock |
Parameters |
required |
Returns |
nothing |
Name |
Type |
Description |
Required |
i |
String |
lock ID |
yes |
expires |
f64 |
auto-release timer (seconds) |
yes |
timeout |
f64 |
max operation timeout (seconds) |
no |
status
Description |
Get status of a lock |
Parameters |
required |
Returns |
Lock status (struct) |
Name |
Type |
Description |
Required |
i |
String |
lock ID |
yes |
Return payload example:
{
"id": "lock1",
"locked": false
}
unlock
Description |
Unlock previously acquired lock |
Parameters |
required |
Returns |
nothing |
Name |
Type |
Description |
Required |
i |
String |
lock ID |
yes |