Class: Datafusion::Integrations

Inherits:
Object
  • Object
show all
Defined in:
lib/datafusion/integrations.rb

Class Method Summary collapse

Class Method Details

.could_not_open(exception, try, elapsed_time, next_interval) ⇒ Object



17
18
19
# File 'lib/datafusion/integrations.rb', line 17

def self.could_not_open(exception, try, elapsed_time, next_interval)
  Datafusion.log.error("#{exception.class}: '#{exception.message}' - #{try} tries in #{elapsed_time} seconds and #{next_interval} seconds until the next try.")
end

.load(file, opts = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/datafusion/integrations.rb', line 9

def self.load(file, opts={})
  retry_count = opts[:retry_count] || 20
  Retriable.retriable :tries => retry_count, :on_retry => self.method(:could_not_open)  do
    erb = ERB.new(open(file).read)
    YAML.load(erb.result(binding))
  end
end

.render(file, opts) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/datafusion/integrations.rb', line 21

def self.render(file, opts)
  pguser = URI(opts[:connection] || "").user || 'postgres'

  integs = Integrations.load(file)
  
  out = ""
  integs.each do |k, v|
    erb = SnippetRenderer.new(v["kind"], v.merge({"user" => pguser, "name"  =>  k}))
    out << erb.render()
  end
  return out
end

.schedules(file) ⇒ Object



34
35
36
37
38
39
# File 'lib/datafusion/integrations.rb', line 34

def self.schedules(file)
  integs = Integrations.load(file)
  integs.map do |k, v|
    v["tables"].map{|t| t["cached"] }.compact
  end.flatten
end