#!/usr/bin/env perl

use strict;
use warnings;

use lib 'definitions';

use Zing::PubSub;

=pod explain

- zing-pubsub is a generic pub/sub data store
- it a subclass of Zing/Repo and uses Zing/Store operations

=cut

for my $i (1..10) {
  for my $j (1..1_000) {
    Zing::PubSub->new(name => "socket-$i")->send({value => $j});

    warn "socket-$i", " ", "value-$j", " ", "sent";
  }
}

for my $i (1..10) {
  for my $j (1..1_000) {
    my $d = Zing::PubSub->new(name => "socket-$i")->recv;
    my $x = $d->{value};

    warn "socket-$i", " ", "value-$x", " ", "received";
  }
}

for my $i (1..10) {
  Zing::PubSub->new(name => "socket-$i")->drop;
}

warn 'pub/sub data saved and dropped';