Skip to content

Commit

Permalink
Fix Zing/Domain false start issue (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamalnewkirk committed Jul 5, 2020
1 parent e5f2490 commit cfebfab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 3 additions & 14 deletions lib/Zing/Domain.pm
Expand Up @@ -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) {
Expand Down Expand Up @@ -75,18 +69,15 @@ 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};
my $key = $data->{key};
my $val = $data->{val};

if ($data->{snapshot} && !$self->{data}) {
$self->{data} = _copy $data->{snapshot};
next;
$self->{data} = _copy($data->{snapshot});
}

local $@;
Expand Down Expand Up @@ -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' });
}
Expand Down
1 change: 0 additions & 1 deletion t/Zing_Domain.t
Expand Up @@ -66,7 +66,6 @@ Zing::Types
name: ro, req, Str
channel: ro, opt, Channel
threshold: ro, opt, Str
=cut

Expand Down

0 comments on commit cfebfab

Please sign in to comment.