Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zing/Domain false start issue #190

Merged
merged 1 commit into from Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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