From 25d1e8900a08db8583c9e4c4346647d232dbe51e Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Wed, 17 Oct 2018 11:00:55 -0700 Subject: [PATCH] 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;