Skip to content

skafandri/SynchronizedBundle

 
 

Repository files navigation

#SynchronizedBundle Build Status Coverage Status Scrutinizer Code Quality

##Instalation via composer

require: {"symfony-micro-services/synchronized-bundle": "dev-master"}

and load the bundle in your AppKernel.php

new Sms\SynchronizedBundle()

##Usage SynchronizedBundle lets you easily manage access to critical resources in a distributed environment.

Suppose you have the following service

class Processor
{
    public function critical()
    {
        //do stuff
    }
}

You need to guarantee that only one process can execute the critical method. There are several locking techniques to achieve it. We try to group most of them in SynchronizedBundle and provide a configuration only easy to use interface.

For instance, the minimum configuration you need to achieve the previous lock is

synchronized:
    driver: "file"
    locks:
        - {service: my_processor, method: critical, driver: file}

##Drivers

driver name details
debug Does no locking, useful for dev mode
file uses flock
If intended to use in a production environment, make sure the path you use is shared across all your servers (ie. network mount)
mysql Not implemented yet
memcache Not implemented yet
redis Not implemented yet
mongodb Not implemented yet
mariadb Not implemented yet
postgresql Not implemented yet
mssql Not implemented yet

##Contributing All contributions are welcome.

  • Fork
  • Do the magic
  • Pull request

##Tests To run the tests simply run phpunit. SynchronizedBundle has 100% code coverage.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%