App-AltSQL

 view release on metacpan or  search on metacpan

lib/App/AltSQL/Plugin/Tail.pm  view on Meta::CPAN

	## Construct tail SQL statement

	$from ||= '* from';
	if ($where) {
		$where .= " and $key_column > ";
	}
	else {
		$where = "where $key_column > ";
	}

	my $tail_sql_fragment = "select $from $table $where";

	## Loop

	my $break = 0;
	$SIG{INT} = sub {
		$break = 1;
	};

	my %render_opts = ( no_pager => 1 );

	while (1) {
		last if $break;
		$update_last_seen_max_value->();
		sleep $sleep_seconds;
		my $sql = $tail_sql_fragment . $last_seen_max_value;
		$self->log_info( scalar(localtime(time)) . ': ' . $sql);
		$self->model->handle_sql_input($sql, \%render_opts);
	}

	return 1;
};

no Moose::Role;

1;



( run in 1.453 second using v1.01-cache-2.11-cpan-b16cb0d3907 )