Skip to content

demdxx/interlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interlock

Build Status Coverage Status Go Report Card

Package implements inter service lock based on different external storages.

Example

package main

import (
  "fmt"
  "log"
  "time"

  "github.com/demdxx/interlock/redislock"
  "github.com/demdxx/interlock"
)

func main() {
  const defaultLifetime = time.Minute
  rlock, err := redislock.NewByURL(`redis://host:3456/1?pool=10&max_retries=2&idle_cons=2`, defaultLifetime)
  if err != nil {
    log.Fatal(err)
  }

  if rlock.TryLock("start") {
    fmt.Println("I'm the first!")
  } else {
    fmt.Println("Someone ran first")
  }
}

TODO

  • Zookeeper
  • Consul
  • Aerospike
  • Memcached
  • Redis

Releases

No releases published

Packages

No packages published

Languages