smart_message 0.0.13 → 0.0.16

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +120 -0
  4. data/Gemfile.lock +3 -3
  5. data/README.md +71 -25
  6. data/docs/index.md +2 -0
  7. data/docs/reference/transports.md +46 -21
  8. data/docs/transports/memory-transport.md +2 -1
  9. data/docs/transports/multi-transport.md +484 -0
  10. data/examples/file/00_run_all_file_demos.rb +260 -0
  11. data/examples/file/01_basic_file_transport_demo.rb +237 -0
  12. data/examples/file/02_fifo_transport_demo.rb +289 -0
  13. data/examples/file/03_file_watching_demo.rb +332 -0
  14. data/examples/file/04_multi_transport_file_demo.rb +432 -0
  15. data/examples/file/README.md +257 -0
  16. data/examples/memory/00_run_all_demos.rb +317 -0
  17. data/examples/memory/01_message_deduplication_demo.rb +18 -30
  18. data/examples/memory/02_dead_letter_queue_demo.rb +9 -9
  19. data/examples/memory/03_point_to_point_orders.rb +3 -3
  20. data/examples/memory/04_publish_subscribe_events.rb +15 -15
  21. data/examples/memory/05_many_to_many_chat.rb +19 -19
  22. data/examples/memory/06_stdout_publish_only.rb +145 -0
  23. data/examples/memory/07_proc_handlers_demo.rb +13 -13
  24. data/examples/memory/08_custom_logger_demo.rb +136 -136
  25. data/examples/memory/09_error_handling_demo.rb +7 -7
  26. data/examples/memory/10_entity_addressing_basic.rb +25 -25
  27. data/examples/memory/11_entity_addressing_with_filtering.rb +32 -32
  28. data/examples/memory/12_regex_filtering_microservices.rb +10 -10
  29. data/examples/memory/14_global_configuration_demo.rb +12 -12
  30. data/examples/memory/README.md +34 -17
  31. data/examples/memory/log/demo_app.log.1 +100 -0
  32. data/examples/memory/log/demo_app.log.2 +100 -0
  33. data/examples/multi_transport_example.rb +114 -0
  34. data/examples/redis/01_smart_home_iot_demo.rb +20 -20
  35. data/examples/utilities/box_it.rb +12 -0
  36. data/examples/utilities/doing.rb +19 -0
  37. data/examples/utilities/temp.md +28 -0
  38. data/lib/smart_message/base.rb +5 -7
  39. data/lib/smart_message/errors.rb +3 -0
  40. data/lib/smart_message/header.rb +1 -1
  41. data/lib/smart_message/logger/default.rb +1 -1
  42. data/lib/smart_message/messaging.rb +36 -6
  43. data/lib/smart_message/plugins.rb +46 -4
  44. data/lib/smart_message/serializer/base.rb +1 -1
  45. data/lib/smart_message/serializer.rb +3 -2
  46. data/lib/smart_message/subscription.rb +18 -20
  47. data/lib/smart_message/transport/async_publish_queue.rb +284 -0
  48. data/lib/smart_message/transport/fifo_operations.rb +264 -0
  49. data/lib/smart_message/transport/file_operations.rb +200 -0
  50. data/lib/smart_message/transport/file_transport.rb +149 -0
  51. data/lib/smart_message/transport/file_watching.rb +72 -0
  52. data/lib/smart_message/transport/partitioned_files.rb +46 -0
  53. data/lib/smart_message/transport/stdout_transport.rb +50 -36
  54. data/lib/smart_message/transport/stdout_transport.rb.backup +88 -0
  55. data/lib/smart_message/version.rb +1 -1
  56. metadata +24 -10
  57. data/ideas/README.md +0 -41
  58. data/ideas/agents.md +0 -1001
  59. data/ideas/database_transport.md +0 -980
  60. data/ideas/improvement.md +0 -359
  61. data/ideas/meshage.md +0 -1788
  62. data/ideas/message_discovery.md +0 -178
  63. data/ideas/message_schema.md +0 -1381
  64. data/lib/smart_message/wrapper.rb.bak +0 -132
  65. /data/examples/memory/{06_pretty_print_demo.rb → 16_pretty_print_demo.rb} +0 -0
