Skip to content

Commit 6ad2349

Browse files
committed
Fix PSUBSCRIBE and EVALSHA
1 parent ee96edb commit 6ad2349

8 files changed

Lines changed: 101 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.vscode
22
__debug*
33
build
4+
/Gemfile

Gemfile.lock

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
connection_pool (2.5.0)
5+
date (3.4.1)
6+
debug (1.10.0)
7+
irb (~> 1.10)
8+
reline (>= 0.3.8)
9+
io-console (0.8.0)
10+
irb (1.15.1)
11+
pp (>= 0.6.0)
12+
rdoc (>= 4.0.0)
13+
reline (>= 0.4.2)
14+
message_bus (4.4.1)
15+
rack (>= 1.1.3)
16+
pp (0.6.2)
17+
prettyprint
18+
prettyprint (0.2.0)
19+
psych (5.2.3)
20+
date
21+
stringio
22+
rack (3.1.12)
23+
rdbg (0.1.0)
24+
debug (>= 1.2.2)
25+
rdoc (6.13.0)
26+
psych (>= 4.0.0)
27+
redis (5.4.0)
28+
redis-client (>= 0.22.0)
29+
redis-client (0.24.0)
30+
connection_pool
31+
reline (0.6.0)
32+
io-console (~> 0.5)
33+
stringio (3.1.6)
34+
35+
PLATFORMS
36+
x86_64-linux
37+
38+
DEPENDENCIES
39+
message_bus
40+
rdbg (~> 0.1.0)
41+
redis
42+
43+
BUNDLED WITH
44+
2.6.2

handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (m *Handler) ServeRESP(conn redcon.Conn, cmd redcon.Command) {
6767
if command == "AUTH" && len(cmd.Args) == 3 {
6868
context.username = string(cmd.Args[1])
6969
conn.SetContext(context)
70-
} else if command == "SUBSCRIBE" || command == "PSUBSRIBE" {
70+
} else if command == "SUBSCRIBE" || command == "PSUBSCRIBE" {
7171
// this will detach connection from this loop
7272
context.detached = true
7373
conn.SetContext(context)

mod.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ func modSingleCommand(command, username string, args [][]byte) ([][]byte, revive
154154
}
155155
case ModifyEvalStyle, ModifyEvalShaStyle:
156156
kpos := 2
157-
if modType == ModifyEvalShaStyle {
158-
kpos = 3
159-
}
160157
if len(args) < kpos {
161158
return args, nil
162159
}

test/bus_message/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'message_bus'
4+
gem 'redis'

test/bus_message/Gemfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
connection_pool (2.5.0)
5+
message_bus (4.4.1)
6+
rack (>= 1.1.3)
7+
rack (3.1.12)
8+
redis (5.4.0)
9+
redis-client (>= 0.22.0)
10+
redis-client (0.24.0)
11+
connection_pool
12+
13+
PLATFORMS
14+
ruby
15+
x86_64-linux
16+
17+
DEPENDENCIES
18+
message_bus
19+
redis
20+
21+
BUNDLED WITH
22+
2.6.2

test/bus_message/main.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'message_bus'
2+
require 'redis'
3+
4+
# Configure MessageBus to use your custom Redis server
5+
MessageBus.configure(
6+
backend: :redis,
7+
redis_config: {
8+
url: "redis://127.0.0.1:6479/0"
9+
},
10+
)
11+
12+
# Subscribe to a channel
13+
Thread.new do
14+
MessageBus.subscribe('/test_channel') do |msg|
15+
puts "[Subscriber] Received message: #{msg.data}"
16+
end
17+
end
18+
19+
# Give the subscriber some time to start
20+
sleep 1
21+
22+
# Publish a message
23+
MessageBus.publish('/test_channel', 'Hello from MessageBus!')
24+
25+
# Keep the script running to receive messages
26+
sleep 5

test/users.acl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
user default on nopass ~default:* &default:* +@all
2+
user root on > ~* &* +@all
3+
user foo on nopass ~foo:* &foo:* +@all

0 commit comments

Comments
 (0)