<field reporter:label="Processing Group Context Field" name="group_field" reporter:datatype="text"/>
<field reporter:label="Template" name="template" reporter:datatype="text"/>
<field reporter:label="Name" name="name" reporter:datatype="text"/>
+ <field reporter:label="Granularity" name="granularity" reporter:datatype="text"/>
<field reporter:label="Environmet Entries" name="env" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Parameters" name="params" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
<field reporter:label="State" name="state" reporter:datatype="text"/>
<field reporter:label="Template Output" name="template_output" reporter:datatype="link"/>
<field reporter:label="Error Output" name="error_output" reporter:datatype="text"/>
+ <field reporter:label="Asynchronous Output" name="async_output" reporter:datatype="link"/>
<field reporter:label="Update Process" name="update_process" reporter:datatype="int"/>
</fields>
<links>
<link field="event_def" reltype="has_a" key="id" map="" class="atevdef"/>
<link field="template_output" reltype="has_a" key="id" map="" class="ateo"/>
<link field="error_output" reltype="has_a" key="id" map="" class="ateo"/>
+ <link field="async_output" reltype="has_a" key="id" map="" class="ateo"/>
</links>
</class>
my $key = shift;
my $location_field = shift; # where to look for event_def.owner filtering ... circ_lib, for instance, where hook.core_type = circ
my $filter = shift || {};
+ my $granularity = shift;
my $active = ($self->api_name =~ /active/o) ? 1 : 0;
if ($active && !keys(%$filter)) {
$event->target( $o_id );
$event->event_def( $def->id );
$event->run_time( $run_time );
+ $event->granularity($granularity) if (defined $granularity);
$editor->create_action_trigger_event( $event );
argc => 2
);
-
sub fire_single_event {
my $self = shift;
my $client = shift;
sub pending_events {
my $self = shift;
my $client = shift;
+ my $granularity = shift;
my $editor = new_editor();
+ my $query = [{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] } }];
+
+ if (defined $granularity) {
+ $query->[0]->{'-or'} = [ {granularity => $granularity}, {granularity => undef} ];
+ } else {
+ $query->[0]->{granularity} = undef;
+ }
+
return $editor->search_action_trigger_event(
- [{ state => 'pending', run_time => {'<' => 'now'} }, { order_by => { atev => [ qw/run_time add_time/] } }],
- { idlist=> 1, timeout => 1800 }
+ $query, { idlist=> 1, timeout => 1800 }
);
}
__PACKAGE__->register_method(
api_level=> 1
);
-
sub grouped_events {
my $self = shift;
my $client = shift;
+ my $granularity = shift;
- my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run();
+ my ($events) = $self->method_lookup('open-ils.trigger.event.find_pending')->run($granularity);
my %groups = ( '*' => [] );
sub run_all_events {
my $self = shift;
my $client = shift;
+ my $granularity = shift;
- my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run();
+ my ($groups) = $self->method_lookup('open-ils.trigger.event.find_pending_by_group')->run($granularity);
for my $def ( %$groups ) {
if ($def eq '*') {
delay_field TEXT, -- for instance, xact_start on a circ hook ... look for fields on hook.core_type where datatype=timestamp? If not set, delay from now()
group_field TEXT, -- field from this.hook.core_type to batch event targets together on, fed into reactor a group at a time.
template TEXT, -- the TT block. will have an 'environment' hash (or array of hashes, grouped events) built up by validator and collector(s), which can be modified.
+ granularity TEXT, -- could specify a batch which is the only time these events should actually run
CONSTRAINT ev_def_owner_hook_val_react_clean_delay_once UNIQUE (owner, hook, validator, reactor, delay, delay_field),
CONSTRAINT ev_def_name_owner_once UNIQUE (owner, name)
);
update_process INT,
state TEXT NOT NULL DEFAULT 'pending' CHECK (state IN ('pending','invalid','found','collecting','collected','validating','valid','reacting','reacted','cleaning','complete','error')),
template_output BIGINT REFERENCES action_trigger.event_output (id),
- error_output BIGINT REFERENCES action_trigger.event_output (id)
+ error_output BIGINT REFERENCES action_trigger.event_output (id),
+ async_output BIGINT REFERENCES action_trigger.event_output (id)
);
CREATE TABLE action_trigger.event_params (
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0072');
+
+ALTER TABLE action_trigger.event_definition ADD COLUMN granularity TEXT;
+ALTER TABLE action_trigger.event ADD COLUMN async_output BIGINT REFERENCES action_trigger.event_output (id);
+
+COMMIT;
my $opt_help = 0;
my $opt_hooks;
my $opt_process_hooks = 0;
+my $opt_granularity = undef;
GetOptions(
'osrf-config=s' => \$opt_osrf_config,
'run-pending' => \$opt_run_pending,
'hooks=s' => \$opt_hooks,
+ 'hooks=s' => \$opt_granularity,
'process-hooks' => \$opt_process_hooks,
'debug-stdout' => \$opt_debug_stdout,
'custom-filters=s' => \$opt_custom_filter,
Define which hooks to create events for. If none are defined,
it defaults to the list of hooks defined in the --custom-filters option.
+ --granularity=label
+ Run events with {label} granularity setting, or no granularity setting
+
--debug-stdout
Print server responses to stdout (as JSON) for debugging
my $method = 'open-ils.trigger.passive.event.autocreate.batch';
$method =~ s/passive/active/ if $config->{active};
- my $req = $ses->request($method, $hook, $config->{context_org}, $config->{filter});
+ my $req = $ses->request($method, $hook, $config->{context_org}, $config->{filter}, $opt_granularity);
while(my $resp = $req->recv(timeout => 1800)) {
if($opt_debug_stdout) {
print OpenSRF::Utils::JSON->perl2JSON($resp->content) . "\n";
sub run_pending {
return unless $opt_run_pending;
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
- my $req = $ses->request('open-ils.trigger.event.run_all_pending');
+ my $req = $ses->request('open-ils.trigger.event.run_all_pending' => $opt_granularity);
while(my $resp = $req->recv(timeout => 600)) {
if($opt_debug_stdout) {
print OpenSRF::Utils::JSON->perl2JSON($resp->content) . "\n";