@@ -62,7 +62,7 @@ write(io::IO, fv::TAMQPFieldValuePair) = write(io, fv.name, fv.val)
62
62
63
63
function read (io:: IO , :: Type{TAMQPFieldTable} )
64
64
len = ntoh (read (io, fieldtype (TAMQPFieldTable, :len )))
65
- @debug (" read fieldtable length $( len) " )
65
+ @debug (" read fieldtable" , len)
66
66
buff = read! (io, Vector {UInt8} (undef, len))
67
67
data = TAMQPFieldValuePair[]
68
68
iob = IOBuffer (buff)
@@ -73,14 +73,14 @@ function read(io::IO, ::Type{TAMQPFieldTable})
73
73
end
74
74
75
75
function write (io:: IO , ft:: TAMQPFieldTable )
76
- @debug (" write fieldtable nfields $( length (ft. data)) " )
76
+ @debug (" write fieldtable" , nfields= length (ft. data))
77
77
iob = IOBuffer ()
78
78
for fv in ft. data
79
79
write (iob, fv)
80
80
end
81
81
buff = take! (iob)
82
- len = convert ( fieldtype (TAMQPFieldTable, :len ), length (buff))
83
- @debug (" write fieldtable length $ len type: $( typeof (len)) " )
82
+ len = TAMQPLongUInt ( length (buff))
83
+ @debug (" write fieldtable" , len, type= typeof (len))
84
84
l = write (io, hton (len))
85
85
if len > 0
86
86
l += write (io, buff)
@@ -101,7 +101,7 @@ function read(io::IO, ::Type{TAMQPGenericFrame})
101
101
hdr = ntoh (read (io, fieldtype (TAMQPGenericFrame, :hdr )))
102
102
@assert hdr in (1 ,2 ,3 ,8 )
103
103
props = read (io, fieldtype (TAMQPGenericFrame, :props ))
104
- @debug (" reading generic frame type: $ hdr , channel: $( props. channel) , payloadsize: $( props. payloadsize) " )
104
+ @debug (" reading generic frame" , type= hdr, channel= props. channel, payloadsize= props. payloadsize)
105
105
payload = read! (io, TAMQPBodyPayload (Vector {TAMQPOctet} (undef, props. payloadsize)))
106
106
fend = ntoh (read (io, fieldtype (TAMQPGenericFrame, :fend )))
107
107
@assert fend == FrameEnd
@@ -267,8 +267,7 @@ function send(c::Connection, f, msgframes::Vector=[])
267
267
nothing
268
268
end
269
269
function send (c:: MessageChannel , payload:: TAMQPMethodPayload , msg:: Union{Message, Nothing} = nothing )
270
- logstrmsg = msg === nothing ? " without" : " with"
271
- @debug (" sending $(method_name (payload)) $logstrmsg content" )
270
+ @debug (" sending" , methodname= method_name (payload), hascontent= (msg != = nothing ))
272
271
frameprop = TAMQPFrameProperties (c. id,0 )
273
272
if msg != = nothing
274
273
msgframes = []
@@ -307,7 +306,7 @@ function wait_for_state(c, states; interval=1, timeout=typemax(Int))
307
306
end
308
307
309
308
function connection_processor (c, name, fn)
310
- @debug (" Starting $name task" )
309
+ @debug (" Starting task" , name )
311
310
try
312
311
while true
313
312
fn (c)
@@ -331,7 +330,7 @@ function connection_processor(c, name, fn)
331
330
@debug (reason)
332
331
else
333
332
reason = reason * " Unhandled exception: $err "
334
- # showerror(STDERR , err)
333
+ # showerror(stderr , err)
335
334
@debug (reason)
336
335
close (c, false , true )
337
336
# rethrow(err)
342
341
343
342
function connection_sender (c:: Connection )
344
343
msg = take! (c. sendq)
345
- @debug (" ==> sending on conn $( c. virtualhost) " )
344
+ @debug (" ==> sending on conn" , host = c. virtualhost)
346
345
nbytes = write (sock (c), msg)
347
- @debug (" ==> sent $ nbytes bytes " )
346
+ @debug (" ==> sent" , nbytes)
348
347
349
348
# update heartbeat time for client
350
349
c. heartbeat_time_client = time ()
@@ -359,9 +358,9 @@ function connection_receiver(c::Connection)
359
358
c. heartbeat_time_server = time ()
360
359
361
360
channelid = f. props. channel
362
- @debug (" <== read message on conn $( c. virtualhost) for chan $ channelid" )
361
+ @debug (" <== read message on conn" , host = c. virtualhost, channelid)
363
362
if ! (channelid in keys (c. channels))
364
- @debug (" Discarding message for unknown channel $ channelid" )
363
+ @debug (" Discarding message for unknown channel" , channelid)
365
364
end
366
365
chan = channel (c, channelid)
367
366
put! (chan. recvq, f)
@@ -379,7 +378,7 @@ function connection_heartbeater(c::Connection)
379
378
end
380
379
381
380
if (now - c. heartbeat_time_server) > (2 * c. heartbeat)
382
- @debug (" server heartbeat missed for $ (now - c. heartbeat_time_server) seconds " )
381
+ @debug (" server heartbeat missed" , secs = (now - c. heartbeat_time_server))
383
382
close (c, false , false )
384
383
end
385
384
nothing
@@ -389,23 +388,23 @@ function channel_receiver(c::MessageChannel)
389
388
f = take! (c. recvq)
390
389
if f. hdr == FrameMethod
391
390
m = TAMQPMethodFrame (f)
392
- @debug (" <== channel: $( f. props. channel) , class: $( m. payload. class) , method: $( m. payload. method) " )
391
+ @debug (" <== received " , channel = f. props. channel, class= m. payload. class, method= m. payload. method)
393
392
cbkey = (f. hdr, m. payload. class, m. payload. method)
394
393
elseif f. hdr == FrameHeartbeat
395
394
m = TAMQPHeartBeatFrame (f)
396
- @debug (" <== channel: $( f. props. channel) , heartbeat " )
395
+ @debug (" <== received heartbeat " , channel = f. props. channel)
397
396
cbkey = (f. hdr,)
398
397
elseif f. hdr == FrameHeader
399
398
m = TAMQPContentHeaderFrame (f)
400
- @debug (" <== channel: $( f. props. channel) , contentheader " )
399
+ @debug (" <== received contentheader " , channel = f. props. channel)
401
400
cbkey = (f. hdr,)
402
401
elseif f. hdr == FrameBody
403
402
m = TAMQPContentBodyFrame (f)
404
- @debug (" <== channel: $( f. props. channel) , contentbody " )
403
+ @debug (" <== received contentbody " , channel = f. props. channel)
405
404
cbkey = (f. hdr,)
406
405
else
407
406
m = f
408
- @debug (" <== channel: $( f. props. channel) , unhandled frame type $( f. hdr) " )
407
+ @debug (" <== received unhandled frame type " , channel = f. props. channel, type= f. hdr)
409
408
cbkey = (f. hdr,)
410
409
end
411
410
(cb,ctx) = get (c. callbacks, cbkey, (on_unexpected_message, nothing ))
@@ -489,7 +488,7 @@ function channel(c::Connection, id::Integer, create::Bool; connect_timeout=DEFAU
489
488
end
490
489
491
490
function connection (;virtualhost= " /" , host= " localhost" , port= AMQPClient. AMQP_DEFAULT_PORT, auth_params= AMQPClient. DEFAULT_AUTH_PARAMS, channelmax= AMQPClient. DEFAULT_CHANNELMAX, framemax= 0 , heartbeat= 0 , connect_timeout= AMQPClient. DEFAULT_CONNECT_TIMEOUT)
492
- @debug " connecting to $( host) : $( port)$( virtualhost)"
491
+ @debug ( " connecting" , host, port, virtualhost)
493
492
conn = AMQPClient. Connection (virtualhost, host, port)
494
493
chan = channel (conn, AMQPClient. DEFAULT_CHANNEL, true )
495
494
@@ -860,12 +859,12 @@ end
860
859
# ----------------------------------------
861
860
862
861
function on_unexpected_message (c:: MessageChannel , m:: TAMQPMethodFrame , ctx)
863
- @debug (" Unexpected message on channel $( c. id) : class: $( m. payload. class) , method: $( m. payload. method) " )
862
+ @debug (" Unexpected message" , channel= c. id, class= m. payload. class, method= m. payload. method)
864
863
nothing
865
864
end
866
865
867
866
function on_unexpected_message (c:: MessageChannel , f, ctx)
868
- @debug (" Unexpected message on channel $( c. id) : frame type: $( f. hdr) " )
867
+ @debug (" Unexpected message" , channel= c. id, frametype = f. hdr)
869
868
nothing
870
869
end
871
870
@@ -887,7 +886,7 @@ function _on_close_ok(context_class::Symbol, chan::MessageChannel, m::TAMQPMetho
887
886
end
888
887
889
888
function _send_close (context_class:: Symbol , chan:: MessageChannel , reply_code= ReplySuccess, reply_text= " " , class_id= 0 , method_id= 0 )
890
- chan. closereason = CloseReason (TAMQPReplyCode (reply_code), convert ( TAMQPReplyText, reply_text), TAMQPClassId (class_id), TAMQPMethodId (method_id))
889
+ chan. closereason = CloseReason (TAMQPReplyCode (reply_code), TAMQPReplyText ( reply_text), TAMQPClassId (class_id), TAMQPMethodId (method_id))
891
890
if context_class === :Channel && chan. id == DEFAULT_CHANNEL
892
891
@debug (" closing channel 0 is equivalent to closing the connection!" )
893
892
context_class = :Connection
@@ -898,7 +897,7 @@ function _send_close(context_class::Symbol, chan::MessageChannel, reply_code=Rep
898
897
end
899
898
900
899
_send_close (context_class:: Symbol , context_chan_id, conn:: Connection , reply_code= ReplySuccess, reply_text= " " , class_id= 0 , method_id= 0 , chan_id= 0 ) =
901
- send (conn, TAMQPMethodFrame (TAMQPFrameProperties (context_chan_id,0 ), TAMQPMethodPayload (context_class, :Close , (TAMQPReplyCode (reply_code), convert ( TAMQPReplyText, reply_text), TAMQPClassId (class_id), TAMQPMethodId (method_id)))))
900
+ send (conn, TAMQPMethodFrame (TAMQPFrameProperties (context_chan_id,0 ), TAMQPMethodPayload (context_class, :Close , (TAMQPReplyCode (reply_code), TAMQPReplyText ( reply_text), TAMQPClassId (class_id), TAMQPMethodId (method_id)))))
902
901
903
902
send_connection_close_ok (chan:: MessageChannel ) = _send_close_ok (:Connection , chan)
904
903
on_connection_close_ok (chan:: MessageChannel , m:: TAMQPMethodFrame , ctx) = _on_close_ok (:Connection , chan, m, ctx)
@@ -934,12 +933,10 @@ function on_connection_start(chan::MessageChannel, m::TAMQPMethodFrame, ctx)
934
933
conn = chan. conn
935
934
936
935
# setup server properties and capabilities
937
- merge! (conn. properties, Dict {Symbol,Any} (m. payload. fields... ))
938
- server_props = convert (Dict{String,Any}, get_property (chan, :ServerProperties , Dict {String,Any} ()))
936
+ merge! (conn. properties, Dict {Symbol,Any} (Symbol (n) => simplify (v) for (n,v) in m. payload. fields))
937
+ server_props = simplify ( get_property (chan, :ServerProperties , TAMQPFieldTable ( Dict {String,Any} () )))
939
938
if " capabilities" in keys (server_props)
940
- for f in server_props[" capabilities" ]. fld. data
941
- conn. capabilities[convert (String, f. name)] = f. val. fld
942
- end
939
+ merge! (conn. capabilities, server_props[" capabilities" ])
943
940
end
944
941
945
942
handle (chan, :Connection , :Start )
@@ -957,31 +954,31 @@ function send_connection_start_ok(chan::MessageChannel, auth_params::Dict{String
957
954
client_props = copy (CLIENT_IDENTIFICATION)
958
955
client_cap = client_props[" capabilities" ]
959
956
server_cap = conn. capabilities
960
- @debug (" server capabilities: $ server_cap" )
957
+ @debug (" server capabilities" , server_cap)
961
958
if " consumer_cancel_notify" in keys (server_cap)
962
959
client_cap[" consumer_cancel_notify" ] = server_cap[" consumer_cancel_notify" ]
963
960
end
964
961
if " connection.blocked" in keys (server_cap)
965
962
client_cap[" connection.blocked" ] = server_cap[" connection.blocked" ]
966
963
end
967
- @debug (" client_props: $( client_props) " )
964
+ @debug (" client_props" , client_props)
968
965
969
966
# assert that auth mechanism is supported
970
967
mechanism = auth_params[" MECHANISM" ]
971
968
mechanisms = split (get_property (chan, :Mechanisms , " " ), ' ' )
972
- @debug (" mechanism: $ mechanism , supported mechanisms: $(mechanisms) " )
969
+ @debug (" checking auth mechanism" , mechanism, supported= mechanisms)
973
970
@assert mechanism in mechanisms
974
971
975
972
# set up locale
976
973
# pick up one of the server locales
977
974
locales = split (get_property (chan, :Locales , " " ), ' ' )
978
- @debug (" supported locales: $( locales) " )
975
+ @debug (" supported locales" , locales)
979
976
client_locale = locales[1 ]
980
- @debug (" client_locale: $( client_locale) " )
977
+ @debug (" client_locale" , client_locale)
981
978
982
979
# respond to login
983
980
auth_resp = AUTH_PROVIDERS[mechanism](auth_params)
984
- @debug (" auth_resp: $( auth_resp) " )
981
+ @debug (" auth_resp" , auth_resp)
985
982
986
983
send (chan, TAMQPMethodPayload (:Connection , :StartOk , (client_props, mechanism, auth_resp, client_locale)))
987
984
nothing
@@ -1017,7 +1014,7 @@ function send_connection_tune_ok(chan::MessageChannel, channelmax=0, framemax=0,
1017
1014
conn. heartbeat = max (conn. heartbeat, heartbeat)
1018
1015
end
1019
1016
1020
- @debug (" channelmax: $( conn. channelmax) , framemax: $( conn. framemax) , heartbeat: $( conn. heartbeat) " )
1017
+ @debug (" send_connection_tune_ok " , channelmax = conn. channelmax, framemax= conn. framemax, heartbeat= conn. heartbeat)
1021
1018
send (chan, TAMQPMethodPayload (:Connection , :TuneOk , (conn. channelmax, conn. framemax, conn. heartbeat)))
1022
1019
1023
1020
# start heartbeat timer
@@ -1065,7 +1062,7 @@ end
1065
1062
function on_channel_flow (chan:: MessageChannel , m:: TAMQPMethodFrame , ctx)
1066
1063
@assert is_method (m, :Channel , ctx)
1067
1064
chan. flow = m. payload. fields[1 ]. second
1068
- @debug (" channel $( chan. id) flow is now $( chan. flow) " )
1065
+ @debug (" on_channel_flow " , channel = chan. id, flow= chan. flow)
1069
1066
nothing
1070
1067
end
1071
1068
@@ -1202,7 +1199,7 @@ function on_channel_message_in(chan::MessageChannel, m::TAMQPContentBodyFrame, c
1202
1199
elseif msg. consumer_tag in keys (chan. consumers)
1203
1200
put! (chan. consumers[msg. consumer_tag]. recvq, popfirst! (chan. partial_msgs))
1204
1201
else
1205
- @debug (" discarding message, no consumer with tag $( msg. consumer_tag) " )
1202
+ @debug (" discarding message, no consumer with tag" , tag = msg. consumer_tag)
1206
1203
end
1207
1204
end
1208
1205
0 commit comments