Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions redis/session.pony
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,28 @@ class ref _SessionUnopened is
match _connect_info.protocol
| Resp3 =>
let cmd = _BuildHelloCommand(_connect_info)
s.state = _SessionNegotiating(_notify, _connect_info)
s._connection().send(_RespSerializer(cmd))
let data = _RespSerializer(cmd)
match s._connection().send(data)
| let _: lori.SendToken =>
s.state = _SessionNegotiating(_notify, _connect_info)
else
s._connection().close()
s.state = _SessionClosed
_notify.redis_session_closed(s)
end
| Resp2 =>
match _connect_info.password
| let password: String =>
let st = _SessionConnected(_notify)
s.state = st
let cmd = _BuildAuthCommand(_connect_info.username, password)
s._connection().send(_RespSerializer(cmd))
let data = _RespSerializer(cmd)
match s._connection().send(data)
| let _: lori.SendToken =>
s.state = _SessionConnected(_notify)
else
s._connection().close()
s.state = _SessionClosed
_notify.redis_session_closed(s)
end
| None =>
s.state = _SessionReady(_notify)
_notify.redis_session_ready(s)
Expand Down Expand Up @@ -362,8 +375,13 @@ class ref _SessionNegotiating is
match _connect_info.password
| let password: String =>
let cmd = _BuildAuthCommand(_connect_info.username, password)
s.state = _SessionConnected.from_negotiating(_notify, _readbuf)
s._connection().send(_RespSerializer(cmd))
let data = _RespSerializer(cmd)
match s._connection().send(data)
| let _: lori.SendToken =>
s.state = _SessionConnected.from_negotiating(_notify, _readbuf)
else
shutdown(s, SessionConnectionLost)
end
| None =>
s.state = _SessionReady.from_connected(_notify, _readbuf)
_notify.redis_session_ready(s)
Expand Down Expand Up @@ -399,8 +417,9 @@ class ref _SessionConnected is
TCP connected, AUTH command sent, waiting for the server's response.

AUTH is sent from `_SessionUnopened.on_connected` (or from
`_SessionNegotiating.on_response` during HELLO fallback) after
transitioning to this state.
`_SessionNegotiating.on_response` during HELLO fallback) before
transitioning to this state — the transition only happens on
successful send.
"""
let _notify: SessionStatusNotify
let _readbuf: Reader
Expand Down
Loading