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
파일 보기 프로젝트 열기: rolfvreijdenberger/izzum-statemachine 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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