Prophet::Replica
A base class for all Prophet replicas.
Determines what replica class to use and instantiates it. Returns the new replica object.
Takes a key and a value.
Store some bit of metadata in a durable local datastore. Metadata isn't propagated when replicas are synced.
Returns true or false.
Takes a scalar key.
Fetches a bit of metadata from the local metadata store.
Returns the value of the key found in the local metadata store.
Returns undef if there's no value for the key in the local metadata store.
Returns the replica class for the given url based on its scheme.
Given a Prophet::Replica to import changes from, traverse all the changesets we haven't seen before and integrate them into this replica.
This routine calls traverse_changesets on the 'from' replica, passing in the most recent changeset the current replica has seen and a callback routine which calls integrate_changeset on the local replica.
That callback itself takes a callback, after_integrate_changeset , which a replica implementation can use to perform some action after a changeset is integrated into a peer. after_integrate_changeset takes a paramhash, currently with only a single key, 'changeset'.
Takes a Prophet::Replica object (and possibly some optional arguments) and imports its resolution changesets into this replica's resolution database.
Returns immediately if either the source replica or the target replica lack a resolution database.
Given a Prophet::ChangeSet, integrate each and every change within that changeset into the handle's replica.
If there are conflicts, generate a nullification change, figure out a conflict resolution and apply the nullification, original change and resolution all at once (as three separate changes).
If there are no conflicts, just apply the change.
This routine also records that we've seen this changeset (and hence everything before it) from both the peer who sent it to us AND the replica which originally created it.
If the state handle is in the middle of an edit, the integration of this changeset is recorded as part of that edit; if not, it is recorded as a new edit.
Returns the last changeset id seen from the replica identified by $SOURCE_UUID.
Returns true if we've previously integrated this changeset, even if we originally received it from a different peer.
Returns true if any change that's part of this changeset won't apply cleanly to the head of the current replica.
Returns a "" in Prophet::Conflict object if the supplied "" in Prophet::ChangeSet will generate conflicts if applied to the current replica.
Returns undef if the current changeset wouldn't generate a conflict.
Returns true if this replica hasn't yet seen the changeset changeset.
changeset
Fetch all changesets from this replica after the local sequence number SEQUENCE_NO.
Returns a reference to an array of "" in Prophet::ChangeSet objects.
See also traverse_changesets for replica implementations to provide streamly interface.
Returns this replica's uuid.
Returns the sequence # of the most recently committed changeset.
Finds or creates a LUID for the given UUID.
Finds the UUID for the given LUID. Returns undef if the LUID is not known.
undef
Given a UUID => LUID hash mapping, return a new unused LUID (one higher than the mapping's current highest luid).
Returns a reference to the parsed JSON contents of the file given by $PATH in the replica's userdata directory.
$PATH
Returns $DEFAULT if the file does not exist.
$DEFAULT
serializes $VALUE to JSON and writes it to the file given by $PATH in the replica's userdata directory, creating parent directories as necessary.
$VALUE
A string representing the name of the file where replica URLs that have been previously pulled from are cached.
Returns a list of cached upstream replica URLs, or an empty list if there are no cached URLs.
writes the replica URLs given by @REPLICAS to the upstream replica cache file.
@REPLICAS
The file in the replica's userdata directory which contains a serialized JSON UUID => LUID hash mapping.
Returns a UUID => LUID hashref for this replica.
Writes the given UUID => LUID hash map to /_guid2luid_file as serialized JSON.
/_guid2luid_file
Returns a LUID => UUID hashref for this replica.
Walk through each changeset in the replica after SEQUENCE_NO, calling the callback for each one in turn.
callback
Returns true if this source is one we know how to read from (and have permission to do so).
Returns true if this source is one we know how to write to (and have permission to write to).
Returns false otherwise.
Given a resolution changeset, record all the resolution changesets as well as resolution records in the local resolution database.
Called ONLY on local resolution creation. (Synced resolutions are just synced as records.)
Inside an edit (transaction), integrate all changes in this changeset and then call the _after_record_changes() hook.
This routine is called by "record_changes" with a Prophet::ChangeSet object. It integrates all changes from that object into the current replica.
All bookkeeping, such as opening and closing an edit, is done by "record_changes".
If your replica type needs to play games to integrate multiple changes as a single record, this is what you'd override.
Integrates the given change into the current replica. Used in "integrate_changes".
This routine records the immediately upstream and original source uuid and sequence numbers for this changeset. Prophet uses this data to make sane choices about later replay and merge operations
Returns this replica's UUID.
Create a new record of type $TYPE with uuid $UUID within the current replica.
$TYPE
$UUID
Sets the record's properties to the key-value hash passed in as the props argument.
props
If called from within an edit, it uses the current edit. Otherwise it manufactures and finalizes one of its own.
Deletes the record $UUID of type $TYPE from the current replica.
Manufactures its own new edit if $self-current_edit> is undefined.
$self-
Updates the record of type $TYPE with uuid $UUID to set each property defined by the props hash. It does NOT alter any property not defined by the props hash.
Manufactures its own current edit if none exists.
Returns a hashref of all properties for the record of type $TYPE with uuid $UUID.
'root' is an optional argument which you can use to pass in an alternate historical version of the replica to inspect. Code to look at the immediately previous version of a record might look like:
$handle->get_record_props( type => $record->type, uuid => $record->uuid, root => $self->repo_handle->fs->revision_root( $self->repo_handle->fs->youngest_rev - 1 ) );
Returns true if the record in question exists and false otherwise.
Returns a reference to a list of all the records of type $TYPE.
Returns a reference to a list of all the known types in your Prophet database.
Returns true if we have any records of type $TYPE.
Called after the replica has integrated a new changeset but before closing the current transaction/edit.
The SVN backend, for example, used this to record author metadata about this changeset.
Sets original_source_uuid and original_sequence_no for the current edit.
original_source_uuid
original_sequence_no
Logs the given message to STDERR (but only if the PROPHET_DEBUG environmental variable is set).
STDERR
PROPHET_DEBUG
Logs the given message and dies with a stack trace.
The string to use as the creator of a changeset.
If the user has a "friendly" name for this replica, then use it. Otherwise, display the replica's uuid.
If you pass in a uuid, it will be used instead of the replica's uuid.
To install Prophet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prophet
CPAN shell
perl -MCPAN -e shell install Prophet
For more information on module installation, please visit the detailed CPAN module installation guide.