class RubySDK::GRPCServer
GRPCServer
provides an implementation of the Plugin service.
Public Class Methods
new(cached_jobs)
click to toggle source
# File lib/rubysdk.rb, line 17 def initialize(cached_jobs) @cached_jobs = cached_jobs end
Public Instance Methods
execute_job(job, _call)
click to toggle source
execute_job
executes the given job and returns a result.
# File lib/rubysdk.rb, line 29 def execute_job(job, _call) cjob = nil @cached_jobs.each do |cached_job| cjob = cached_job if cached_job.job.unique_id == job.unique_id end if cjob == nil Proto::JobResult.new(failed: true, exit_pipeline: true, message: "job not found in plugin " + job.title) return end # Transform arguments args = [] if !job.args.empty? job.args.each do |arg| new_arg = Proto::Argument.new(key: arg.key, value: arg.value) args.push new_arg end end # Execute job job_failed = false exit_pipeline = false message = "" unique_id = 0 begin cjob.handler.call(args) rescue => e # Check if job wants to force exit pipeline. # We will exit the pipeline but not mark it as 'failed'. job_failed = true if e == ErrorExitPipeline # Set log message and job id exit_pipeline = true message = e.message unique_id = job.job.unique_id end Proto::JobResult.new(unique_id: unique_id, failed: job_failed, exit_pipeline: exit_pipeline, message: message) end
get_jobs(empty, _call)
click to toggle source
get_jobs
returns all registered jobs.
# File lib/rubysdk.rb, line 22 def get_jobs(empty, _call) jobs = [] @cached_jobs.each { |job| jobs.push job.job } jobs.each end