Gruf::Queue
Simple GRPC::Pool enhancement that replaces worker-based capacity checking with job count based threshold.
What it does
- Simplifies
GRPC::Pool
by removing complex worker queue management - Direct job scheduling to
@jobs
queue with idle thread processing - Uses
jobs_waiting < threshold
for capacity management - Configurable threshold via
GRUF_MAX_WAITING_REQUESTS
(default: 60) - Supports graceful shutdown
Installation
gem 'gruf-queue'
Usage
require 'gruf-queue'
# Optional: Set threshold (default is 60)
ENV['GRUF_MAX_WAITING_REQUESTS'] = '100'
# Start server normally
Gruf::Server.new(
hostname: '0.0.0.0:9001',
services: [YourService]
).start
Configuration
# Disable auto-installation
ENV['GRUF_QUEUE_NO_AUTO_INSTALL'] = 'true'
# Manual installation
Gruf::Queue::Plugin.install!
How it works
# Before: GRPC::Pool tracks actual worker availability
pool.ready_for_work? # Complex worker state checking
# After: Simple job count threshold
pool.ready_for_work? # jobs_waiting < max_waiting_requests
Requirements
- Ruby >= 3.2.0
- Gruf >= 2.21.0
- gRPC >= 1.0
License
MIT License