Class: JetstreamBridge::Generators::HealthCheckGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- JetstreamBridge::Generators::HealthCheckGenerator
- Defined in:
- lib/generators/jetstream_bridge/health_check/health_check_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_route ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/jetstream_bridge/health_check/health_check_generator.rb', line 15 def add_route route_content = " # JetStream Bridge health check endpoint\n " \ "get '/health/jetstream', to: 'jetstream_health#show'" if File.exist?('config/routes.rb') inject_into_file 'config/routes.rb', after: /Rails\.application\.routes\.draw do\n/ do "#{route_content}\n" end say 'Added health check route to config/routes.rb', :green else say 'Could not find config/routes.rb - please add route manually:', :yellow say route_content, :yellow end end |
#create_controller ⇒ Object
11 12 13 |
# File 'lib/generators/jetstream_bridge/health_check/health_check_generator.rb', line 11 def create_controller template 'health_controller.rb', 'app/controllers/jetstream_health_controller.rb' end |
#show_usage ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/generators/jetstream_bridge/health_check/health_check_generator.rb', line 30 def show_usage say "\n#{'=' * 70}", :green say 'Health Check Endpoint Created!', :green say '=' * 70, :green say "\nThe health check endpoint is now available at:" say ' GET /health/jetstream', :cyan say "\nExample response:" say <<~EXAMPLE, :white { "healthy": true, "nats_connected": true, "connected_at": "2025-11-22T20:00:00Z", "stream": { "exists": true, "name": "jetstream-bridge-stream", "subjects": ["app1.sync.app2"], "messages": 42 }, "config": { "stream_name": "jetstream-bridge-stream", "app_name": "my_app", "destination_app": "other_app" }, "version": "2.10.0" } EXAMPLE say "\nUse this endpoint for:" say ' • Kubernetes liveness/readiness probes', :white say ' • Docker health checks', :white say ' • Monitoring and alerting', :white say ' • Load balancer health checks', :white say '=' * 70, :green end |