1 package DBIx::Class::Schema::QueryInterval;
7 DBIx::Class::Schema::Role::QueryInterval; Defines a job control interval.
11 The following example shows how to define a job control interval and assign it
12 to a particular L<DBIx::Class::Schema::Job> for a L<DBIx::Class::Schema>
14 my $job = DBIx::Class::Schema->new(runs => sub { print 'did job'});
15 my $interval = DBIx::Class::Schema::Interval->new(every => 10);
17 if($interval->matches($query_count)) {
18 print "I indentified the query count as matching";
21 ## $schema->isa(DBIx::Class::Schema);
22 $schema->create_and_add_at_query_intervals($interval => $job);
26 A Query Interval defines a reoccuring period based on the query count from a
27 given offset. For example, you can define a query interval of 10 queries
28 with an offset of 1 query. This interval identifies query number 11, 21, 31,
33 This package defines the following attributes.
37 This is the 'size' of the gap identifying a query as matching a particular
38 interval. Think, "I match every X queries".
51 This is a number of queries from the start of all queries to offset the match
52 counting mechanism. This is basically added to the L</every> attribute to
53 identify a query as matching the interval we wish to define.
67 This module defines the following methods.
69 =head2 matches ($query_count)
71 Does the $query_count match the defined interval? Returns a Boolean.
76 my ($self, $query_count) = @_;
77 my $offset_count = $query_count - $self->offset;
78 return $offset_count % $self->every ? 0:1;
84 See L<DBIx::Class> for more information regarding authors.
88 You may distribute this code under the same terms as Perl itself.