PHP Класс izzum\statemachine\persistence\MongoDB

MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. MongoDB obviates the need for an Object Relational Mapping (ORM) to facilitate development. start macosx: mongod --config /usr/local/etc/mongod.conf mongo shell: mongo
Наследование: extends Adapter, implements izzum\statemachine\loader\Loader
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$dns string the data source name for a mongo connection
$driver_options array the php driver specific options
$options array connection options

Открытые методы

Метод Описание
__construct ( string $dns = 'mongodb://localhost:27017', array $options = ["connect" => true], array $driver_options = [] ) constructor. a connection to mongodb via the mongoclient will be lazily created.
__toString ( )
getClient ( ) : MongoClient Gets a lazy loaded \MongoClient instance.
getEntityIds ( $machine, $state = null ) {@inheritDoc}
isPersisted ( Identifier $identifier ) {@inheritDoc}
load ( StateMachine $statemachine ) {@inheritDoc} Load the statemachine via a document in a mongodb collection.
processGetState ( Identifier $identifier ) {@inheritDoc}
setClient ( MongoClient $client ) sets a mongoclient. this can be useful if your application already has a mongoclient instantiated and you want to reuse it.
toString ( )

Защищенные методы

Метод Описание
addHistory ( Identifier $identifier, $state, $message = null, $is_exception = false ) {@inheritDoc}
checkAndCreateIndexesIfNecessary ( number $check_index_once_in = 1000 ) since we do not want to burden a client of this code with the responsiblity of creating indexes, we take a statistical approach to check if we need to create an index in the background. This will only be done once.
createIndexes ( ) create indexes in the background for the collections used. this will only be done by mongo if they do not exist already.
insertState ( Identifier $identifier, $state, $message = null ) {@inheritDoc}
onConnect ( ) A hook to use in a subclass.
updateState ( Identifier $identifier, $state, $message = null ) {@inheritDoc}

Описание методов

__construct() публичный Метод

an existing mongoclient can also be set on this class (reuse a client accross your application)
public __construct ( string $dns = 'mongodb://localhost:27017', array $options = ["connect" => true], array $driver_options = [] )
$dns string the data source name. mongodb://[username:password@]host1[:port1][,host2[:port2:],...]
$options array server options (usable for authentication, replicasets etc)
$driver_options array php specifif driver options

__toString() публичный Метод

public __toString ( )

addHistory() защищенный Метод

{@inheritDoc}
protected addHistory ( Identifier $identifier, $state, $message = null, $is_exception = false )
$identifier izzum\statemachine\Identifier

checkAndCreateIndexesIfNecessary() защищенный Метод

since we do not want to burden a client of this code with the responsiblity of creating indexes, we take a statistical approach to check if we need to create an index in the background. This will only be done once.
protected checkAndCreateIndexesIfNecessary ( number $check_index_once_in = 1000 )
$check_index_once_in number check for index creation. on average, every times the index should be created if it is not there already

createIndexes() защищенный Метод

create indexes in the background for the collections used. this will only be done by mongo if they do not exist already.
protected createIndexes ( )

getClient() публичный Метод

Gets a lazy loaded \MongoClient instance.
public getClient ( ) : MongoClient
Результат MongoClient

getEntityIds() публичный Метод

{@inheritDoc}
public getEntityIds ( $machine, $state = null )

insertState() защищенный Метод

{@inheritDoc}
protected insertState ( Identifier $identifier, $state, $message = null )
$identifier izzum\statemachine\Identifier

isPersisted() публичный Метод

{@inheritDoc}
public isPersisted ( Identifier $identifier )
$identifier izzum\statemachine\Identifier

load() публичный Метод

The document, originally loaded as a json string (see JSON::getJSONSchema) is stored at the mongodb collection 'configuration' by default. multiple machine definitions can be provided in a single document, or in multiple documents in the collection. The first document containing the 'machines.name' key with the value matching the name of the $statemachine is used. You could use the ReaderWriterDelegator to use another source to load the configuration from.
public load ( StateMachine $statemachine )
$statemachine izzum\statemachine\StateMachine

onConnect() защищенный Метод

you can do you initial setup here if you like.
protected onConnect ( )

processGetState() публичный Метод

{@inheritDoc}
public processGetState ( Identifier $identifier )
$identifier izzum\statemachine\Identifier

setClient() публичный Метод

sets a mongoclient. this can be useful if your application already has a mongoclient instantiated and you want to reuse it.
public setClient ( MongoClient $client )
$client MongoClient

toString() публичный Метод

public toString ( )

updateState() защищенный Метод

{@inheritDoc}
protected updateState ( Identifier $identifier, $state, $message = null )
$identifier izzum\statemachine\Identifier

Описание свойств

$dns защищенное свойство

the data source name for a mongo connection
protected string $dns
Результат string

$driver_options защищенное свойство

the php driver specific options
protected array $driver_options
Результат array

$options защищенное свойство

connection options
protected array $options
Результат array