@@ -1,132 +0,0 @@
1
- # lib/smart_message/wrapper.rb
2
- # encoding: utf-8
3
- # frozen_string_literal: true
4
-
5
- require 'securerandom' # STDLIB
6
- require_relative './header.rb'
7
-
8
- module SmartMessage
9
- module Wrapper
10
- # Every smart message has a common wrapper format that contains
11
- # information used to support the dispatching of subscribed
12
- # messages upon receipt from a transport as well as the serialized
13
- # payload.
14
- #
15
- # The wrapper consolidates header and payload into a single object
16
- # for cleaner method signatures throughout the SmartMessage dataflow.
17
- class Base < Hashie::Dash
18
- include Hashie::Extensions::IndifferentAccess
19
- include Hashie::Extensions::MethodAccess
20
- include Hashie::Extensions::DeepMerge
21
-
22
- # Core wrapper properties
23
- # Using '_sm_' prefix to avoid collision with user message definitions
24
- property :_sm_header,
25
- required: true,
26
- description: "SmartMessage header containing routing and metadata information"
27
-
28
- property :_sm_payload,
29
- required: true,
30
- description: "Serialized message payload containing the business data"
31
-
32
- # Create wrapper from header and payload
33
- def initialize(header: nil, payload: nil, **props, &block)
34
- # Handle different initialization patterns
35
- if header && payload
36
- attributes = {
37
- _sm_header: header,
38
- _sm_payload: payload
39
- }
40
- else
41
- # Create default header if not provided
42
- default_header = SmartMessage::Header.new(
43
- uuid: SecureRandom.uuid,
44
- message_class: 'SmartMessage::Wrapper::Base',
45
- published_at: Time.now,
46
- publisher_pid: Process.pid,
47
- version: 1
48
- )
49
-
50
- attributes = {
51
- _sm_header: default_header,
52
- _sm_payload: nil
53
- }.merge(props)
54
- end
55
-
56
- super(attributes, &block)
57
- end
58
-
59
- # Convenience accessors for header and payload
60
- def header
61
- _sm_header
62
- end
63
-
64
- def payload
65
- _sm_payload
66
- end
67
-
68
- # Check if this is a broadcast message (to field is nil)
69
- def broadcast?
70
- _sm_header.to.nil?
71
- end
72
-
73
- # Check if this is a directed message (to field is present)
74
- def directed?
75
- !broadcast?
76
- end
77
-
78
- # Get message class from header
79
- def message_class
80
- _sm_header.message_class
81
- end
82
-
83
- # Get sender from header
84
- def from
85
- _sm_header.from
86
- end
87
-
88
- # Get recipient from header
89
- def to
90
- _sm_header.to
91
- end
92
-
93
- # Get reply destination from header
94
- def reply_to
95
- _sm_header.reply_to
96
- end
97
-
98
- # Get message version from header
99
- def version
100
- _sm_header.version
101
- end
102
-
103
- # Get UUID from header
104
- def uuid
105
- _sm_header.uuid
106
- end
107
-
108
- # Convert wrapper to hash for serialization/transport
109
- def to_hash
110
- {
111
- '_sm_header' => _sm_header.to_hash,
112
- '_sm_payload' => _sm_payload
113
- }
114
- end
115
-
116
- alias_method :to_h, :to_hash
117
-
118
- # Outer-level JSON serialization for the wrapper
119
- # This is level 2 serialization - always JSON for routing/monitoring
120
- def to_json(*args)
121
- require 'json'
122
- to_hash.to_json(*args)
123
- end
124
-
125
- # Split wrapper into header and payload components
126
- # Enables destructuring assignment: header, payload = wrapper.split
127
- def split
128
- [_sm_header, _sm_payload]
129
- end
130
- end
131
- end
132
- end