From 25d1e8900a08db8583c9e4c4346647d232dbe51e Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Wed, 17 Oct 2018 11:00:55 -0700 Subject: [PATCH 1/3] Allow PathInput to take an optional frequency parameter. The previous version hard-coded the cache check frequency to 30 seconds. This meant that the path was checked very frequently (max of 30 seconds and the evaluation period of the job), which could be problematic for URL PathInput specifications, and especially ones that are automatically updated frequently without *each* update necessarily being interesting (an example: the haskell hackage index file.) --- src/lib/Hydra/Plugin/PathInput.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Plugin/PathInput.pm b/src/lib/Hydra/Plugin/PathInput.pm index c1788428..e5c02bfe 100644 --- a/src/lib/Hydra/Plugin/PathInput.pm +++ b/src/lib/Hydra/Plugin/PathInput.pm @@ -11,12 +11,22 @@ sub supportedInputTypes { $inputTypes->{'path'} = 'Local path'; } +sub _parseValue { + my ($value) = @_; + my @parts = split ' ', $value; + (my $uri, my $freq) = @parts; + # by default don't check a path more often than every 30 seconds, + # but the second path argument can change that value. + $freq = defined $freq ? $freq : 30; + return ($uri, $freq); +} + sub fetchInput { my ($self, $type, $name, $value) = @_; return undef if $type ne "path"; - my $uri = $value; + my ($uri, $timeout) = _parseValue($value); my $timestamp = time; my $sha256; From 66730993fcfdb9928314e0deb2a38b483505f083 Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Tue, 9 Jun 2020 08:55:46 -0700 Subject: [PATCH 2/3] Reconcile with changes from pullreq #775 --- src/lib/Hydra/Plugin/PathInput.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Hydra/Plugin/PathInput.pm b/src/lib/Hydra/Plugin/PathInput.pm index e5c02bfe..f8ae6bc4 100644 --- a/src/lib/Hydra/Plugin/PathInput.pm +++ b/src/lib/Hydra/Plugin/PathInput.pm @@ -16,9 +16,11 @@ sub _parseValue { my @parts = split ' ', $value; (my $uri, my $freq) = @parts; # by default don't check a path more often than every 30 seconds, - # but the second path argument can change that value. - $freq = defined $freq ? $freq : 30; - return ($uri, $freq); + # but the second path argument can change that value or the global + # path_input_cache_validity_seconds configuration, in that order. + my $timeout = defined $freq ? $freq : ($self->{config}->{path_input_cache_validity_seconds} // 30); + + return ($uri, $timeout); } sub fetchInput { @@ -32,8 +34,6 @@ sub fetchInput { my $sha256; my $storePath; - my $timeout = $self->{config}->{path_input_cache_validity_seconds} // 30; - # Some simple caching: don't check a path more than once every N seconds. (my $cachedInput) = $self->{db}->resultset('CachedPathInputs')->search( {srcpath => $uri, lastseen => {">", $timestamp - $timeout}}, From 23fa93c5f83a95aa4d00d232b408732b7ad27cd3 Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Tue, 9 Jun 2020 09:00:02 -0700 Subject: [PATCH 3/3] Better update of timeout for the PathInput handler. --- src/lib/Hydra/Plugin/PathInput.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Plugin/PathInput.pm b/src/lib/Hydra/Plugin/PathInput.pm index f8ae6bc4..8bd7b77f 100644 --- a/src/lib/Hydra/Plugin/PathInput.pm +++ b/src/lib/Hydra/Plugin/PathInput.pm @@ -12,13 +12,15 @@ sub supportedInputTypes { } sub _parseValue { - my ($value) = @_; + # The input is a local path or URL, optionally followed by a + # time period specified in seconds. + my ($config, $value) = @_; my @parts = split ' ', $value; (my $uri, my $freq) = @parts; - # by default don't check a path more often than every 30 seconds, + # By default don't check a path more often than every 30 seconds, # but the second path argument can change that value or the global # path_input_cache_validity_seconds configuration, in that order. - my $timeout = defined $freq ? $freq : ($self->{config}->{path_input_cache_validity_seconds} // 30); + my $timeout = defined $freq ? $freq : ($config->{path_input_cache_validity_seconds} // 30); return ($uri, $timeout); } @@ -28,7 +30,7 @@ sub fetchInput { return undef if $type ne "path"; - my ($uri, $timeout) = _parseValue($value); + my ($uri, $timeout) = _parseValue($self->{config}, $value); my $timestamp = time; my $sha256;