
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
jruby_parallel_processing
Advanced tools
JRubyParallelProcessing
is a gem designed for parallel processing tasks in JRuby. It offers efficient data processing and API request handling using multiple threads, along with a task queue system for managing and executing tasks with priority and retries.
Add this gem to your Gemfile:
gem 'jruby_parallel_processing'
DataProcessor
is a class designed for parallel data processing. It allows you to split data into chunks and process them across multiple threads, which significantly speeds up task execution. Additionally, it supports middleware hooks for customizing the behavior before and after processing.
require 'jruby_parallel_processing'
data = (1..100).to_a
processor = JRubyParallelProcessing::DataProcessor.new(data_array: data, in_threads: 4)
processor.process do |item|
# Your processing logic here
puts item
end
processor = JRubyParallelProcessing::DataProcessor.new(data_array: data, in_threads: 4)
# Add before processing middleware
processor.add_middleware(:before_process) do
puts "Starting processing..."
end
# Add after processing middleware
processor.add_middleware(:after_process) do
puts "Finished processing."
end
processor.process do |item|
puts item
end
require 'stringio'
require 'jruby_parallel_processing'
stream = StringIO.new("line 1\nline 2\nline 3\n")
processor = JRubyParallelProcessing::DataProcessor.new(stream: stream, in_threads: 2)
processor.process do |line|
puts line
end
TaskQueue
is a class for managing and executing tasks with priority, retries, and custom configurations. It allows for efficient task scheduling and error handling.
require 'jruby_parallel_processing'
task_queue = JRubyParallelProcessing::TaskQueue.new(max_retries: 3, retry_delay: 0.1, max_queue_size: 10)
task_queue.add_task(1) do
# Your task logic here
puts "Task executed"
end
task_queue.process_tasks
ApiRequestProcessor
handles parallel API requests with built-in error handling and retries.
urls = ["https://api.example.com/data", "https://api.example.com/other"]
processor = JRubyParallelProcessing::ApiRequestProcessor.new(urls, in_threads: 4)
results = processor.process(http_method: :get) do |response|
puts "Received response: #{response.body}"
end
DistributedWorker
is a class for managing distributed tasks across multiple worker nodes. It enables task distribution, prioritization, and ensures that workers remain active through a heartbeat mechanism.
require 'jruby_parallel_processing'
# Initialize a DistributedWorker instance
worker = JRubyParallelProcessing::DistributedWorker.new("localhost", 8787)
# Queue a task with a given priority
result = worker.execute_task(-> { puts "Task executed" }, priority: 5)
puts result[:status] # :queued
# To connect to an existing worker
worker_url = "druby://localhost:8787"
remote_worker = JRubyParallelProcessing::DistributedWorker.connect_to_worker(worker_url)
# Send a heartbeat to the worker
remote_worker.send_heartbeat
This gem is licensed under the MIT License.
FAQs
Unknown package
We found that jruby_parallel_processing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.