lib/rocket_job/batch/io.rb in rocketjob-5.0.0 vs lib/rocket_job/batch/io.rb in rocketjob-5.1.0
- old
+ new
@@ -14,14 +14,11 @@
# Default: None ( Uses the single default input collection for this job )
# Validates: This value must be one of those listed in #input_categories
def input(category = :main)
raise "Category #{category.inspect}, must be registered in input_categories: #{input_categories.inspect}" unless input_categories.include?(category) || (category == :main)
- collection_name = "rocket_job.inputs.#{id}"
- collection_name << ".#{category}" unless category == :main
-
- (@inputs ||= {})[category] ||= RocketJob::Sliced::Input.new(collection_name: collection_name, slice_size: slice_size)
+ (@inputs ||= {})[category] ||= RocketJob::Sliced::Input.new(rocket_job_io_slice_arguments("inputs", category))
end
# Returns [RocketJob::Sliced::Output] output collection for holding output slices
# Returns nil if no output is being collected
#
@@ -31,14 +28,11 @@
# Default: None ( Uses the single default output collection for this job )
# Validates: This value must be one of those listed in #output_categories
def output(category = :main)
raise "Category #{category.inspect}, must be registered in output_categories: #{output_categories.inspect}" unless output_categories.include?(category) || (category == :main)
- collection_name = "rocket_job.outputs.#{id}"
- collection_name << ".#{category}" unless category == :main
-
- (@outputs ||= {})[category] ||= RocketJob::Sliced::Output.new(collection_name: collection_name, slice_size: slice_size)
+ (@outputs ||= {})[category] ||= RocketJob::Sliced::Output.new(rocket_job_io_slice_arguments("outputs", category))
end
# Upload the supplied file, io, IOStreams::Path, or IOStreams::Stream.
#
# Returns [Integer] the number of records uploaded.
@@ -392,8 +386,24 @@
else
raise(ArgumentError, 'result parameter is required when no block is supplied') unless result
RocketJob::Sliced::Writer::Output.collect(self, input_slice) { |writer| writer << result }
end
end
+
+ private
+
+ def rocket_job_io_slice_arguments(collection_type, category)
+ collection_name = "rocket_job.#{collection_type}.#{id}"
+ collection_name << ".#{category}" unless category == :main
+
+ args = {collection_name: collection_name, slice_size: slice_size}
+ if encrypt
+ args[:slice_class] = Sliced::EncryptedSlice
+ elsif compress
+ args[:slice_class] = Sliced::CompressedSlice
+ end
+ args
+ end
+
end
end
end