Class: Jets::PolyFun
- Inherits:
-
Object
show all
- Extended by:
- Memoist
- Defined in:
- lib/jets/poly_fun.rb,
lib/jets/poly_fun/node_error.rb,
lib/jets/poly_fun/python_error.rb,
lib/jets/poly_fun/base_executor.rb,
lib/jets/poly_fun/node_executor.rb,
lib/jets/poly_fun/lambda_executor.rb,
lib/jets/poly_fun/python_executor.rb
Defined Under Namespace
Classes: BaseExecutor, LambdaExecutor, NodeError, NodeExecutor, PythonError, PythonExecutor
Instance Method Summary
collapse
Constructor Details
#initialize(app_class, app_meth) ⇒ PolyFun
Returns a new instance of PolyFun.
14
15
16
17
|
# File 'lib/jets/poly_fun.rb', line 14
def initialize(app_class, app_meth)
@app_class = app_class @app_meth = app_meth.to_sym
end
|
Instance Method Details
#raise_error(resp) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/jets/poly_fun.rb', line 34
def raise_error(resp)
backtrace = resp["stackTrace"] + caller
backtrace = backtrace.map { |l| l.sub(/^\s+/,'') }
backtrace = backtrace.map do |l|
if l.include?(Jets.build_root) && !l.include?("lambda_executor.")
l.sub(/\/tmp\/jets.*executor\/\d{8}-+.*?\//, '')
else
l
end
end
error_class = "Jets::PolyFun::#{task.lang.to_s.classify}Error".constantize
raise error_class.new(resp["errorMessage"], backtrace)
end
|
#run(event, context = {}) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jets/poly_fun.rb', line 19
def run(event, context={})
if task.lang == :ruby
@app_class.process(event, context, @app_meth)
else
executor = LambdaExecutor.new(task)
resp = executor.run(event, context)
if resp["errorMessage"]
raise_error(resp)
end
resp
end
end
|
#task ⇒ Object
56
57
58
|
# File 'lib/jets/poly_fun.rb', line 56
def task
@app_class.all_tasks[@app_meth]
end
|