From 2c0f1e805b6e478ab84d90c342dd5433e517dc9f Mon Sep 17 00:00:00 2001 From: Al Newkirk Date: Sun, 5 Jul 2020 15:19:54 -0400 Subject: [PATCH] Fix Zing/Domain false start issue --- lib/Zing/Domain.pm | 17 +++-------------- t/Zing_Domain.t | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/Zing/Domain.pm b/lib/Zing/Domain.pm index 7290b63..ac359f1 100644 --- a/lib/Zing/Domain.pm +++ b/lib/Zing/Domain.pm @@ -33,12 +33,6 @@ fun new_channel($self) { Zing::Channel->new(name => $self->name) } -has 'threshold' => ( - is => 'ro', - isa => 'Str', - def => 1_000, -); - # BUILDERS fun BUILD($self) { @@ -75,9 +69,7 @@ sub _copy { # METHODS method apply() { - if ($self->channel->renew) { - undef $self->{data} if $self->channel->size; - } + undef $self->{data} if $self->channel->renew; while (my $data = $self->recv) { my $op = $data->{op}; @@ -85,8 +77,7 @@ method apply() { my $val = $data->{val}; if ($data->{snapshot} && !$self->{data}) { - $self->{data} = _copy $data->{snapshot}; - next; + $self->{data} = _copy($data->{snapshot}); } local $@; @@ -123,13 +114,11 @@ method apply() { method change(Str $op, Str $key, Any @val) { my %fields = ( key => $key, - snapshot => $self->data, + snapshot => _copy($self->data), time => time, val => [@val], ); - $self->channel->drop if $self->channel->size >= $self->threshold; - if ($op eq 'decr') { $self->send({ %fields, op => 'decr' }); } diff --git a/t/Zing_Domain.t b/t/Zing_Domain.t index 552f6dc..bfd76c7 100644 --- a/t/Zing_Domain.t +++ b/t/Zing_Domain.t @@ -66,7 +66,6 @@ Zing::Types name: ro, req, Str channel: ro, opt, Channel -threshold: ro, opt, Str =cut