- my($conn, $rs, $event) = @_;
- my $rec = $rs->record(0);
- print $conn->option("host"), ": got 0: $rec = '", $rec->render(), "'\n";
+ my($conn, $arg, $rs, $event) = @_;
+
+ my $host = $conn->option("host");
+ my %state = $arg->{$host};
+
+ {
+ # Sanity-checking assertions. These should be impossible
+ my $ns = $arg->{$host}->{next_to_show};
+ my $nf = $arg->{$host}->{next_to_fetch};
+ if ($ns > $nf) {
+ die "next_to_show > next_to_fetch ($ns > $nf)";
+ } elsif ($ns == $nf) {
+ die "next_to_show == next_to_fetch ($ns)";
+ }
+ }
+
+ my $i = $arg->{$host}->{next_to_show}++;
+ my $rec = $rs->record($i);
+ print "$host: record $i is ", render_record($rec), "\n";
+ request_records($conn, $rs, $arg->{$host}, 3)
+ if $i == $arg->{$host}->{next_to_fetch}-1;
+
+ return 0;
+}
+
+sub exception_thrown {
+ my($conn, $arg, $rs, $exception) = @_;
+ print "Uh-oh! $exception\n";