GithubHelp home page GithubHelp logo

daheige / distlock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from go-locks/distlock

0.0 1.0 0.0 22 KB

The universal component of distributed locks in golang , support redis and postgresql

License: Apache License 2.0

Go 100.00%

distlock's Introduction

Go-Locks License

通用的Golang分布式锁组件,更多使用案例详见 examples

Driver列表

若有意向贡献未完成的驱动代码,请通过 ISSUES 或 邮箱 [email protected] 联系我

Driver 代码完成度 测试完成度 依赖包 使用说明
redis 100% 100% letsfire/redigo 详见 README.md
pgsql 100% 100% lib/pq 详见 README.md
etcd 未完成 未测试 etcd/client 详见 README.md
etcdv3 未完成 未测试 etcd/clientv3 详见 README.md

方法说明

配置项 mutex.OptFunc 以及返回值锁的使用详见 mutex/README.md

  • NewMutex(name string, optFuncs ...mutex.OptFunc) (*mutex.Mutex, error)
    创建互斥锁,若 name 已用于创建读写锁则返回 error,本方法单例模式
  • NewRWMutex(name string, optFuncs ...mutex.OptFunc) (*mutex.RWMutex, error)
    创建读写锁,若 name 已用于创建互斥锁则返回 error,本方法单例模式

注意事项

  • 不可重入(如果您有强烈的需求场景,请通过 ISSUES 提供反馈)
  • 非公平锁(Golang的本地锁 sync.Locker 视乎也不是公平锁,若您有需求或建议,请通过 ISSUES 提供反馈)
  • 有互斥锁 mutex 和 读写锁 rwmutex 两种类型,具体支持程度详见各个 Driver 对应的 README.md
  • 虽有完整的单元测试,但暂未经过实际项目考验,故慎用于生产环境,如有问题请通过 ISSUES 来共同完善

项目结构

  • 主线调用层级为 distlock.go -> mutex.go -> driver.go
  • distlock.go 提供了创建锁的工厂类,单例模式(相同名称的锁有且仅有一个,有且仅为一种)
  • mutex.go提供了各类锁的实现,欢迎各位同学贡献其他类型锁,详见 mutex/README.md
  • driver.go提供驱动接口的定义,欢迎各位同学贡献其他驱动,详见 driver/README.md

distlock's People

Contributors

letsfire avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.