nats_messaging 0.0.1
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/lib/nats_messaging/nats_controller.rb +55 -0
- data/lib/nats_messaging.rb +9 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1c03b6275df6592138ee9f785dfadc6ee4417ea8ec31be27ef8cc6002aa89fc
|
4
|
+
data.tar.gz: 9e7113bf8a1dc643e051ced09de01dc6a40633969ef18c8914f8a6a9a8212c14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb7000f0af331471d3cd406c5cfccbffe3fa2d8ee8f147a75f1a3f9066a3f9d8e0dcc7ad85cdb3b3cb55663b819086042066c1565c7a15ba5a8f6bedcf2c0c4e
|
7
|
+
data.tar.gz: a4aa62c9f99898b0bda4d06ed73a0add93b81e87d0ee97188d2ca6923808a0475247c9af51f8bbb5a1e0de5416d318212fe86b8a3cfb267408c4b3f8a96b8dae
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class NatsController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@durable = false # Default value for the toggle
|
5
|
+
end
|
6
|
+
|
7
|
+
def publish_message
|
8
|
+
subject = params[:subject]
|
9
|
+
message = params[:message]
|
10
|
+
|
11
|
+
nats_service = Rails.application.config.nats_service
|
12
|
+
nats_service.publish_message(subject, message)
|
13
|
+
|
14
|
+
flash[:notice] = "Message published to #{subject}."
|
15
|
+
redirect_to root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def subscribe_to_subject
|
19
|
+
subject = params[:subject]
|
20
|
+
|
21
|
+
nats_service = Rails.application.config.nats_service
|
22
|
+
nats_service.subscribe_to_subject(subject, "durable_#{subject}")
|
23
|
+
|
24
|
+
flash[:notice] = "Subscribed to #{subject}"
|
25
|
+
Rails.logger.info "Suscribed to #{subject}"
|
26
|
+
redirect_to root_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def send_request
|
30
|
+
subject = params[:subject]
|
31
|
+
message = params[:message]
|
32
|
+
|
33
|
+
nats_service = NatsService.new
|
34
|
+
reply = nats_service.send_request(subject, message)
|
35
|
+
|
36
|
+
if reply
|
37
|
+
flash[:notice] = "Reply received: #{reply}"
|
38
|
+
else
|
39
|
+
flash[:alert] = "No reply received for subject: #{subject}"
|
40
|
+
end
|
41
|
+
|
42
|
+
redirect_to root_path
|
43
|
+
end
|
44
|
+
|
45
|
+
def listen_and_reply
|
46
|
+
subject = params[:subject]
|
47
|
+
reply_message = params[:reply_message]
|
48
|
+
|
49
|
+
nats_service = Rails.application.config.nats_service
|
50
|
+
nats_service.listen_and_reply(subject, reply_message)
|
51
|
+
|
52
|
+
flash[:notice] = "Listening for requests on #{subject} and replying with '#{reply_message}'"
|
53
|
+
redirect_to root_path
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nats_messaging
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bea Graboloza
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A service to send and receive messages on a Rails application using NATS
|
14
|
+
email: beatriz.graboloza@bpo-advisors.net
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/nats_messaging.rb
|
20
|
+
- lib/nats_messaging/nats_controller.rb
|
21
|
+
homepage: https://rubygems.org/gems/nats_messaging
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.0.9
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: a NATS service for messaging
|
44
|
+
test_files: []
|