How bigcommerce/gruf works
Project type and purpose
• gruf is an open-source Ruby gem that wraps the gRPC Ruby library to provide a streamlined server and client framework for building gRPC services in Ruby (and Rails) applications. It is not a full-stack app but a middleware library designed for integration and extensibility.
File structure
• Top-level artifacts
• bin/console, bin/gruf, gruf.gemspec, Gemfile, Rakefile – gem entry points, build & test scripts
• lib/gruf – core library code
• lib/gruf/client – client API, error handling, configuration
• lib/gruf/controllers – abstract controller classes (health, request handling, service binding)
• lib/gruf/interceptors – server- and client-side interceptor chain for auth, logging, instrumentation, connection reset, etc.
• lib/gruf/hooks – lifecycle hooks (before_request, after_response) with registry and executors
• lib/gruf/serializers – error serializers for JSON, metadata transport
• lib/gruf/integrations – Rails Railtie integration
• lib/gruf/server.rb – wrapper around the gRPC Ruby server
• lib/gruf/logger, grpc_logger, timer – unified logging and timing utilities
• Configuration files (YARD, RuboCop, CircleCI, GitHub templates) point to a well-maintained open-source project with CI, code style, and documentation.
README for additional insights
• Features: abstracted controllers, full interceptor support, robust client error handling, authentication, TLS support, error serialization, execution timings
• Supported environments: Ruby 3.0–3.4, gRPC 1.10+, Rails and non-Rails usage