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.
- checksums.yaml +7 -0
- data/.envrc +1 -0
- data/.github/workflows/docs.yml +38 -0
- data/.gitignore +11 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +61 -0
- data/COMMITS.md +196 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +330 -0
- data/Rakefile +9 -0
- data/bunny_farm.gemspec +30 -0
- data/config/bunny.yml.erb +29 -0
- data/config/bunny_test.yml.erb +29 -0
- data/config/hipchat.yml.erb +12 -0
- data/docs/api/configuration.md +9 -0
- data/docs/api/consumer.md +8 -0
- data/docs/api/message-class.md +419 -0
- data/docs/api/publisher.md +9 -0
- data/docs/architecture/integration.md +8 -0
- data/docs/architecture/message-flow.md +11 -0
- data/docs/architecture/overview.md +448 -0
- data/docs/architecture/scaling.md +8 -0
- data/docs/assets/actions_dsl_flow.svg +109 -0
- data/docs/assets/architecture_overview.svg +152 -0
- data/docs/assets/best_practices_patterns.svg +203 -0
- data/docs/assets/bunny_farm_logo.png +0 -0
- data/docs/assets/configuration_api_methods.svg +104 -0
- data/docs/assets/configuration_flow.svg +130 -0
- data/docs/assets/configuration_hierarchy.svg +70 -0
- data/docs/assets/data_processing_pipeline.svg +131 -0
- data/docs/assets/debugging_monitoring.svg +165 -0
- data/docs/assets/ecommerce_example_flow.svg +145 -0
- data/docs/assets/email_campaign_example.svg +127 -0
- data/docs/assets/environment_variables_map.svg +78 -0
- data/docs/assets/error_handling_flow.svg +114 -0
- data/docs/assets/favicon.ico +1 -0
- data/docs/assets/fields_dsl_structure.svg +89 -0
- data/docs/assets/instance_methods_lifecycle.svg +137 -0
- data/docs/assets/integration_patterns.svg +207 -0
- data/docs/assets/json_serialization_flow.svg +153 -0
- data/docs/assets/logo.svg +4 -0
- data/docs/assets/message_api_overview.svg +126 -0
- data/docs/assets/message_encapsulation.svg +113 -0
- data/docs/assets/message_lifecycle.svg +110 -0
- data/docs/assets/message_structure.svg +138 -0
- data/docs/assets/publisher_consumer_api.svg +120 -0
- data/docs/assets/scaling_deployment_patterns.svg +195 -0
- data/docs/assets/smart_routing_diagram.svg +131 -0
- data/docs/assets/system_architecture_overview.svg +155 -0
- data/docs/assets/task_scheduling_flow.svg +139 -0
- data/docs/assets/testing_strategies.svg +146 -0
- data/docs/assets/workflow_patterns.svg +183 -0
- data/docs/assets/yaml_config_structure.svg +72 -0
- data/docs/configuration/environment-variables.md +14 -0
- data/docs/configuration/overview.md +373 -0
- data/docs/configuration/programmatic-setup.md +10 -0
- data/docs/configuration/yaml-configuration.md +12 -0
- data/docs/core-features/configuration.md +528 -0
- data/docs/core-features/error-handling.md +82 -0
- data/docs/core-features/json-serialization.md +545 -0
- data/docs/core-features/message-design.md +406 -0
- data/docs/core-features/smart-routing.md +467 -0
- data/docs/core-features/task-scheduling.md +67 -0
- data/docs/core-features/workflow-support.md +112 -0
- data/docs/development/contributing.md +345 -0
- data/docs/development/roadmap.md +9 -0
- data/docs/development/testing.md +14 -0
- data/docs/examples/order-processing.md +10 -0
- data/docs/examples/overview.md +269 -0
- data/docs/examples/real-world.md +8 -0
- data/docs/examples/simple-producer-consumer.md +15 -0
- data/docs/examples/task-scheduler.md +9 -0
- data/docs/getting-started/basic-concepts.md +274 -0
- data/docs/getting-started/installation.md +122 -0
- data/docs/getting-started/quick-start.md +158 -0
- data/docs/index.md +106 -0
- data/docs/message-structure/actions-dsl.md +163 -0
- data/docs/message-structure/fields-dsl.md +146 -0
- data/docs/message-structure/instance-methods.md +115 -0
- data/docs/message-structure/overview.md +211 -0
- data/examples/README.md +212 -0
- data/examples/consumer.rb +41 -0
- data/examples/images/message_flow.svg +87 -0
- data/examples/images/order_workflow.svg +122 -0
- data/examples/images/producer_consumer.svg +96 -0
- data/examples/images/task_scheduler.svg +140 -0
- data/examples/order_processor.rb +238 -0
- data/examples/producer.rb +60 -0
- data/examples/simple_message.rb +43 -0
- data/examples/task_scheduler.rb +263 -0
- data/images/architecture_overview.svg +152 -0
- data/images/bunny_farm_logo.png +0 -0
- data/images/configuration_flow.svg +130 -0
- data/images/message_structure.svg +138 -0
- data/lib/bunny_farm/.irbrc +7 -0
- data/lib/bunny_farm/generic_consumer.rb +12 -0
- data/lib/bunny_farm/hash_ext.rb +37 -0
- data/lib/bunny_farm/init_bunny.rb +137 -0
- data/lib/bunny_farm/init_hipchat.rb +49 -0
- data/lib/bunny_farm/message.rb +218 -0
- data/lib/bunny_farm/message_elements.rb +25 -0
- data/lib/bunny_farm/version.rb +3 -0
- data/lib/bunny_farm.rb +9 -0
- data/mkdocs.yml +148 -0
- metadata +244 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<svg width="900" height="600" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="900" height="600" fill="transparent"/>
|
|
3
|
+
|
|
4
|
+
<!-- Title -->
|
|
5
|
+
<text x="450" y="30" text-anchor="middle" font-family="Arial, sans-serif" font-size="18" font-weight="bold" fill="#e0e0e0">
|
|
6
|
+
Message API Overview
|
|
7
|
+
</text>
|
|
8
|
+
|
|
9
|
+
<!-- Class Hierarchy -->
|
|
10
|
+
<g>
|
|
11
|
+
<text x="450" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#4299e1">
|
|
12
|
+
Class Hierarchy and API Structure
|
|
13
|
+
</text>
|
|
14
|
+
|
|
15
|
+
<!-- Base Message Class -->
|
|
16
|
+
<rect x="350" y="90" width="200" height="80" rx="8" fill="#2d3748" stroke="#4299e1" stroke-width="3"/>
|
|
17
|
+
<text x="450" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#4299e1">BunnyFarm::Message</text>
|
|
18
|
+
<text x="450" y="135" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#e0e0e0">Base class for all messages</text>
|
|
19
|
+
<text x="450" y="150" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#9ca3af">Core functionality</text>
|
|
20
|
+
<text x="450" y="165" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#9ca3af">Field management, publishing</text>
|
|
21
|
+
|
|
22
|
+
<!-- Derived Classes -->
|
|
23
|
+
<rect x="100" y="200" width="150" height="60" rx="6" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
|
|
24
|
+
<text x="175" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#68d391">OrderMessage</text>
|
|
25
|
+
<text x="175" y="240" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">extends Message</text>
|
|
26
|
+
<text x="175" y="255" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#9ca3af">Business logic</text>
|
|
27
|
+
|
|
28
|
+
<rect x="275" y="200" width="150" height="60" rx="6" fill="#2d3748" stroke="#9f7aea" stroke-width="2"/>
|
|
29
|
+
<text x="350" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#9f7aea">EmailMessage</text>
|
|
30
|
+
<text x="350" y="240" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">extends Message</text>
|
|
31
|
+
<text x="350" y="255" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#9ca3af">Email handling</text>
|
|
32
|
+
|
|
33
|
+
<rect x="450" y="200" width="150" height="60" rx="6" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
|
|
34
|
+
<text x="525" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#f6e05e">ReportMessage</text>
|
|
35
|
+
<text x="525" y="240" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">extends Message</text>
|
|
36
|
+
<text x="525" y="255" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#9ca3af">Report generation</text>
|
|
37
|
+
|
|
38
|
+
<rect x="625" y="200" width="150" height="60" rx="6" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
|
|
39
|
+
<text x="700" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#e53e3e">TaskMessage</text>
|
|
40
|
+
<text x="700" y="240" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">extends Message</text>
|
|
41
|
+
<text x="700" y="255" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#9ca3af">Task execution</text>
|
|
42
|
+
</g>
|
|
43
|
+
|
|
44
|
+
<!-- Core API Methods -->
|
|
45
|
+
<g>
|
|
46
|
+
<text x="450" y="310" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">
|
|
47
|
+
Core API Methods by Category
|
|
48
|
+
</text>
|
|
49
|
+
|
|
50
|
+
<!-- Initialization -->
|
|
51
|
+
<rect x="50" y="330" width="170" height="120" rx="6" fill="#2d3748" stroke="#68d391" stroke-width="1"/>
|
|
52
|
+
<text x="135" y="355" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#68d391">Initialization</text>
|
|
53
|
+
<text x="60" y="375" font-family="monospace" font-size="10" fill="#e0e0e0">new(data = {})</text>
|
|
54
|
+
<text x="60" y="390" font-family="monospace" font-size="10" fill="#e0e0e0">initialize(data)</text>
|
|
55
|
+
<text x="60" y="405" font-family="monospace" font-size="10" fill="#e0e0e0">setup!</text>
|
|
56
|
+
<text x="60" y="420" font-family="monospace" font-size="10" fill="#e0e0e0">configure(options)</text>
|
|
57
|
+
<text x="60" y="435" font-family="monospace" font-size="10" fill="#e0e0e0">from_json(json_str)</text>
|
|
58
|
+
|
|
59
|
+
<!-- Field Management -->
|
|
60
|
+
<rect x="240" y="330" width="170" height="120" rx="6" fill="#2d3748" stroke="#4299e1" stroke-width="1"/>
|
|
61
|
+
<text x="325" y="355" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#4299e1">Field Management</text>
|
|
62
|
+
<text x="250" y="375" font-family="monospace" font-size="10" fill="#e0e0e0">[](field_name)</text>
|
|
63
|
+
<text x="250" y="390" font-family="monospace" font-size="10" fill="#e0e0e0">[]=(field, value)</text>
|
|
64
|
+
<text x="250" y="405" font-family="monospace" font-size="10" fill="#e0e0e0">field_names</text>
|
|
65
|
+
<text x="250" y="420" font-family="monospace" font-size="10" fill="#e0e0e0">has_field?(name)</text>
|
|
66
|
+
<text x="250" y="435" font-family="monospace" font-size="10" fill="#e0e0e0">clear_field(name)</text>
|
|
67
|
+
|
|
68
|
+
<!-- Publishing -->
|
|
69
|
+
<rect x="430" y="330" width="170" height="120" rx="6" fill="#2d3748" stroke="#9f7aea" stroke-width="1"/>
|
|
70
|
+
<text x="515" y="355" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#9f7aea">Publishing</text>
|
|
71
|
+
<text x="440" y="375" font-family="monospace" font-size="10" fill="#e0e0e0">publish(action)</text>
|
|
72
|
+
<text x="440" y="390" font-family="monospace" font-size="10" fill="#e0e0e0">publish_at(time)</text>
|
|
73
|
+
<text x="440" y="405" font-family="monospace" font-size="10" fill="#e0e0e0">publish_in(delay)</text>
|
|
74
|
+
<text x="440" y="420" font-family="monospace" font-size="10" fill="#e0e0e0">schedule(cron)</text>
|
|
75
|
+
<text x="440" y="435" font-family="monospace" font-size="10" fill="#e0e0e0">broadcast</text>
|
|
76
|
+
|
|
77
|
+
<!-- Validation -->
|
|
78
|
+
<rect x="620" y="330" width="170" height="120" rx="6" fill="#2d3748" stroke="#f6e05e" stroke-width="1"/>
|
|
79
|
+
<text x="705" y="355" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#f6e05e">Validation</text>
|
|
80
|
+
<text x="630" y="375" font-family="monospace" font-size="10" fill="#e0e0e0">valid?</text>
|
|
81
|
+
<text x="630" y="390" font-family="monospace" font-size="10" fill="#e0e0e0">validate!</text>
|
|
82
|
+
<text x="630" y="405" font-family="monospace" font-size="10" fill="#e0e0e0">errors</text>
|
|
83
|
+
<text x="630" y="420" font-family="monospace" font-size="10" fill="#e0e0e0">add_error(msg)</text>
|
|
84
|
+
<text x="630" y="435" font-family="monospace" font-size="10" fill="#e0e0e0">clear_errors</text>
|
|
85
|
+
</g>
|
|
86
|
+
|
|
87
|
+
<!-- Method Usage Examples -->
|
|
88
|
+
<g>
|
|
89
|
+
<text x="450" y="490" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">
|
|
90
|
+
Common Usage Patterns
|
|
91
|
+
</text>
|
|
92
|
+
|
|
93
|
+
<!-- Creation Pattern -->
|
|
94
|
+
<rect x="50" y="510" width="250" height="70" rx="6" fill="#1a202c" stroke="#68d391" stroke-width="1"/>
|
|
95
|
+
<text x="175" y="530" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#68d391">Message Creation</text>
|
|
96
|
+
<text x="60" y="545" font-family="monospace" font-size="10" fill="#e0e0e0">msg = OrderMessage.new</text>
|
|
97
|
+
<text x="60" y="560" font-family="monospace" font-size="10" fill="#e0e0e0">msg[:order_id] = 12345</text>
|
|
98
|
+
<text x="60" y="575" font-family="monospace" font-size="10" fill="#e0e0e0">msg.setup!</text>
|
|
99
|
+
|
|
100
|
+
<!-- Publishing Pattern -->
|
|
101
|
+
<rect x="320" y="510" width="250" height="70" rx="6" fill="#1a202c" stroke="#9f7aea" stroke-width="1"/>
|
|
102
|
+
<text x="445" y="530" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#9f7aea">Publishing Pattern</text>
|
|
103
|
+
<text x="330" y="545" font-family="monospace" font-size="10" fill="#e0e0e0">msg.validate!</text>
|
|
104
|
+
<text x="330" y="560" font-family="monospace" font-size="10" fill="#e0e0e0">msg.publish('process')</text>
|
|
105
|
+
<text x="330" y="575" font-family="monospace" font-size="10" fill="#e0e0e0"># Routes to OrderMessage.process</text>
|
|
106
|
+
|
|
107
|
+
<!-- Error Handling Pattern -->
|
|
108
|
+
<rect x="590" y="510" width="250" height="70" rx="6" fill="#1a202c" stroke="#e53e3e" stroke-width="1"/>
|
|
109
|
+
<text x="715" y="530" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#e53e3e">Error Handling</text>
|
|
110
|
+
<text x="600" y="545" font-family="monospace" font-size="10" fill="#e0e0e0">unless msg.valid?</text>
|
|
111
|
+
<text x="610" y="560" font-family="monospace" font-size="10" fill="#e0e0e0">puts msg.errors</text>
|
|
112
|
+
<text x="600" y="575" font-family="monospace" font-size="10" fill="#e0e0e0">end</text>
|
|
113
|
+
</g>
|
|
114
|
+
|
|
115
|
+
<!-- Inheritance Arrows -->
|
|
116
|
+
<defs>
|
|
117
|
+
<marker id="arrow-inherit" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
|
|
118
|
+
<polygon points="0 0, 8 3, 0 6" fill="#4299e1"/>
|
|
119
|
+
</marker>
|
|
120
|
+
</defs>
|
|
121
|
+
|
|
122
|
+
<line x1="400" y1="170" x2="200" y2="190" stroke="#4299e1" stroke-width="2" marker-end="url(#arrow-inherit)"/>
|
|
123
|
+
<line x1="430" y1="170" x2="350" y2="190" stroke="#4299e1" stroke-width="2" marker-end="url(#arrow-inherit)"/>
|
|
124
|
+
<line x1="470" y1="170" x2="525" y2="190" stroke="#4299e1" stroke-width="2" marker-end="url(#arrow-inherit)"/>
|
|
125
|
+
<line x1="500" y1="170" x2="675" y2="190" stroke="#4299e1" stroke-width="2" marker-end="url(#arrow-inherit)"/>
|
|
126
|
+
</svg>
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
Message Encapsulation: Data + Behavior
|
|
7
|
+
</text>
|
|
8
|
+
|
|
9
|
+
<!-- Traditional Job Queue (Left Side) -->
|
|
10
|
+
<g>
|
|
11
|
+
<text x="200" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e53e3e">
|
|
12
|
+
Traditional Job Queue
|
|
13
|
+
</text>
|
|
14
|
+
|
|
15
|
+
<!-- Data structure -->
|
|
16
|
+
<rect x="50" y="90" width="300" height="80" rx="8" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
|
|
17
|
+
<text x="200" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#e53e3e">Simple Data Structure</text>
|
|
18
|
+
<text x="60" y="135" font-family="monospace" font-size="11" fill="#e0e0e0">job_data = {</text>
|
|
19
|
+
<text x="70" y="150" font-family="monospace" font-size="11" fill="#e0e0e0">action: "process_order",</text>
|
|
20
|
+
<text x="70" y="165" font-family="monospace" font-size="11" fill="#e0e0e0">order_id: 12345</text>
|
|
21
|
+
<text x="60" y="180" font-family="monospace" font-size="11" fill="#e0e0e0">}</text>
|
|
22
|
+
|
|
23
|
+
<!-- Generic Worker -->
|
|
24
|
+
<rect x="50" y="190" width="300" height="100" rx="8" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
|
|
25
|
+
<text x="200" y="215" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#e53e3e">Generic Worker Process</text>
|
|
26
|
+
<text x="60" y="235" font-family="monospace" font-size="11" fill="#e0e0e0">def handle_job(job_data)</text>
|
|
27
|
+
<text x="70" y="250" font-family="monospace" font-size="11" fill="#e0e0e0">case job_data[:action]</text>
|
|
28
|
+
<text x="70" y="265" font-family="monospace" font-size="11" fill="#e0e0e0">when "process_order"</text>
|
|
29
|
+
<text x="80" y="280" font-family="monospace" font-size="11" fill="#e0e0e0">process_order_logic</text>
|
|
30
|
+
<text x="60" y="295" font-family="monospace" font-size="11" fill="#e0e0e0">end</text>
|
|
31
|
+
|
|
32
|
+
<text x="200" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#e53e3e">❌ Data and behavior are separated</text>
|
|
33
|
+
<text x="200" y="335" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#e53e3e">❌ Hard to test individual job types</text>
|
|
34
|
+
<text x="200" y="350" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#e53e3e">❌ Worker becomes complex with many job types</text>
|
|
35
|
+
</g>
|
|
36
|
+
|
|
37
|
+
<!-- VS Arrow -->
|
|
38
|
+
<text x="400" y="210" text-anchor="middle" font-family="Arial, sans-serif" font-size="20" font-weight="bold" fill="#ff9800">VS</text>
|
|
39
|
+
|
|
40
|
+
<!-- BunnyFarm Message (Right Side) -->
|
|
41
|
+
<g>
|
|
42
|
+
<text x="600" y="70" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#68d391">
|
|
43
|
+
BunnyFarm Message
|
|
44
|
+
</text>
|
|
45
|
+
|
|
46
|
+
<!-- Message Class -->
|
|
47
|
+
<rect x="450" y="90" width="300" height="180" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
|
|
48
|
+
<text x="600" y="115" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#68d391">Message Class (Data + Behavior)</text>
|
|
49
|
+
|
|
50
|
+
<!-- Data definition -->
|
|
51
|
+
<text x="460" y="135" font-family="monospace" font-size="11" fill="#4299e1">class OrderMessage < BunnyFarm::Message</text>
|
|
52
|
+
<text x="470" y="150" font-family="monospace" font-size="11" fill="#9ca3af"># Data structure</text>
|
|
53
|
+
<text x="470" y="165" font-family="monospace" font-size="11" fill="#68d391">fields</text>
|
|
54
|
+
<text x="510" y="165" font-family="monospace" font-size="11" fill="#e0e0e0">:order_id, :customer, :items</text>
|
|
55
|
+
|
|
56
|
+
<!-- Actions definition -->
|
|
57
|
+
<text x="470" y="185" font-family="monospace" font-size="11" fill="#9ca3af"># Behavior definition</text>
|
|
58
|
+
<text x="470" y="200" font-family="monospace" font-size="11" fill="#f6e05e">actions</text>
|
|
59
|
+
<text x="520" y="200" font-family="monospace" font-size="11" fill="#e0e0e0">:validate, :process, :ship</text>
|
|
60
|
+
|
|
61
|
+
<!-- Method implementation -->
|
|
62
|
+
<text x="470" y="220" font-family="monospace" font-size="11" fill="#9ca3af"># Business logic</text>
|
|
63
|
+
<text x="470" y="235" font-family="monospace" font-size="11" fill="#f6e05e">def process</text>
|
|
64
|
+
<text x="480" y="250" font-family="monospace" font-size="11" fill="#e0e0e0">validate_order</text>
|
|
65
|
+
<text x="480" y="265" font-family="monospace" font-size="11" fill="#e0e0e0">charge_payment</text>
|
|
66
|
+
<text x="470" y="280" font-family="monospace" font-size="11" fill="#f6e05e">end</text>
|
|
67
|
+
<text x="460" y="295" font-family="monospace" font-size="11" fill="#4299e1">end</text>
|
|
68
|
+
|
|
69
|
+
<text x="600" y="320" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">✅ Data and behavior encapsulated together</text>
|
|
70
|
+
<text x="600" y="335" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">✅ Easy to unit test each message type</text>
|
|
71
|
+
<text x="600" y="350" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" fill="#68d391">✅ Self-contained and discoverable</text>
|
|
72
|
+
</g>
|
|
73
|
+
|
|
74
|
+
<!-- Benefits Section -->
|
|
75
|
+
<g>
|
|
76
|
+
<text x="400" y="390" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">
|
|
77
|
+
Benefits of Message-Centric Design
|
|
78
|
+
</text>
|
|
79
|
+
|
|
80
|
+
<!-- Benefit boxes -->
|
|
81
|
+
<rect x="50" y="410" width="160" height="120" rx="8" fill="#2d3748" stroke="#68d391" stroke-width="1"/>
|
|
82
|
+
<text x="130" y="435" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#68d391">Encapsulation</text>
|
|
83
|
+
<text x="60" y="455" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Related data and behavior</text>
|
|
84
|
+
<text x="70" y="470" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">stay together</text>
|
|
85
|
+
<text x="60" y="485" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Single responsibility</text>
|
|
86
|
+
<text x="60" y="500" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Clear boundaries</text>
|
|
87
|
+
<text x="60" y="515" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Reduced coupling</text>
|
|
88
|
+
|
|
89
|
+
<rect x="230" y="410" width="160" height="120" rx="8" fill="#2d3748" stroke="#4299e1" stroke-width="1"/>
|
|
90
|
+
<text x="310" y="435" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#4299e1">Discoverability</text>
|
|
91
|
+
<text x="240" y="455" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Easy to understand what</text>
|
|
92
|
+
<text x="250" y="470" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">a message can do</text>
|
|
93
|
+
<text x="240" y="485" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Self-documenting API</text>
|
|
94
|
+
<text x="240" y="500" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Clear interface</text>
|
|
95
|
+
<text x="240" y="515" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Introspectable</text>
|
|
96
|
+
|
|
97
|
+
<rect x="410" y="410" width="160" height="120" rx="8" fill="#2d3748" stroke="#9f7aea" stroke-width="1"/>
|
|
98
|
+
<text x="490" y="435" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#9f7aea">Testability</text>
|
|
99
|
+
<text x="420" y="455" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Individual message types</text>
|
|
100
|
+
<text x="430" y="470" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">can be unit tested</text>
|
|
101
|
+
<text x="420" y="485" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Mock dependencies easily</text>
|
|
102
|
+
<text x="420" y="500" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Test business logic</text>
|
|
103
|
+
<text x="430" y="515" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">in isolation</text>
|
|
104
|
+
|
|
105
|
+
<rect x="590" y="410" width="160" height="120" rx="8" fill="#2d3748" stroke="#f6e05e" stroke-width="1"/>
|
|
106
|
+
<text x="670" y="435" text-anchor="middle" font-family="Arial, sans-serif" font-size="13" font-weight="bold" fill="#f6e05e">Type Safety</text>
|
|
107
|
+
<text x="600" y="455" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Ruby class system</text>
|
|
108
|
+
<text x="610" y="470" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">provides structure</text>
|
|
109
|
+
<text x="600" y="485" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Field validation</text>
|
|
110
|
+
<text x="600" y="500" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• Method signatures</text>
|
|
111
|
+
<text x="600" y="515" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">• IDE support</text>
|
|
112
|
+
</g>
|
|
113
|
+
</svg>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<svg width="900" height="400" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="900" height="400" fill="transparent"/>
|
|
3
|
+
|
|
4
|
+
<!-- Title -->
|
|
5
|
+
<text x="450" y="30" text-anchor="middle" font-family="Arial, sans-serif" font-size="18" font-weight="bold" fill="#e0e0e0">
|
|
6
|
+
Message Lifecycle in BunnyFarm
|
|
7
|
+
</text>
|
|
8
|
+
|
|
9
|
+
<!-- Stage boxes -->
|
|
10
|
+
<defs>
|
|
11
|
+
<marker id="arrow-lifecycle" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
|
12
|
+
<polygon points="0 0, 10 3.5, 0 7" fill="#ff9800"/>
|
|
13
|
+
</marker>
|
|
14
|
+
</defs>
|
|
15
|
+
|
|
16
|
+
<!-- Stage 1: Creation -->
|
|
17
|
+
<g>
|
|
18
|
+
<rect x="50" y="80" width="140" height="80" rx="10" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
|
|
19
|
+
<text x="120" y="105" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#68d391">1. Creation</text>
|
|
20
|
+
<text x="120" y="125" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">message = OrderMessage.new</text>
|
|
21
|
+
<text x="120" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">message[:order_id] = 12345</text>
|
|
22
|
+
<text x="120" y="155" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Set data fields</text>
|
|
23
|
+
</g>
|
|
24
|
+
|
|
25
|
+
<!-- Stage 2: Publishing -->
|
|
26
|
+
<g>
|
|
27
|
+
<rect x="220" y="80" width="140" height="80" rx="10" fill="#2d3748" stroke="#4299e1" stroke-width="2"/>
|
|
28
|
+
<text x="290" y="105" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#4299e1">2. Publishing</text>
|
|
29
|
+
<text x="290" y="125" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">message.publish('process')</text>
|
|
30
|
+
<text x="290" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Serialize to JSON</text>
|
|
31
|
+
<text x="290" y="155" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Send to RabbitMQ</text>
|
|
32
|
+
</g>
|
|
33
|
+
|
|
34
|
+
<!-- Stage 3: Routing -->
|
|
35
|
+
<g>
|
|
36
|
+
<rect x="390" y="80" width="140" height="80" rx="10" fill="#2d3748" stroke="#9f7aea" stroke-width="2"/>
|
|
37
|
+
<text x="460" y="105" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#9f7aea">3. Routing</text>
|
|
38
|
+
<text x="460" y="125" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Key: OrderMessage.process</text>
|
|
39
|
+
<text x="460" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Exchange → Queue</text>
|
|
40
|
+
<text x="460" y="155" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Route to consumer</text>
|
|
41
|
+
</g>
|
|
42
|
+
|
|
43
|
+
<!-- Stage 4: Consumption -->
|
|
44
|
+
<g>
|
|
45
|
+
<rect x="560" y="80" width="140" height="80" rx="10" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
|
|
46
|
+
<text x="630" y="105" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#f6e05e">4. Consumption</text>
|
|
47
|
+
<text x="630" y="125" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Deserialize JSON</text>
|
|
48
|
+
<text x="630" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Create instance</text>
|
|
49
|
+
<text x="630" y="155" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Call process() method</text>
|
|
50
|
+
</g>
|
|
51
|
+
|
|
52
|
+
<!-- Stage 5: Acknowledgment -->
|
|
53
|
+
<g>
|
|
54
|
+
<rect x="730" y="80" width="140" height="80" rx="10" fill="#2d3748" stroke="#e53e3e" stroke-width="2"/>
|
|
55
|
+
<text x="800" y="105" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#e53e3e">5. Acknowledgment</text>
|
|
56
|
+
<text x="800" y="125" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">successful? → ACK</text>
|
|
57
|
+
<text x="800" y="140" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">failed? → NACK</text>
|
|
58
|
+
<text x="800" y="155" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#e0e0e0">Remove from queue</text>
|
|
59
|
+
</g>
|
|
60
|
+
|
|
61
|
+
<!-- Flow arrows -->
|
|
62
|
+
<line x1="190" y1="120" x2="220" y2="120" stroke="#ff9800" stroke-width="3" marker-end="url(#arrow-lifecycle)"/>
|
|
63
|
+
<line x1="360" y1="120" x2="390" y2="120" stroke="#ff9800" stroke-width="3" marker-end="url(#arrow-lifecycle)"/>
|
|
64
|
+
<line x1="530" y1="120" x2="560" y2="120" stroke="#ff9800" stroke-width="3" marker-end="url(#arrow-lifecycle)"/>
|
|
65
|
+
<line x1="700" y1="120" x2="730" y2="120" stroke="#ff9800" stroke-width="3" marker-end="url(#arrow-lifecycle)"/>
|
|
66
|
+
|
|
67
|
+
<!-- Data representation -->
|
|
68
|
+
<g>
|
|
69
|
+
<text x="450" y="210" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#e0e0e0">Data Transformation</text>
|
|
70
|
+
|
|
71
|
+
<!-- Ruby Object -->
|
|
72
|
+
<rect x="50" y="230" width="180" height="120" rx="8" fill="#1a202c" stroke="#68d391" stroke-width="1"/>
|
|
73
|
+
<text x="140" y="250" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#68d391">Ruby Object</text>
|
|
74
|
+
<text x="60" y="270" font-family="monospace" font-size="10" fill="#e0e0e0">message = OrderMessage.new</text>
|
|
75
|
+
<text x="60" y="285" font-family="monospace" font-size="10" fill="#e0e0e0">message[:order_id] = 12345</text>
|
|
76
|
+
<text x="60" y="300" font-family="monospace" font-size="10" fill="#e0e0e0">message[:customer] = {</text>
|
|
77
|
+
<text x="70" y="315" font-family="monospace" font-size="10" fill="#e0e0e0">name: "John Doe",</text>
|
|
78
|
+
<text x="70" y="330" font-family="monospace" font-size="10" fill="#e0e0e0">email: "john@example.com"</text>
|
|
79
|
+
<text x="60" y="345" font-family="monospace" font-size="10" fill="#e0e0e0">}</text>
|
|
80
|
+
|
|
81
|
+
<!-- Arrow -->
|
|
82
|
+
<line x1="240" y1="290" x2="280" y2="290" stroke="#ff9800" stroke-width="2" marker-end="url(#arrow-lifecycle)"/>
|
|
83
|
+
<text x="260" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#ff9800">serialize</text>
|
|
84
|
+
|
|
85
|
+
<!-- JSON -->
|
|
86
|
+
<rect x="290" y="230" width="200" height="120" rx="8" fill="#1a202c" stroke="#4299e1" stroke-width="1"/>
|
|
87
|
+
<text x="390" y="250" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#4299e1">JSON Message</text>
|
|
88
|
+
<text x="300" y="270" font-family="monospace" font-size="10" fill="#e0e0e0">{</text>
|
|
89
|
+
<text x="310" y="285" font-family="monospace" font-size="10" fill="#e0e0e0">"order_id": 12345,</text>
|
|
90
|
+
<text x="310" y="300" font-family="monospace" font-size="10" fill="#e0e0e0">"customer": {</text>
|
|
91
|
+
<text x="320" y="315" font-family="monospace" font-size="10" fill="#e0e0e0">"name": "John Doe",</text>
|
|
92
|
+
<text x="320" y="330" font-family="monospace" font-size="10" fill="#e0e0e0">"email": "john@example.com"</text>
|
|
93
|
+
<text x="310" y="345" font-family="monospace" font-size="10" fill="#e0e0e0">}</text>
|
|
94
|
+
<text x="300" y="360" font-family="monospace" font-size="10" fill="#e0e0e0">}</text>
|
|
95
|
+
|
|
96
|
+
<!-- Arrow -->
|
|
97
|
+
<line x1="500" y1="290" x2="540" y2="290" stroke="#ff9800" stroke-width="2" marker-end="url(#arrow-lifecycle)"/>
|
|
98
|
+
<text x="520" y="285" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" fill="#ff9800">deserialize</text>
|
|
99
|
+
|
|
100
|
+
<!-- Processed Object -->
|
|
101
|
+
<rect x="550" y="230" width="180" height="120" rx="8" fill="#1a202c" stroke="#68d391" stroke-width="1"/>
|
|
102
|
+
<text x="640" y="250" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#68d391">Processed Object</text>
|
|
103
|
+
<text x="560" y="270" font-family="monospace" font-size="10" fill="#e0e0e0">def process</text>
|
|
104
|
+
<text x="570" y="285" font-family="monospace" font-size="10" fill="#e0e0e0">validate_order</text>
|
|
105
|
+
<text x="570" y="300" font-family="monospace" font-size="10" fill="#e0e0e0">charge_payment</text>
|
|
106
|
+
<text x="570" y="315" font-family="monospace" font-size="10" fill="#e0e0e0">update_inventory</text>
|
|
107
|
+
<text x="570" y="330" font-family="monospace" font-size="10" fill="#e0e0e0">success!</text>
|
|
108
|
+
<text x="560" y="345" font-family="monospace" font-size="10" fill="#e0e0e0">end</text>
|
|
109
|
+
</g>
|
|
110
|
+
</svg>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<svg width="800" height="650" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<!-- Background transparent -->
|
|
3
|
+
<rect width="800" height="650" fill="transparent"/>
|
|
4
|
+
|
|
5
|
+
<!-- Title -->
|
|
6
|
+
<text x="400" y="30" text-anchor="middle" font-family="Arial, sans-serif" font-size="20" font-weight="bold" fill="#e0e0e0">
|
|
7
|
+
BunnyFarm Message Class Structure
|
|
8
|
+
</text>
|
|
9
|
+
|
|
10
|
+
<!-- Class Definition -->
|
|
11
|
+
<g>
|
|
12
|
+
<rect x="50" y="60" width="700" height="120" rx="10" fill="#2d3748" stroke="#9f7aea" stroke-width="2"/>
|
|
13
|
+
<text x="400" y="85" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#9f7aea">Message Class Definition</text>
|
|
14
|
+
|
|
15
|
+
<rect x="70" y="100" width="660" height="70" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
16
|
+
<text x="80" y="115" font-family="monospace" font-size="11" fill="#9f7aea">class OrderMessage < BunnyFarm::Message</text>
|
|
17
|
+
<text x="90" y="130" font-family="monospace" font-size="11" fill="#68d391">fields</text>
|
|
18
|
+
<text x="130" y="130" font-family="monospace" font-size="11" fill="#e0e0e0">:order_id, :total, { customer: [:name, :email] }, { items: [:id, :qty] }</text>
|
|
19
|
+
<text x="90" y="145" font-family="monospace" font-size="11" fill="#f6e05e">actions</text>
|
|
20
|
+
<text x="130" y="145" font-family="monospace" font-size="11" fill="#e0e0e0">:validate, :process_payment, :ship, :cancel</text>
|
|
21
|
+
<text x="80" y="160" font-family="monospace" font-size="11" fill="#9f7aea">end</text>
|
|
22
|
+
</g>
|
|
23
|
+
|
|
24
|
+
<!-- DSL Components -->
|
|
25
|
+
<g>
|
|
26
|
+
<rect x="50" y="200" width="340" height="160" rx="10" fill="#2d3748" stroke="#68d391" stroke-width="2"/>
|
|
27
|
+
<text x="220" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#68d391">Fields DSL</text>
|
|
28
|
+
<text x="220" y="245" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">Define expected data structure</text>
|
|
29
|
+
|
|
30
|
+
<rect x="70" y="255" width="300" height="95" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
31
|
+
<text x="80" y="270" font-family="monospace" font-size="10" fill="#68d391">Simple fields:</text>
|
|
32
|
+
<text x="80" y="285" font-family="monospace" font-size="10" fill="#e0e0e0">:name, :email, :amount</text>
|
|
33
|
+
|
|
34
|
+
<text x="80" y="305" font-family="monospace" font-size="10" fill="#68d391">Nested objects:</text>
|
|
35
|
+
<text x="80" y="320" font-family="monospace" font-size="10" fill="#e0e0e0">{ customer: [:name, :email] }</text>
|
|
36
|
+
|
|
37
|
+
<text x="80" y="340" font-family="monospace" font-size="10" fill="#68d391">Arrays of objects:</text>
|
|
38
|
+
<text x="80" y="355" font-family="monospace" font-size="10" fill="#e0e0e0">{ items: [:product_id, :quantity] }</text>
|
|
39
|
+
|
|
40
|
+
<rect x="410" y="200" width="340" height="160" rx="10" fill="#2d3748" stroke="#f6e05e" stroke-width="2"/>
|
|
41
|
+
<text x="580" y="225" text-anchor="middle" font-family="Arial, sans-serif" font-size="14" font-weight="bold" fill="#f6e05e">Actions DSL</text>
|
|
42
|
+
<text x="580" y="245" text-anchor="middle" font-family="Arial, sans-serif" font-size="11" fill="#e0e0e0">Define available operations</text>
|
|
43
|
+
|
|
44
|
+
<rect x="430" y="255" width="300" height="95" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
45
|
+
<text x="440" y="270" font-family="monospace" font-size="10" fill="#f6e05e">actions :create, :update, :delete</text>
|
|
46
|
+
<text x="440" y="290" font-family="monospace" font-size="10" fill="#9ca3af"># Each action becomes a method</text>
|
|
47
|
+
<text x="440" y="310" font-family="monospace" font-size="10" fill="#f6e05e">def create(*args)</text>
|
|
48
|
+
<text x="450" y="325" font-family="monospace" font-size="10" fill="#e0e0e0"># Process creation logic</text>
|
|
49
|
+
<text x="450" y="340" font-family="monospace" font-size="10" fill="#68d391">success!</text>
|
|
50
|
+
<text x="440" y="355" font-family="monospace" font-size="10" fill="#f6e05e">end</text>
|
|
51
|
+
</g>
|
|
52
|
+
|
|
53
|
+
<!-- Message Instance Structure -->
|
|
54
|
+
<g>
|
|
55
|
+
<rect x="50" y="380" width="700" height="140" rx="10" fill="#2d3748" stroke="#4299e1" stroke-width="2"/>
|
|
56
|
+
<text x="400" y="405" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#4299e1">Message Instance Structure</text>
|
|
57
|
+
|
|
58
|
+
<!-- Instance Variables -->
|
|
59
|
+
<rect x="80" y="420" width="200" height="90" rx="5" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
60
|
+
<text x="180" y="440" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#4299e1">Instance Variables</text>
|
|
61
|
+
<text x="90" y="455" font-family="monospace" font-size="10" fill="#68d391">@items</text>
|
|
62
|
+
<text x="125" y="455" font-family="monospace" font-size="10" fill="#e0e0e0">- Validated data</text>
|
|
63
|
+
<text x="90" y="470" font-family="monospace" font-size="10" fill="#68d391">@elements</text>
|
|
64
|
+
<text x="140" y="470" font-family="monospace" font-size="10" fill="#e0e0e0">- Raw JSON data</text>
|
|
65
|
+
<text x="90" y="485" font-family="monospace" font-size="10" fill="#68d391">@payload</text>
|
|
66
|
+
<text x="135" y="485" font-family="monospace" font-size="10" fill="#e0e0e0">- JSON string</text>
|
|
67
|
+
<text x="90" y="500" font-family="monospace" font-size="10" fill="#68d391">@errors</text>
|
|
68
|
+
<text x="130" y="500" font-family="monospace" font-size="10" fill="#e0e0e0">- Error messages</text>
|
|
69
|
+
|
|
70
|
+
<!-- Access Methods -->
|
|
71
|
+
<rect x="300" y="420" width="180" height="90" rx="5" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
72
|
+
<text x="390" y="440" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#4299e1">Access Methods</text>
|
|
73
|
+
<text x="310" y="455" font-family="monospace" font-size="10" fill="#68d391">msg[:field]</text>
|
|
74
|
+
<text x="370" y="455" font-family="monospace" font-size="10" fill="#e0e0e0">- Get value</text>
|
|
75
|
+
<text x="310" y="470" font-family="monospace" font-size="10" fill="#68d391">msg[:field] = val</text>
|
|
76
|
+
<text x="395" y="470" font-family="monospace" font-size="10" fill="#e0e0e0">- Set</text>
|
|
77
|
+
<text x="310" y="485" font-family="monospace" font-size="10" fill="#68d391">msg.to_json</text>
|
|
78
|
+
<text x="370" y="485" font-family="monospace" font-size="10" fill="#e0e0e0">- Serialize</text>
|
|
79
|
+
<text x="310" y="500" font-family="monospace" font-size="10" fill="#68d391">msg.keys</text>
|
|
80
|
+
<text x="350" y="500" font-family="monospace" font-size="10" fill="#e0e0e0">- Get fields</text>
|
|
81
|
+
|
|
82
|
+
<!-- State Methods -->
|
|
83
|
+
<rect x="500" y="420" width="220" height="90" rx="5" fill="#1a202c" stroke="#4a5568" stroke-width="1"/>
|
|
84
|
+
<text x="610" y="440" text-anchor="middle" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#4299e1">State Management</text>
|
|
85
|
+
<text x="510" y="455" font-family="monospace" font-size="10" fill="#68d391">success!</text>
|
|
86
|
+
<text x="550" y="455" font-family="monospace" font-size="10" fill="#e0e0e0">- Mark successful</text>
|
|
87
|
+
<text x="510" y="470" font-family="monospace" font-size="10" fill="#e53e3e">failure(msg)</text>
|
|
88
|
+
<text x="570" y="470" font-family="monospace" font-size="10" fill="#e0e0e0">- Mark failed</text>
|
|
89
|
+
<text x="510" y="485" font-family="monospace" font-size="10" fill="#68d391">successful?</text>
|
|
90
|
+
<text x="570" y="485" font-family="monospace" font-size="10" fill="#e0e0e0">- Check status</text>
|
|
91
|
+
<text x="510" y="500" font-family="monospace" font-size="10" fill="#68d391">publish(action)</text>
|
|
92
|
+
<text x="585" y="500" font-family="monospace" font-size="10" fill="#e0e0e0">- Send msg</text>
|
|
93
|
+
</g>
|
|
94
|
+
|
|
95
|
+
<!-- Data Flow Example -->
|
|
96
|
+
<g>
|
|
97
|
+
<rect x="50" y="540" width="700" height="100" rx="10" fill="#2d3748" stroke="#ed8936" stroke-width="2"/>
|
|
98
|
+
<text x="400" y="565" text-anchor="middle" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#ed8936">Data Flow Example</text>
|
|
99
|
+
|
|
100
|
+
<!-- Step boxes -->
|
|
101
|
+
<rect x="70" y="580" width="120" height="50" rx="5" fill="#68d391"/>
|
|
102
|
+
<text x="130" y="595" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#1a202c">1. JSON Input</text>
|
|
103
|
+
<text x="130" y="610" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">Raw message data</text>
|
|
104
|
+
<text x="130" y="620" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">from RabbitMQ</text>
|
|
105
|
+
|
|
106
|
+
<rect x="210" y="580" width="120" height="50" rx="5" fill="#4299e1"/>
|
|
107
|
+
<text x="270" y="595" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#1a202c">2. Parse & Validate</text>
|
|
108
|
+
<text x="270" y="610" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">Extract fields</text>
|
|
109
|
+
<text x="270" y="620" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">using DSL definition</text>
|
|
110
|
+
|
|
111
|
+
<rect x="350" y="580" width="120" height="50" rx="5" fill="#9f7aea"/>
|
|
112
|
+
<text x="410" y="595" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#1a202c">3. Route Action</text>
|
|
113
|
+
<text x="410" y="610" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">Call method based</text>
|
|
114
|
+
<text x="410" y="620" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">on routing key</text>
|
|
115
|
+
|
|
116
|
+
<rect x="490" y="580" width="120" height="50" rx="5" fill="#f6e05e"/>
|
|
117
|
+
<text x="550" y="595" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#1a202c">4. Execute Logic</text>
|
|
118
|
+
<text x="550" y="610" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">Run business</text>
|
|
119
|
+
<text x="550" y="620" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">logic in action</text>
|
|
120
|
+
|
|
121
|
+
<rect x="630" y="580" width="120" height="50" rx="5" fill="#e53e3e"/>
|
|
122
|
+
<text x="690" y="595" text-anchor="middle" font-family="Arial, sans-serif" font-size="10" font-weight="bold" fill="#1a202c">5. ACK/NACK</text>
|
|
123
|
+
<text x="690" y="610" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">Acknowledge</text>
|
|
124
|
+
<text x="690" y="620" text-anchor="middle" font-family="Arial, sans-serif" font-size="9" fill="#1a202c">to RabbitMQ</text>
|
|
125
|
+
|
|
126
|
+
<!-- Arrows -->
|
|
127
|
+
<defs>
|
|
128
|
+
<marker id="arrow-flow" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
|
129
|
+
<polygon points="0 0, 10 3.5, 0 7" fill="#ed8936"/>
|
|
130
|
+
</marker>
|
|
131
|
+
</defs>
|
|
132
|
+
|
|
133
|
+
<line x1="190" y1="605" x2="210" y2="605" stroke="#ed8936" stroke-width="2" marker-end="url(#arrow-flow)"/>
|
|
134
|
+
<line x1="330" y1="605" x2="350" y2="605" stroke="#ed8936" stroke-width="2" marker-end="url(#arrow-flow)"/>
|
|
135
|
+
<line x1="470" y1="605" x2="490" y2="605" stroke="#ed8936" stroke-width="2" marker-end="url(#arrow-flow)"/>
|
|
136
|
+
<line x1="610" y1="605" x2="630" y2="605" stroke="#ed8936" stroke-width="2" marker-end="url(#arrow-flow)"/>
|
|
137
|
+
</g>
|
|
138
|
+
</svg>
|