Skip to content

Simple CLI integration #36

@splitice

Description

@splitice

Thank you for your hard work. Been reading through this and the few other implementations of distributed locking systems. A uniquely simple design in this case. Effectively you take the lock for (default) 10 seconds and keep renewing it preventing expiration (every 3 seconds). Simple design and K8S services while they can be a bit jittery should be reliable on that scale. Competition between acquiring workers being handled by a race to insert.

I don't do anything normally with golang so correct me if I am wrong.

Any chance that an (example?) of a CLI application could be developed that could be usable from scripting languages? This would make your work accessible from sh/bash (or any other scripting language supporting shell commands - i.e most of them)? I suspect even languages like PHP and python could make use of it via proc open type interfaces.

My thoughts regarding API:

#!/bin/bash

keyname="our key"

# take lock $keyname
k8lock $keyname &
lockpid=$!

do_stuff

# signal for clean exit
kill -sHUP $lockpid
wait $lockpid

distlock should also monitor it's parent pid for exit (and release the lock accordingly i.e in case of crash).

In C I would do this with a signal handler on SIGHUP and use PR_SET_PDEATHSIG to ensure a SIGHUP is received on parent death for that graceful cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions