bunny_farm 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/.envrc +1 -0
  3. data/.github/workflows/docs.yml +38 -0
  4. data/.gitignore +11 -0
  5. data/.travis.yml +3 -0
  6. data/CHANGELOG.md +61 -0
  7. data/COMMITS.md +196 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +330 -0
  11. data/Rakefile +9 -0
  12. data/bunny_farm.gemspec +30 -0
  13. data/config/bunny.yml.erb +29 -0
  14. data/config/bunny_test.yml.erb +29 -0
  15. data/config/hipchat.yml.erb +12 -0
  16. data/docs/api/configuration.md +9 -0
  17. data/docs/api/consumer.md +8 -0
  18. data/docs/api/message-class.md +419 -0
  19. data/docs/api/publisher.md +9 -0
  20. data/docs/architecture/integration.md +8 -0
  21. data/docs/architecture/message-flow.md +11 -0
  22. data/docs/architecture/overview.md +448 -0
  23. data/docs/architecture/scaling.md +8 -0
  24. data/docs/assets/actions_dsl_flow.svg +109 -0
  25. data/docs/assets/architecture_overview.svg +152 -0
  26. data/docs/assets/best_practices_patterns.svg +203 -0
  27. data/docs/assets/bunny_farm_logo.png +0 -0
  28. data/docs/assets/configuration_api_methods.svg +104 -0
  29. data/docs/assets/configuration_flow.svg +130 -0
  30. data/docs/assets/configuration_hierarchy.svg +70 -0
  31. data/docs/assets/data_processing_pipeline.svg +131 -0
  32. data/docs/assets/debugging_monitoring.svg +165 -0
  33. data/docs/assets/ecommerce_example_flow.svg +145 -0
  34. data/docs/assets/email_campaign_example.svg +127 -0
  35. data/docs/assets/environment_variables_map.svg +78 -0
  36. data/docs/assets/error_handling_flow.svg +114 -0
  37. data/docs/assets/favicon.ico +1 -0
  38. data/docs/assets/fields_dsl_structure.svg +89 -0
  39. data/docs/assets/instance_methods_lifecycle.svg +137 -0
  40. data/docs/assets/integration_patterns.svg +207 -0
  41. data/docs/assets/json_serialization_flow.svg +153 -0
  42. data/docs/assets/logo.svg +4 -0
  43. data/docs/assets/message_api_overview.svg +126 -0
  44. data/docs/assets/message_encapsulation.svg +113 -0
  45. data/docs/assets/message_lifecycle.svg +110 -0
  46. data/docs/assets/message_structure.svg +138 -0
  47. data/docs/assets/publisher_consumer_api.svg +120 -0
  48. data/docs/assets/scaling_deployment_patterns.svg +195 -0
  49. data/docs/assets/smart_routing_diagram.svg +131 -0
  50. data/docs/assets/system_architecture_overview.svg +155 -0
  51. data/docs/assets/task_scheduling_flow.svg +139 -0
  52. data/docs/assets/testing_strategies.svg +146 -0
  53. data/docs/assets/workflow_patterns.svg +183 -0
  54. data/docs/assets/yaml_config_structure.svg +72 -0
  55. data/docs/configuration/environment-variables.md +14 -0
  56. data/docs/configuration/overview.md +373 -0
  57. data/docs/configuration/programmatic-setup.md +10 -0
  58. data/docs/configuration/yaml-configuration.md +12 -0
  59. data/docs/core-features/configuration.md +528 -0
  60. data/docs/core-features/error-handling.md +82 -0
  61. data/docs/core-features/json-serialization.md +545 -0
  62. data/docs/core-features/message-design.md +406 -0
  63. data/docs/core-features/smart-routing.md +467 -0
  64. data/docs/core-features/task-scheduling.md +67 -0
  65. data/docs/core-features/workflow-support.md +112 -0
  66. data/docs/development/contributing.md +345 -0
  67. data/docs/development/roadmap.md +9 -0
  68. data/docs/development/testing.md +14 -0
  69. data/docs/examples/order-processing.md +10 -0
  70. data/docs/examples/overview.md +269 -0
  71. data/docs/examples/real-world.md +8 -0
  72. data/docs/examples/simple-producer-consumer.md +15 -0
  73. data/docs/examples/task-scheduler.md +9 -0
  74. data/docs/getting-started/basic-concepts.md +274 -0
  75. data/docs/getting-started/installation.md +122 -0
  76. data/docs/getting-started/quick-start.md +158 -0
  77. data/docs/index.md +106 -0
  78. data/docs/message-structure/actions-dsl.md +163 -0
  79. data/docs/message-structure/fields-dsl.md +146 -0
  80. data/docs/message-structure/instance-methods.md +115 -0
  81. data/docs/message-structure/overview.md +211 -0
  82. data/examples/README.md +212 -0
  83. data/examples/consumer.rb +41 -0
  84. data/examples/images/message_flow.svg +87 -0
  85. data/examples/images/order_workflow.svg +122 -0
  86. data/examples/images/producer_consumer.svg +96 -0
  87. data/examples/images/task_scheduler.svg +140 -0
  88. data/examples/order_processor.rb +238 -0
  89. data/examples/producer.rb +60 -0
  90. data/examples/simple_message.rb +43 -0
  91. data/examples/task_scheduler.rb +263 -0
  92. data/images/architecture_overview.svg +152 -0
  93. data/images/bunny_farm_logo.png +0 -0
  94. data/images/configuration_flow.svg +130 -0
  95. data/images/message_structure.svg +138 -0
  96. data/lib/bunny_farm/.irbrc +7 -0
  97. data/lib/bunny_farm/generic_consumer.rb +12 -0
  98. data/lib/bunny_farm/hash_ext.rb +37 -0
  99. data/lib/bunny_farm/init_bunny.rb +137 -0
  100. data/lib/bunny_farm/init_hipchat.rb +49 -0
  101. data/lib/bunny_farm/message.rb +218 -0
  102. data/lib/bunny_farm/message_elements.rb +25 -0
  103. data/lib/bunny_farm/version.rb +3 -0
  104. data/lib/bunny_farm.rb +9 -0
  105. data/mkdocs.yml +148 -0
  106. metadata +244 -0
@@ -0,0 +1,183 @@
1
+ <svg width="1000" height="800" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="1000" height="800" fill="transparent"/>
3
+
4
+ <!-- Title -->
5
+ <text x="500" y="30" text-anchor="middle" font-family="Arial, sans-serif" font-size="20" font-weight="bold" fill="#e0e0e0">
6
+ Workflow Support: Building Complex Multi-Step Processes
7
+ </text>
8
+
9
+ <!-- Sequential Workflow -->
10
+ <g>
11
+ <text x="200" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#68d391">
12
+ Sequential Workflow
13
+ </text>
14
+
15
+ <rect x="50" y="90" width="120" height="60" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
16
+ <text x="110" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">1. Validate</text>
17
+ <text x="110" y="135" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">validate_order</text>
18
+
19
+ <rect x="190" y="90" width="120" height="60" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
20
+ <text x="250" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">2. Payment</text>
21
+ <text x="250" y="135" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">process_payment</text>
22
+
23
+ <rect x="330" y="90" width="120" height="60" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
24
+ <text x="390" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">3. Fulfill</text>
25
+ <text x="390" y="135" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">fulfill_order</text>
26
+
27
+ <rect x="470" y="90" width="120" height="60" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
28
+ <text x="530" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">4. Ship</text>
29
+ <text x="530" y="135" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">ship_order</text>
30
+
31
+ <!-- Arrows -->
32
+ <defs>
33
+ <marker id="arrow-workflow" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
34
+ <polygon points="0 0, 10 3.5, 0 7" fill="#68d391"/>
35
+ </marker>
36
+ <marker id="arrow-conditional" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
37
+ <polygon points="0 0, 10 3.5, 0 7" fill="#f6e05e"/>
38
+ </marker>
39
+ <marker id="arrow-parallel" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
40
+ <polygon points="0 0, 10 3.5, 0 7" fill="#9f7aea"/>
41
+ </marker>
42
+ </defs>
43
+
44
+ <line x1="170" y1="120" x2="190" y2="120" stroke="#68d391" stroke-width="2" marker-end="url(#arrow-workflow)"/>
45
+ <line x1="310" y1="120" x2="330" y2="120" stroke="#68d391" stroke-width="2" marker-end="url(#arrow-workflow)"/>
46
+ <line x1="450" y1="120" x2="470" y2="120" stroke="#68d391" stroke-width="2" marker-end="url(#arrow-workflow)"/>
47
+
48
+ <!-- Code example -->
49
+ <rect x="50" y="170" width="540" height="120" rx="8" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
50
+ <text x="60" y="190" font-family="monospace" font-size="11" fill="#68d391">def start_order</text>
51
+ <text x="70" y="205" font-family="monospace" font-size="11" fill="#e0e0e0">self.class.new(@items).publish('validate')</text>
52
+ <text x="70" y="220" font-family="monospace" font-size="11" fill="#68d391">success!</text>
53
+ <text x="60" y="235" font-family="monospace" font-size="11" fill="#68d391">end</text>
54
+ <text x="250" y="190" font-family="monospace" font-size="11" fill="#68d391">def validate</text>
55
+ <text x="260" y="205" font-family="monospace" font-size="11" fill="#e0e0e0">validate_data</text>
56
+ <text x="260" y="220" font-family="monospace" font-size="11" fill="#e0e0e0">return unless successful?</text>
57
+ <text x="260" y="235" font-family="monospace" font-size="11" fill="#e0e0e0">self.class.new(@items).publish('process_payment')</text>
58
+ <text x="60" y="250" font-family="monospace" font-size="11" fill="#68d391">end</text>
59
+ <text x="250" y="265" font-family="monospace" font-size="11" fill="#9ca3af"># Each step triggers the next step</text>
60
+ <text x="250" y="280" font-family="monospace" font-size="11" fill="#9ca3af"># Chain continues until completion or failure</text>
61
+ </g>
62
+
63
+ <!-- Conditional Workflow -->
64
+ <g>
65
+ <text x="200" y="330" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#f6e05e">
66
+ Conditional Workflow
67
+ </text>
68
+
69
+ <rect x="110" y="350" width="120" height="60" rx="8" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
70
+ <text x="170" y="375" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#f6e05e">Validate Order</text>
71
+ <text x="170" y="395" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">validate_order</text>
72
+
73
+ <!-- Decision diamond -->
74
+ <polygon points="320,360 350,380 320,400 290,380" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
75
+ <text x="320" y="375" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#f6e05e">Needs</text>
76
+ <text x="320" y="390" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#f6e05e">Approval?</text>
77
+
78
+ <!-- Approval path -->
79
+ <rect x="390" y="320" width="120" height="50" rx="8" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
80
+ <text x="450" y="340" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#e53e3e">Manual Review</text>
81
+ <text x="450" y="355" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">request_approval</text>
82
+
83
+ <!-- Auto process path -->
84
+ <rect x="390" y="390" width="120" height="50" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
85
+ <text x="450" y="410" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">Auto Process</text>
86
+ <text x="450" y="425" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">auto_process</text>
87
+
88
+ <!-- Arrows -->
89
+ <line x1="230" y1="380" x2="290" y2="380" stroke="#f6e05e" stroke-width="2" marker-end="url(#arrow-conditional)"/>
90
+ <line x1="350" y1="370" x2="390" y2="345" stroke="#e53e3e" stroke-width="2" marker-end="url(#arrow-conditional)"/>
91
+ <line x1="350" y1="390" x2="390" y2="415" stroke="#68d391" stroke-width="2" marker-end="url(#arrow-conditional)"/>
92
+
93
+ <text x="365" y="365" font-family="Arial, sans-serif" font-size="10" fill="#e53e3e">YES</text>
94
+ <text x="365" y="405" font-family="Arial, sans-serif" font-size="10" fill="#68d391">NO</text>
95
+
96
+ <!-- Code example -->
97
+ <rect x="50" y="460" width="540" height="80" rx="8" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
98
+ <text x="60" y="480" font-family="monospace" font-size="11" fill="#f6e05e">def process_order</text>
99
+ <text x="70" y="495" font-family="monospace" font-size="11" fill="#e0e0e0">if @items[:requires_approval]</text>
100
+ <text x="80" y="510" font-family="monospace" font-size="11" fill="#e0e0e0">self.class.new(@items).publish('request_approval')</text>
101
+ <text x="70" y="525" font-family="monospace" font-size="11" fill="#e0e0e0">else</text>
102
+ <text x="80" y="540" font-family="monospace" font-size="11" fill="#e0e0e0">self.class.new(@items).publish('auto_process')</text>
103
+ <text x="60" y="555" font-family="monospace" font-size="11" fill="#f6e05e">end</text>
104
+ </g>
105
+
106
+ <!-- Parallel Workflow -->
107
+ <g>
108
+ <text x="750" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#9f7aea">
109
+ Parallel Workflow
110
+ </text>
111
+
112
+ <rect x="690" y="90" width="120" height="60" rx="8" fill="#2d3748" stroke="#9f7aea" stroke-width="2"/>
113
+ <text x="750" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#9f7aea">Start Process</text>
114
+ <text x="750" y="135" text-anchor="middle" font-family="monospace" font-size="10" fill="#e0e0e0">start_parallel</text>
115
+
116
+ <!-- Parallel operations -->
117
+ <rect x="600" y="180" width="100" height="50" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
118
+ <text x="650" y="200" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#68d391">Reserve</text>
119
+ <text x="650" y="215" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#68d391">Inventory</text>
120
+
121
+ <rect x="720" y="180" width="100" height="50" rx="8" fill="#2d3748" stroke="#4299e1" stroke-width="2"/>
122
+ <text x="770" y="200" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#4299e1">Authorize</text>
123
+ <text x="770" y="215" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#4299e1">Payment</text>
124
+
125
+ <rect x="840" y="180" width="100" height="50" rx="8" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
126
+ <text x="890" y="200" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#f6e05e">Calculate</text>
127
+ <text x="890" y="215" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#f6e05e">Shipping</text>
128
+
129
+ <!-- Convergence -->
130
+ <rect x="720" y="260" width="100" height="50" rx="8" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
131
+ <text x="770" y="280" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#e53e3e">Complete</text>
132
+ <text x="770" y="295" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#e53e3e">Order</text>
133
+
134
+ <!-- Arrows -->
135
+ <line x1="720" y1="150" x2="650" y2="180" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
136
+ <line x1="750" y1="150" x2="770" y2="180" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
137
+ <line x1="780" y1="150" x2="890" y2="180" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
138
+
139
+ <line x1="650" y1="230" x2="720" y2="270" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
140
+ <line x1="770" y1="230" x2="770" y2="260" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
141
+ <line x1="890" y1="230" x2="820" y2="270" stroke="#9f7aea" stroke-width="2" marker-end="url(#arrow-parallel)"/>
142
+
143
+ <!-- Code example -->
144
+ <rect x="630" y="330" width="340" height="120" rx="8" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
145
+ <text x="640" y="350" font-family="monospace" font-size="11" fill="#9f7aea">def start_parallel_processing</text>
146
+ <text x="650" y="365" font-family="monospace" font-size="11" fill="#9ca3af"># Trigger multiple parallel operations</text>
147
+ <text x="650" y="380" font-family="monospace" font-size="11" fill="#e0e0e0">InventoryMessage.new(@items).publish('reserve_items')</text>
148
+ <text x="650" y="395" font-family="monospace" font-size="11" fill="#e0e0e0">PaymentMessage.new(@items).publish('authorize_payment')</text>
149
+ <text x="650" y="410" font-family="monospace" font-size="11" fill="#e0e0e0">ShippingMessage.new(@items).publish('calculate_shipping')</text>
150
+ <text x="650" y="425" font-family="monospace" font-size="11" fill="#68d391">success!</text>
151
+ <text x="640" y="440" font-family="monospace" font-size="11" fill="#9f7aea">end</text>
152
+ </g>
153
+
154
+ <!-- State Tracking -->
155
+ <g>
156
+ <text x="200" y="590" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">
157
+ Workflow State Management
158
+ </text>
159
+
160
+ <rect x="50" y="610" width="300" height="140" rx="8" fill="#2d3748" stroke="#4a5568" stroke-width="2"/>
161
+ <text x="200" y="635" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#e0e0e0">State Tracking</text>
162
+
163
+ <text x="60" y="655" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:workflow_state] = 'initialized'</text>
164
+ <text x="60" y="670" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:completed_steps] = []</text>
165
+ <text x="60" y="685" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:current_step] = 'validate'</text>
166
+ <text x="60" y="700" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:started_at] = Time.current</text>
167
+ <text x="60" y="715" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:retry_count] = 0</text>
168
+ <text x="60" y="730" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:error_history] = []</text>
169
+ <text x="60" y="745" font-family="monospace" font-size="10" fill="#e0e0e0">@items[:metadata] = {...}</text>
170
+
171
+ <!-- Benefits -->
172
+ <rect x="370" y="610" width="300" height="140" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
173
+ <text x="520" y="635" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#68d391">Workflow Benefits</text>
174
+
175
+ <text x="380" y="655" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Complex business processes</text>
176
+ <text x="380" y="670" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Step-by-step execution</text>
177
+ <text x="380" y="685" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Error recovery at any step</text>
178
+ <text x="380" y="700" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Parallel processing support</text>
179
+ <text x="380" y="715" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ State persistence</text>
180
+ <text x="380" y="730" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Audit trail</text>
181
+ <text x="380" y="745" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">✅ Conditional branching</text>
182
+ </g>
183
+ </svg>
@@ -0,0 +1,72 @@
1
+ <svg width="800" height="600" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="800" height="600" fill="transparent"/>
3
+
4
+ <!-- Title -->
5
+ <text x="400" y="30" text-anchor="middle" font-family="Arial, sans-serif" font-size="18" font-weight="bold" fill="#e0e0e0">
6
+ YAML Configuration Structure
7
+ </text>
8
+
9
+ <!-- Configuration File Example -->
10
+ <g>
11
+ <text x="400" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#4299e1">
12
+ bunny_farm.yml Structure
13
+ </text>
14
+
15
+ <rect x="50" y="90" width="700" height="320" rx="8" fill="#2d3748" stroke="#4299e1" stroke-width="2"/>
16
+ <text x="400" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#4299e1">Complete Configuration Example</text>
17
+
18
+ <!-- RabbitMQ Section -->
19
+ <text x="70" y="140" font-family="monospace" font-size="11" fill="#68d391"># RabbitMQ Connection Settings</text>
20
+ <text x="70" y="155" font-family="monospace" font-size="11" fill="#f6e05e">rabbitmq:</text>
21
+ <text x="90" y="170" font-family="monospace" font-size="11" fill="#e0e0e0">url: "amqp://localhost:5672"</text>
22
+ <text x="90" y="185" font-family="monospace" font-size="11" fill="#e0e0e0">username: "bunny_user"</text>
23
+ <text x="90" y="200" font-family="monospace" font-size="11" fill="#e0e0e0">password: "bunny_pass"</text>
24
+ <text x="90" y="215" font-family="monospace" font-size="11" fill="#e0e0e0">vhost: "/production"</text>
25
+
26
+ <!-- Exchange Section -->
27
+ <text x="70" y="240" font-family="monospace" font-size="11" fill="#68d391"># Message Routing</text>
28
+ <text x="70" y="255" font-family="monospace" font-size="11" fill="#f6e05e">exchange:</text>
29
+ <text x="90" y="270" font-family="monospace" font-size="11" fill="#e0e0e0">name: "bunny_farm_production"</text>
30
+ <text x="90" y="285" font-family="monospace" font-size="11" fill="#e0e0e0">type: "topic"</text>
31
+ <text x="90" y="300" font-family="monospace" font-size="11" fill="#e0e0e0">durable: true</text>
32
+
33
+ <!-- Error Handling -->
34
+ <text x="70" y="325" font-family="monospace" font-size="11" fill="#68d391"># Error Handling</text>
35
+ <text x="70" y="340" font-family="monospace" font-size="11" fill="#f6e05e">retry:</text>
36
+ <text x="90" y="355" font-family="monospace" font-size="11" fill="#e0e0e0">max_attempts: 5</text>
37
+ <text x="90" y="370" font-family="monospace" font-size="11" fill="#e0e0e0">backoff: "exponential"</text>
38
+ <text x="90" y="385" font-family="monospace" font-size="11" fill="#e0e0e0">initial_delay: 2</text>
39
+ <text x="70" y="400" font-family="monospace" font-size="11" fill="#f6e05e">dead_letter_queue: "failed_messages"</text>
40
+ </g>
41
+
42
+ <!-- Environment-Specific Configs -->
43
+ <g>
44
+ <text x="400" y="450" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">
45
+ Environment-Specific Configuration
46
+ </text>
47
+
48
+ <!-- Development -->
49
+ <rect x="50" y="470" width="220" height="100" rx="6" fill="#1a202c" stroke="#68d391" stroke-width="1"/>
50
+ <text x="160" y="490" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#68d391">development.yml</text>
51
+ <text x="60" y="510" font-family="monospace" font-size="10" fill="#e0e0e0">rabbitmq:</text>
52
+ <text x="70" y="525" font-family="monospace" font-size="10" fill="#e0e0e0">url: "amqp://localhost:5672"</text>
53
+ <text x="60" y="540" font-family="monospace" font-size="10" fill="#e0e0e0">exchange:</text>
54
+ <text x="70" y="555" font-family="monospace" font-size="10" fill="#e0e0e0">name: "bunny_farm_dev"</text>
55
+
56
+ <!-- Testing -->
57
+ <rect x="290" y="470" width="220" height="100" rx="6" fill="#1a202c" stroke="#f6e05e" stroke-width="1"/>
58
+ <text x="400" y="490" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#f6e05e">test.yml</text>
59
+ <text x="300" y="510" font-family="monospace" font-size="10" fill="#e0e0e0">rabbitmq:</text>
60
+ <text x="310" y="525" font-family="monospace" font-size="10" fill="#e0e0e0">url: "amqp://test:5672"</text>
61
+ <text x="300" y="540" font-family="monospace" font-size="10" fill="#e0e0e0">exchange:</text>
62
+ <text x="310" y="555" font-family="monospace" font-size="10" fill="#e0e0e0">name: "bunny_farm_test"</text>
63
+
64
+ <!-- Production -->
65
+ <rect x="530" y="470" width="220" height="100" rx="6" fill="#1a202c" stroke="#e53e3e" stroke-width="1"/>
66
+ <text x="640" y="490" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#e53e3e">production.yml</text>
67
+ <text x="540" y="510" font-family="monospace" font-size="10" fill="#e0e0e0">rabbitmq:</text>
68
+ <text x="550" y="525" font-family="monospace" font-size="10" fill="#e0e0e0">url: "amqp://prod:5672"</text>
69
+ <text x="540" y="540" font-family="monospace" font-size="10" fill="#e0e0e0">exchange:</text>
70
+ <text x="550" y="555" font-family="monospace" font-size="10" fill="#e0e0e0">name: "bunny_farm_prod"</text>
71
+ </g>
72
+ </svg>
@@ -0,0 +1,14 @@
1
+ # Environment Variables
2
+
3
+ Complete reference for BunnyFarm environment variables.
4
+
5
+ ## Connection Variables
6
+ - `AMQP_HOST` - RabbitMQ hostname
7
+ - `AMQP_PORT` - Connection port
8
+ - `AMQP_USER` - Username
9
+ - `AMQP_PASS` - Password
10
+
11
+ ## Message Routing
12
+ - `AMQP_EXCHANGE` - Exchange name
13
+ - `AMQP_QUEUE` - Queue name
14
+ - `AMQP_ROUTING_KEY` - Routing key pattern
@@ -0,0 +1,373 @@
1
+ # Configuration Overview
2
+
3
+ BunnyFarm provides flexible configuration options to suit different environments and deployment scenarios. This guide covers all available configuration methods and options.
4
+
5
+ <img src="../assets/configuration_flow.svg" alt="Configuration Flow" width="100%">
6
+
7
+ ## Configuration Methods
8
+
9
+ BunnyFarm supports multiple configuration approaches that follow a clear priority hierarchy:
10
+
11
+ 1. **Built-in defaults** - Safe defaults for development
12
+ 2. **YAML configuration files** - Environment-specific settings
13
+ 3. **Environment variables** - Runtime configuration
14
+ 4. **Programmatic configuration** - Code-based overrides
15
+
16
+ Later configurations override earlier ones, giving you maximum flexibility.
17
+
18
+ ## Environment Variables
19
+
20
+ The simplest way to configure BunnyFarm is through environment variables:
21
+
22
+ ```bash
23
+ # Connection settings
24
+ export AMQP_HOST=localhost
25
+ export AMQP_VHOST=/
26
+ export AMQP_PORT=5672
27
+ export AMQP_USER=guest
28
+ export AMQP_PASS=guest
29
+
30
+ # Message routing
31
+ export AMQP_EXCHANGE=my_exchange
32
+ export AMQP_QUEUE=my_queue
33
+ export AMQP_ROUTING_KEY='#'
34
+
35
+ # Application identity
36
+ export AMQP_APP_NAME=my_app
37
+ ```
38
+
39
+ ## Programmatic Configuration
40
+
41
+ Configure BunnyFarm directly in your Ruby code:
42
+
43
+ ```ruby
44
+ BunnyFarm.config do
45
+ env 'production'
46
+ app_id 'order_processor'
47
+ bunny_file 'config/rabbitmq.yml.erb'
48
+ end
49
+ ```
50
+
51
+ ### Available Options
52
+
53
+ #### Basic Configuration
54
+ ```ruby
55
+ BunnyFarm.config do
56
+ app_id 'my_application' # Application identifier
57
+ env 'production' # Environment name
58
+ end
59
+ ```
60
+
61
+ #### File-based Configuration
62
+ ```ruby
63
+ BunnyFarm.config do
64
+ bunny_file 'config/custom.yml' # Custom config file path
65
+ end
66
+ ```
67
+
68
+ ## YAML Configuration
69
+
70
+ Use YAML files for environment-specific configuration with ERB support:
71
+
72
+ **config/bunny.yml.erb:**
73
+ ```yaml
74
+ defaults: &defaults
75
+ host: <%= ENV['AMQP_HOST'] || 'localhost' %>
76
+ vhost: <%= ENV['AMQP_VHOST'] || '/' %>
77
+ port: <%= (ENV['AMQP_PORT'] || 5672).to_i %>
78
+ user: <%= ENV['AMQP_USER'] || 'guest' %>
79
+ pass: <%= ENV['AMQP_PASS'] || 'guest' %>
80
+ exchange_name: <%= ENV['AMQP_EXCHANGE'] || 'my_exchange' %>
81
+ queue_name: <%= ENV['AMQP_QUEUE'] || 'my_queue' %>
82
+ routing_key: <%= ENV['AMQP_ROUTING_KEY'] || '#' %>
83
+ app_name: <%= ENV['AMQP_APP_NAME'] || 'bunny_farm_job' %>
84
+
85
+ development:
86
+ <<: *defaults
87
+
88
+ test:
89
+ <<: *defaults
90
+ exchange_name: test_exchange
91
+ queue_name: test_queue
92
+
93
+ production:
94
+ <<: *defaults
95
+ host: amqp.production.com
96
+ exchange_name: prod_exchange
97
+ ```
98
+
99
+ ## Configuration Parameters
100
+
101
+ ### Connection Parameters
102
+
103
+ | Parameter | Environment Variable | Description | Default |
104
+ |-----------|---------------------|-------------|---------|
105
+ | `host` | `AMQP_HOST` | RabbitMQ server hostname | `localhost` |
106
+ | `vhost` | `AMQP_VHOST` | Virtual host | `/` |
107
+ | `port` | `AMQP_PORT` | Connection port | `5672` |
108
+ | `user` | `AMQP_USER` | Username | `guest` |
109
+ | `pass` | `AMQP_PASS` | Password | `guest` |
110
+
111
+ ### Message Routing Parameters
112
+
113
+ | Parameter | Environment Variable | Description | Default |
114
+ |-----------|---------------------|-------------|---------|
115
+ | `exchange_name` | `AMQP_EXCHANGE` | Exchange name | `bunny_farm_exchange` |
116
+ | `queue_name` | `AMQP_QUEUE` | Queue name | `bunny_farm_queue` |
117
+ | `routing_key` | `AMQP_ROUTING_KEY` | Routing key pattern | `#` |
118
+
119
+ ### Application Parameters
120
+
121
+ | Parameter | Environment Variable | Description | Default |
122
+ |-----------|---------------------|-------------|---------|
123
+ | `app_name` | `AMQP_APP_NAME` | Application name | `bunny_farm_app` |
124
+
125
+ ## Environment-Specific Configuration
126
+
127
+ ### Development Configuration
128
+ ```ruby
129
+ # config/environments/development.rb
130
+ BunnyFarm.config do
131
+ env 'development'
132
+ # Uses local RabbitMQ with default settings
133
+ end
134
+ ```
135
+
136
+ ### Production Configuration
137
+ ```ruby
138
+ # config/environments/production.rb
139
+ BunnyFarm.config do
140
+ env 'production'
141
+ bunny_file Rails.root.join('config', 'rabbitmq.yml.erb')
142
+ end
143
+ ```
144
+
145
+ ### Test Configuration
146
+ ```ruby
147
+ # config/environments/test.rb
148
+ BunnyFarm.config do
149
+ env 'test'
150
+ app_id 'test_suite'
151
+ end
152
+ ```
153
+
154
+ ## Common Configuration Patterns
155
+
156
+ ### Docker Configuration
157
+ ```bash
158
+ # docker-compose.yml environment section
159
+ environment:
160
+ - AMQP_HOST=rabbitmq
161
+ - AMQP_EXCHANGE=app_exchange
162
+ - AMQP_QUEUE=app_queue
163
+ - AMQP_USER=app_user
164
+ - AMQP_PASS=secret_password
165
+ ```
166
+
167
+ ### Kubernetes Configuration
168
+ ```yaml
169
+ # k8s-configmap.yaml
170
+ apiVersion: v1
171
+ kind: ConfigMap
172
+ metadata:
173
+ name: bunny-farm-config
174
+ data:
175
+ AMQP_HOST: "rabbitmq-service"
176
+ AMQP_EXCHANGE: "production_exchange"
177
+ AMQP_QUEUE: "production_queue"
178
+ ```
179
+
180
+ ### Cloud Configuration
181
+ ```ruby
182
+ # For cloud RabbitMQ services
183
+ BunnyFarm.config do
184
+ case ENV['RAILS_ENV']
185
+ when 'production'
186
+ # Use CloudAMQP URL
187
+ connection_string ENV['CLOUDAMQP_URL']
188
+ when 'staging'
189
+ connection_string ENV['STAGING_AMQP_URL']
190
+ end
191
+ end
192
+ ```
193
+
194
+ ## Advanced Configuration
195
+
196
+ ### Connection Options
197
+ ```ruby
198
+ BunnyFarm.config do
199
+ connection_options do
200
+ heartbeat 30
201
+ connection_timeout 10
202
+ read_timeout 30
203
+ write_timeout 30
204
+ end
205
+ end
206
+ ```
207
+
208
+ ### Exchange Options
209
+ ```ruby
210
+ BunnyFarm.config do
211
+ exchange_options do
212
+ durable true
213
+ auto_delete false
214
+ type :topic
215
+ end
216
+ end
217
+ ```
218
+
219
+ ### Queue Options
220
+ ```ruby
221
+ BunnyFarm.config do
222
+ queue_options do
223
+ durable true
224
+ auto_delete false
225
+ exclusive false
226
+ arguments({
227
+ 'x-message-ttl' => 60000,
228
+ 'x-max-length' => 1000
229
+ })
230
+ end
231
+ end
232
+ ```
233
+
234
+ ### Message Options
235
+ ```ruby
236
+ BunnyFarm.config do
237
+ message_options do
238
+ persistent true
239
+ mandatory false
240
+ immediate false
241
+ end
242
+ end
243
+ ```
244
+
245
+ ## Configuration Validation
246
+
247
+ BunnyFarm validates configuration at startup:
248
+
249
+ ```ruby
250
+ begin
251
+ BunnyFarm.config do
252
+ host 'invalid-host'
253
+ port 'invalid-port'
254
+ end
255
+ rescue BunnyFarm::ConfigurationError => e
256
+ puts "Configuration error: #{e.message}"
257
+ end
258
+ ```
259
+
260
+ ## Best Practices
261
+
262
+ ### 1. Use Environment Variables for Secrets
263
+ ```ruby
264
+ # Good: Use environment variables for sensitive data
265
+ BunnyFarm.config do
266
+ user ENV['RABBITMQ_USER']
267
+ pass ENV['RABBITMQ_PASSWORD']
268
+ end
269
+
270
+ # Avoid: Hard-coding secrets
271
+ BunnyFarm.config do
272
+ user 'admin'
273
+ pass 'secret123' # Don't do this!
274
+ end
275
+ ```
276
+
277
+ ### 2. Environment-Specific Configuration
278
+ ```ruby
279
+ # config/application.rb
280
+ case Rails.env
281
+ when 'development'
282
+ BunnyFarm.config { env 'development' }
283
+ when 'test'
284
+ BunnyFarm.config { env 'test' }
285
+ when 'production'
286
+ BunnyFarm.config do
287
+ env 'production'
288
+ bunny_file 'config/production_rabbitmq.yml'
289
+ end
290
+ end
291
+ ```
292
+
293
+ ### 3. Connection Pooling for High Load
294
+ ```ruby
295
+ BunnyFarm.config do
296
+ connection_pool_size 10
297
+ channel_pool_size 50
298
+ end
299
+ ```
300
+
301
+ ### 4. Monitoring Configuration
302
+ ```ruby
303
+ BunnyFarm.config do
304
+ # Enable detailed logging
305
+ log_level :info
306
+
307
+ # Health check endpoint
308
+ health_check_enabled true
309
+ health_check_port 8080
310
+ end
311
+ ```
312
+
313
+ ## Configuration Debugging
314
+
315
+ ### Check Current Configuration
316
+ ```ruby
317
+ # In Rails console or Ruby script
318
+ puts BunnyFarm.current_config.inspect
319
+ ```
320
+
321
+ ### Test Connection
322
+ ```ruby
323
+ # Verify connection works
324
+ BunnyFarm.test_connection
325
+ ```
326
+
327
+ ### Configuration Validation
328
+ ```ruby
329
+ # Validate configuration without connecting
330
+ BunnyFarm.validate_config
331
+ ```
332
+
333
+ ## Troubleshooting
334
+
335
+ ### Common Issues
336
+
337
+ #### Connection Refused
338
+ ```
339
+ Error: Connection refused - connect(2)
340
+ ```
341
+
342
+ **Solutions:**
343
+ - Verify RabbitMQ is running: `systemctl status rabbitmq-server`
344
+ - Check host and port configuration
345
+ - Verify firewall settings
346
+
347
+ #### Authentication Failed
348
+ ```
349
+ Error: ACCESS_REFUSED - Login was refused
350
+ ```
351
+
352
+ **Solutions:**
353
+ - Verify username and password
354
+ - Check user permissions in RabbitMQ
355
+ - Ensure virtual host exists and user has access
356
+
357
+ #### Exchange/Queue Not Found
358
+ ```
359
+ Error: NOT_FOUND - no exchange 'my_exchange'
360
+ ```
361
+
362
+ **Solutions:**
363
+ - Create exchange and queue manually
364
+ - Enable auto-creation in configuration
365
+ - Check exchange/queue names for typos
366
+
367
+ ## Next Steps
368
+
369
+ With configuration mastered, explore:
370
+
371
+ - **[Environment Variables](environment-variables.md)** - Complete environment variable reference
372
+ - **[YAML Configuration](yaml-configuration.md)** - Advanced YAML configuration patterns
373
+ - **[Programmatic Setup](programmatic-setup.md)** - Dynamic configuration scenarios
@@ -0,0 +1,10 @@
1
+ # Programmatic Setup
2
+
3
+ Configuring BunnyFarm through Ruby code.
4
+
5
+ ```ruby
6
+ BunnyFarm.config do
7
+ host 'amqp.example.com'
8
+ port 5672
9
+ end
10
+ ```