postjob 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 375c8b8cb2b29ba963463113fa303d53374222fd
4
- data.tar.gz: 5feceb4be5f5c97eba91caffd55f73d70469aa0c
3
+ metadata.gz: 19ac068f3a63b97556c7ce6aefe07e10ead759f1
4
+ data.tar.gz: 003e5725fa65129288ddc34eac9625a751cc252e
5
5
  SHA512:
6
- metadata.gz: 02cb7b0d90750a13f859c925fccb9fea90af194cd71efcff329be0aa9274195531e2c2892ebaa0a549bc66f470c648b848fab6c697781fc8273265c55ebf09ae
7
- data.tar.gz: e663a86782d31c2c84e8039bd373103151fb38685b2973d362ddff5b6bd7dd15943c374ecbe94106c04c16d2519bb084556159418f8aa382442b73c52994674b
6
+ metadata.gz: 3874859c70f5c0182189acbb7cbf6e16130497b6ea5783658f280f2355a6e205a020724100c293f0fe427fa146251e1fc57756af6ad892ed08b24b68c9745745
7
+ data.tar.gz: 9f040743503861a3aaa2571a56d4081c4c915649b558990f201218e9207c2dc8e3576332ed7793c6a13835db66bbdaeab2687d02a8d5ff14adb0f8c284e9a945
@@ -87,10 +87,14 @@ module Postjob::CLI
87
87
  print_sql limit: limit, query: query
88
88
  end
89
89
 
90
- def ps_top(*ids, limit: "100", tags: nil)
90
+ def ps_top(*ids, limit: "100", tags: nil, full: false)
91
91
  loop do
92
92
  system "clear"
93
- ps(*ids, limit: limit, tags: tags)
93
+ if full
94
+ ps_full(*ids, limit: limit, tags: tags)
95
+ else
96
+ ps(*ids, limit: limit, tags: tags)
97
+ end
94
98
  sleep 1
95
99
  end
96
100
  rescue Interrupt
@@ -138,7 +142,7 @@ module Postjob::CLI
138
142
  end
139
143
 
140
144
  def print_sql(limit:, query:)
141
- records = Simple::SQL.records("#{query} LIMIT $1+1", limit)
145
+ records = Simple::SQL.all("#{query} LIMIT $1+1", limit, into: Hash)
142
146
 
143
147
  tp records[0, limit]
144
148
  if records.length > limit
@@ -8,7 +8,7 @@ BEGIN
8
8
  END;
9
9
  $$ LANGUAGE plpgsql;
10
10
 
11
- CREATE OR REPLACE FUNCTION {SCHEMA_NAME}.next_unresolved_childjob(v_parent_id BIGINT)
11
+ CREATE OR REPLACE FUNCTION {SCHEMA_NAME}.unresolved_childjobs(v_parent_id BIGINT)
12
12
  RETURNS SETOF {SCHEMA_NAME}.postjobs AS $$
13
13
  BEGIN
14
14
  RETURN QUERY
@@ -27,7 +27,7 @@ module Postjob
27
27
  private
28
28
 
29
29
  def run_migration(file)
30
- STDERR.puts "[#{file}] Running migration"
30
+ STDERR.puts "[postjob] Running migration in #{file}"
31
31
 
32
32
  case file
33
33
  when /\.rb$/ then run_migration_ruby(file)
data/lib/postjob/queue.rb CHANGED
@@ -48,7 +48,7 @@ module Postjob::Queue
48
48
  # a) a limitation in Simple::SQL which would not be able to unpack a
49
49
  # "SELECT function()" usefully when the return value is a record;
50
50
  # b) and/or my inability to write better SQL functions;
51
- SQL.record "SELECT * FROM #{SCHEMA_NAME}.enqueue($1, $2, $3, $4, $5, $6, $7, $8, $9)",
51
+ SQL.ask "SELECT * FROM #{SCHEMA_NAME}.enqueue($1, $2, $3, $4, $5, $6, $7, $8, $9)",
52
52
  options[:queue],
53
53
  workflow,
54
54
  workflow_method,
@@ -79,12 +79,12 @@ module Postjob::Queue
79
79
 
80
80
  def childjobs(parent)
81
81
  expect! parent => Job
82
- SQL.records "SELECT * FROM #{SCHEMA_NAME}.childjobs($1)", parent.id, into: Job
82
+ SQL.all "SELECT * FROM #{SCHEMA_NAME}.childjobs($1)", parent.id, into: Job
83
83
  end
84
84
 
85
- def next_unresolved_childjob(parent)
85
+ def unresolved_childjobs(parent)
86
86
  expect! parent => Job
87
- SQL.records "SELECT * FROM #{SCHEMA_NAME}.next_unresolved_childjob($1)", parent.id, into: Job
87
+ SQL.ask "SELECT COUNT(*) FROM #{SCHEMA_NAME}.unresolved_childjobs($1)", parent.id
88
88
  end
89
89
 
90
90
  def find_or_create_childjob(parent, workflow, args, timeout:, max_attempts:, queue: nil)
@@ -97,7 +97,7 @@ module Postjob::Queue
97
97
  # a) a limitation in Simple::SQL which would not be able to unpack a
98
98
  # "SELECT function()" usefully when the return value is a record;
99
99
  # b) and/or my inability to write better SQL functions;
100
- return SQL.record "SELECT * FROM #{SCHEMA_NAME}.find_or_create_childjob($1, $2, $3, $4, $5, $6, $7, $8, $9)",
100
+ return SQL.ask "SELECT * FROM #{SCHEMA_NAME}.find_or_create_childjob($1, $2, $3, $4, $5, $6, $7, $8, $9)",
101
101
  queue,
102
102
  workflow,
103
103
  workflow_method,
@@ -138,7 +138,7 @@ module Postjob::Queue
138
138
  public
139
139
 
140
140
  def checkout(workflows_with_versions)
141
- SQL.record "SELECT * FROM #{SCHEMA_NAME}.checkout($1, $2)",
141
+ SQL.ask "SELECT * FROM #{SCHEMA_NAME}.checkout($1, $2)",
142
142
  workflows_with_versions, Postjob.fast_mode, into: Job
143
143
  end
144
144
 
@@ -147,6 +147,6 @@ module Postjob::Queue
147
147
  end
148
148
 
149
149
  def find_job_by_token(token)
150
- SQL.record "SELECT * FROM #{SCHEMA_NAME}.postjobs_by_token($1)", token, into: Job
150
+ SQL.ask "SELECT * FROM #{SCHEMA_NAME}.postjobs_by_token($1)", token, into: Job
151
151
  end
152
152
  end
@@ -55,8 +55,9 @@ module Postjob::Runner
55
55
  def await(job, *args, timeout: nil, max_attempts: nil)
56
56
  case job
57
57
  when :all
58
- if Postjob::Queue.next_unresolved_childjob(current_job)
59
- Postjob.logger.debug "await :all: Found an unresolved childjob"
58
+ unresolved_childjobs = Postjob::Queue.unresolved_childjobs(current_job)
59
+ if unresolved_childjobs > 0
60
+ Postjob.logger.debug "await :all: Found #{unresolved_childjobs} unresolved childjobs"
60
61
  throw :pending, :pending
61
62
  else
62
63
  childjobs = Postjob::Queue.childjobs(current_job)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2018-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec