Simba-Distributed-Mutex 分布式锁服务开源项目

我要开发同款
匿名用户2022年05月06日
117阅读

技术信息

开源地址
https://github.com/Ahoo-Wang/Simba
授权协议
Apache

作品详情

Simba旨在提供易用、灵活的分布式锁服务,支持多种存储后端实现:关系型数据库、Redis、Zookeeper。

安装GradleKotliDSL

valsimbaVersio="0.3.2";implemetatio("me.ahoo.simba:simba-sprig-boot-starter:${simbaVersio}") Mave<?xmlversio="1.0"ecodig="UTF-8"?><projectxmls="https://mave.apache.org/POM/4.0.0"xmls:xsi="https://www.w3.org/2001/XMLSchema-istace"xsi:schemaLocatio="https://mave.apache.org/POM/4.0.0https://mave.apache.org/xsd/mave-4.0.0.xsd"><modelVersio>4.0.0</modelVersio><artifactId>demo</artifactId><properties><simba.versio>0.3.2</simba.versio></properties><depedecies><depedecy><groupId>me.ahoo.simba</groupId><artifactId>simba-sprig-boot-starter</artifactId><versio>${simba.versio}</versio></depedecy></depedecies></project> applicatio.yamlsimba:jdbc:eabled:true#redis:#eabled:truesprig:datasource:url:jdbc:mysql://localhost:3306/simba_dbuserame:rootpassword:root Optioal-1:JdbcMutexCotedService

KotliDSL

valsimbaVersio="0.3.2";implemetatio("me.ahoo.simba:simba-jdbc:${simbaVersio}") createtablesimba_mutex(mutexvarchar(66)otullprimarykeycommet'mutexame',acquired_atbigitusigedotull,ttl_atbigitusigedotull,trasitio_atbigitusigedotull,ower_idchar(32)otull,versioitusigedotull); Optioal-2:RedisMutexCotedServiceKotliDSL

valsimbaVersio="0.3.2";implemetatio("me.ahoo.simba:simba-redis:${simbaVersio}")Optioal-3:ZookeeperMutexCotedServiceKotliDSL

valsimbaVersio="0.3.2";implemetatio("me.ahoo.simba:simba-zookeeper:${simbaVersio}") ExamplesSimba-Examples

使用入门MutexCotederMutexCotedServicecotedService=cotedServiceFactory.createMutexCotedService(ewAbstractMutexCoteder(mutex){@OverridepublicvoidoAcquired(MutexStatemutexState){log.ifo("oAcquired");}@OverridepublicvoidoReleased(MutexStatemutexState){log.ifo("oReleased");}});cotedService.start(); SimbaLockertry(Lockerlocker=ewSimbaLocker("mutex-locker",this.mutexCotedServiceFactory)){locker.acquire(Duratio.ofSecods(1));/***doSomethig*/}catch(Exceptioe){log.error(e.getMessage(),e);} SchedulerpublicclassExampleSchedulerextedsAbstractSchedulerimplemetsSmartLifecycle{publicExampleScheduler(MutexCotedServiceFactorycotedServiceFactory){super("example-scheduler",ScheduleCofig.ofDelay(Duratio.ofSecods(0),Duratio.ofSecods(10)),cotedServiceFactory);}@OverrideprotectedStriggetWorker(){retur"ExampleScheduler";}@Overrideprotectedvoidwork(){if(log.isIfoEabled()){log.ifo("dosomework!");}}}UseCasesGover-EvetBusCoSky

 

功能介绍

Simba 旨在提供易用、灵活的分布式锁服务,支持多种存储后端实现:关系型数据库、Redis、Zookeeper。 安装 Gradle Kotlin DSL val simbaVersi...

示例图片

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论