[Bps-public-commit] Prophet branch, master, updated. 113da1f7b009729f2c7e6ae9c3ade7f65b6e3b42
jesse
jesse at bestpractical.com
Wed Aug 12 22:23:45 EDT 2009
The branch, master has been updated
via 113da1f7b009729f2c7e6ae9c3ade7f65b6e3b42 (commit)
from f9bdf3011982c370ac7642fcdc5c90bcdedac518 (commit)
Summary of changes:
lib/Prophet/App.pm | 6 ------
lib/Prophet/FilesystemReplica.pm | 4 ++--
lib/Prophet/ForeignReplica.pm | 2 +-
lib/Prophet/Record.pm | 2 +-
lib/Prophet/Replica.pm | 9 +++++++++
lib/Prophet/Replica/prophet.pm | 4 ++--
lib/Prophet/Replica/sqlite.pm | 6 +++---
lib/Prophet/Server/Dispatcher.pm | 2 +-
8 files changed, 19 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit 113da1f7b009729f2c7e6ae9c3ade7f65b6e3b42
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Aug 12 17:32:03 2009 -0400
refactor our uuid_generator into a replica-specific attribute
diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 4e8b1ef..18c254a 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -38,12 +38,6 @@ has config => (
);
-has uuid_generator => (
- is => 'rw',
- isa => 'Prophet::UUIDGenerator',
- default => sub { Prophet::UUIDGenerator->new( uuid_scheme => 1) }
-);
-
use constant DEFAULT_REPLICA_TYPE => 'prophet';
diff --git a/lib/Prophet/FilesystemReplica.pm b/lib/Prophet/FilesystemReplica.pm
index 66c22c2..9890125 100644
--- a/lib/Prophet/FilesystemReplica.pm
+++ b/lib/Prophet/FilesystemReplica.pm
@@ -121,7 +121,7 @@ sub _write_changeset {
my $changeset_index_line = pack( 'Na16NH40',
$seqno,
- $self->app_handle->uuid_generator->from_string( $changeset->original_source_uuid ),
+ $self->uuid_generator->from_string( $changeset->original_source_uuid ),
$changeset->original_sequence_no,
$cas_key );
@@ -220,7 +220,7 @@ sub _changeset_index_entry {
my $index_record = substr( $$chgidx, ( $rev - 1 ) * CHG_RECORD_SIZE, CHG_RECORD_SIZE );
my ( $seq, $orig_uuid, $orig_seq, $key ) = unpack( 'Na16NH40', $index_record );
- $orig_uuid = $self->app_handle->uuid_generator->to_string($orig_uuid);
+ $orig_uuid = $self->uuid_generator->to_string($orig_uuid);
$self->log_debug( "REV: $rev - seq $seq - originally $orig_seq from "
. substr( $orig_uuid, 0, 6 )
. " data key $key" );
diff --git a/lib/Prophet/ForeignReplica.pm b/lib/Prophet/ForeignReplica.pm
index 6276b1b..abec3df 100644
--- a/lib/Prophet/ForeignReplica.pm
+++ b/lib/Prophet/ForeignReplica.pm
@@ -60,7 +60,7 @@ sub db_uuid { return undef }
sub uuid_for_url {
my ( $self, $url ) = @_;
- return $self->app_handle->uuid_generator->create_string_from_url( $url );
+ return $self->uuid_generator->create_string_from_url( $url );
}
sub prompt_for_login {
diff --git a/lib/Prophet/Record.pm b/lib/Prophet/Record.pm
index 67ab36e..ff019d8 100644
--- a/lib/Prophet/Record.pm
+++ b/lib/Prophet/Record.pm
@@ -192,7 +192,7 @@ In case of failure, returns undef.
sub create {
my $self = shift;
my %args = validate( @_, { props => 1 } );
- my $uuid = $self->handle->app_handle->uuid_generator->create_str;
+ my $uuid = $self->handle->uuid_generator->create_str;
my $props = $args{props};
diff --git a/lib/Prophet/Replica.pm b/lib/Prophet/Replica.pm
index e1d59a1..9f632de 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -52,6 +52,15 @@ has after_initialize => (
default => sub { sub {1} } # default returns a coderef
);
+
+has uuid_generator => (
+ is => 'rw',
+ isa => 'Prophet::UUIDGenerator',
+ default => sub { Prophet::UUIDGenerator->new( uuid_scheme => 1) }
+);
+
+
+
our $MERGETICKET_METATYPE = '_merge_tickets';
=head1 NAME
diff --git a/lib/Prophet/Replica/prophet.pm b/lib/Prophet/Replica/prophet.pm
index f307332..121abb8 100644
--- a/lib/Prophet/Replica/prophet.pm
+++ b/lib/Prophet/Replica/prophet.pm
@@ -327,9 +327,9 @@ sub initialize {
mkpath( [ File::Spec->catdir( $self->fs_root => $_ ) ] );
}
- $self->set_db_uuid( $args{'db_uuid'} || $self->app_handle->uuid_generator->create_str );
+ $self->set_db_uuid( $args{'db_uuid'} || $self->uuid_generator->create_str );
$self->set_latest_sequence_no("0");
- $self->set_replica_uuid( $self->app_handle->uuid_generator->create_str );
+ $self->set_replica_uuid( $self->uuid_generator->create_str );
$self->set_replica_version(1);
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index bdc7729..f626e05 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -349,8 +349,8 @@ CREATE TABLE userdata (
$self->dbh->do($_) || warn $self->dbh->errstr;
}
- $self->set_db_uuid( $args{'db_uuid'} || $self->app_handle->uuid_generator->create_str );
- $self->set_replica_uuid( $self->app_handle->uuid_generator->create_str );
+ $self->set_db_uuid( $args{'db_uuid'} || $self->uuid_generator->create_str );
+ $self->set_replica_uuid( $self->uuid_generator->create_str );
$self->set_replica_version(3);
$self->resolution_db_handle->initialize( db_uuid => $args{resdb_uuid} )
if !$self->is_resdb;
@@ -524,7 +524,7 @@ sub read_changeset_index {
my $data = $args{changeset_metadata};
my $changeset_index_line = pack( 'Na16NH40',
$data->[0],
- $self->app_handle->uuid_generator->from_string( $data->[1]),
+ $self->uuid_generator->from_string( $data->[1]),
$data->[2],
$data->[3]);
$index .= $changeset_index_line;
diff --git a/lib/Prophet/Server/Dispatcher.pm b/lib/Prophet/Server/Dispatcher.pm
index 1e6ea21..2711e60 100644
--- a/lib/Prophet/Server/Dispatcher.pm
+++ b/lib/Prophet/Server/Dispatcher.pm
@@ -60,7 +60,7 @@ under { method => 'GET' } => sub {
my $data = $args{changeset_metadata};
my $changeset_index_line = pack( 'Na16NH40',
$data->[0],
- $self->server->app_handle->uuid_generator->from_string( $data->[1]),
+ $self->server->uuid_generator->from_string( $data->[1]),
$data->[2],
$data->[3]);
$index .= $changeset_index_line;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list