highlander

command module
v0.0.0-...-6b9f1c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

README

A tiny mutex over the network

It might be useful when several distributed components have to organise access around one shared resource.

Build

go build -o highlander main.go

Example

./highlander 127.0.0.1:9000 10

The first call to "take_lock" will receive the lock name.

$ curl -s http://127.0.0.1:9000/take_lock
hrcBMnQa

Further attempts within the maximum expiry time (given as the second parameter, here: 10 seconds) will just give "busy".

$ curl -s http://127.0.0.1:9000/take_lock
busy

With the name, the lock can be released earlier.

$ curl -s http://127.0.0.1:9000/release_lock/hrcBMnQa
ok

So a new lock can be taken.

$ curl -s http://127.0.0.1:9000/take_lock
CLQxYaoc

A restart of the server process will also clear the lock, as everything happens simply in the process memory.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL