Граф коммитов

430 Коммитов

Автор SHA1 Сообщение Дата
Joel Hendrix fff23c3c33
Prep v1.2.0 for release (#344) 2024-09-30 10:12:18 -07:00
Joel Hendrix 2c88249d50
Update CI to latest two versions of Go (#343)
Update to latest version of golangci-lint.
2024-09-30 06:35:26 -07:00
Joel Hendrix 950c9652c3
Add doc comments for buffer type and methods (#342) 2024-09-30 06:26:41 -07:00
Joel Hendrix 9540ce937a
Always encode MessageHeader.Durable field (#341)
This allows sending an explicit false.
2024-09-27 14:40:50 -07:00
Joel Hendrix d4266359e0
Add Properties methods (#340)
Exposes peer properties for the respective performatives.
2024-09-26 12:08:55 -07:00
Joel Hendrix 202ee6f0f5
Fix race in Conn.start (#337)
If the provided context is canceled/expires after connReader and
connWriter are started, the resultant *Conn will be nil causing their
goroutines to be leaked.
2024-09-24 13:58:39 -07:00
Joel Hendrix f631e69097
Add Null type for sending an AMQP null (#336)
* Add Null type for sending an AMQP null

* fix test names
2024-09-13 15:44:15 -07:00
Richard Park 58e8fd809b
Allow for errors.As() to see the underlying AMQP error (#329)
You can now do errors.As() and grab the amqp.Error{} out of Link/Session/ConnErrors.
2024-08-20 14:31:23 -07:00
Joel Hendrix 1003610b1e
Add fake.NetConnOptions (#324)
Includes ChunkSize to set a default for the fake.NetConn.
2024-03-15 06:51:15 -07:00
Joel Hendrix 8d8ce79b7b
Fake can split up response frames into chunks (#323)
* Fake can split up response frames into chunks

Added a unit test to cover the fix made in a819335.

* refine

* small tweak
2024-03-07 15:36:53 -08:00
Joel Hendrix 2dff4b36f8
Clean up some unused test variables (#321)
* Clean up some unused test variables

* change release date
2024-03-01 12:07:53 -08:00
Joel Hendrix 24969a15c6
Update CI (#322)
* Update CI

Update to latest two versions of Go.
Update tools used in CI.

* use latest azure-amqp
2024-03-01 10:55:13 -08:00
Richard Park a8193355c7
Fixing a bug where we were bottlenecking on frames that had bodies smaller than 8 bytes (#320)
* The check for the header size was preventing us from moving on if the body length was smaller than the standard frame header (8 bytes).

Moving it within the portion of the reader that deals with parsing headers.

* update changelog and some comments

---------

Co-authored-by: Richard Park <ripark@microsoft.com>
Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
2024-03-01 07:55:09 -08:00
Joel Hendrix b0717e4074
Track receiver's unsettled messages as a count (#318)
The unsettled map is currently used as a count for diagnostic purposes
only, so it's safe to convert it to a count.
2024-01-16 14:29:29 -08:00
Joel Hendrix 76124f70dc
Allow cross receiver message settlement (#316)
* Allow cross receiver message settlement

It's not prevented at present, but can cause a memory leak due to
entries never being removed from the unsettledMessages map.
When a received message isn't settled, associate its receiver with the
message. The settlement APIs will direct to the associated receiver.

* mark message as settled when RSM is mode first

set rcv to nil when message has been settled

* add some additional comments

* improve comment
2024-01-08 07:55:35 -08:00
Joel Hendrix 1c1e489960
Prep for v1.0.2 release (#308) 2023-09-05 11:39:48 -07:00
Joel Hendrix 7f43d5fcd5
Roll back sender's delivery count and link credit (#307)
* Roll back sender's delivery count and link credit

When a transfer fails to be sent due to context cancellation/timeout,
roll back the updates to delivery count and link credit.

* fix misspelling
2023-08-29 16:04:29 -07:00
Joel Hendrix 766ec611cf
Fix potential hang in Sender.Send() (#306)
* Fix potential hang in Sender.Send()

There were two observers of env.Sent, the session mux and the sender.
If the sender was the first to read from the channel, this would cause
the session mux to be blocked.
In order to support multiple observers, the channels must be treated as
semaphores which are signaled when closed.
Don't terminate a session's mux if a transfer wasn't sent due to
context cancellation/timeout (this is not terminal).

* simplify

* improve naming
2023-08-29 14:20:27 -07:00
Joel Hendrix a74ebbb50a
Add unit test to verify conn is closed when start fails (#304)
* Add unit test to verify conn is closed when start fails

* add negative test

* simplify else clause
2023-08-28 07:00:02 -07:00
Joel Hendrix 87b9199f11
Update CI with latest versions of Go (#305)
Updated golangci-lint to latest version.
2023-08-28 06:56:16 -07:00
Joel Hendrix f57a4eaf1b
Update test dependencies (#303) 2023-08-25 11:42:31 -07:00
Joel Hendrix e87e969fcd
Fix non-determinism in fake NetConn.Write (#302)
* Fix non-determinism in fake NetConn.Write

Serialize the responses to write so that they show up in their specified
order. This was responsible for some spurious test failures.
Consolidate creation of senders and receivers with test hooks.
Make sending and receiving of frames log level 0 to get the minimum
amount of logging that can be useful.

* check for context cancelled

* add unit test for Conn.getWriteTimeout and update changelog

* use delta comparison

* log error verbatim
2023-08-25 07:10:56 -07:00
Joel Hendrix 5d301ec57c
Fixed write delay implementation for fake.NetConn (#301)
NetConn.Write will now send its payload to Conn on a separate goroutine,
allowing proper simulation of a delayed response.
A fake responder now returns a fake.Response that contains the payload
and any write delay.
Added newResponse() helper for returning frames without delay.
2023-08-24 07:19:00 -07:00
Joel Hendrix e17dc337bc
Properly distinguish between input and output link handles (#293)
* Properly distinguish between input and output link handles

Per spec, peers can have different values for link handles.  When
sending a frame, its Handle is set to the output (our) handle.  When
receiving a frame, its Handle is set to the input (remote) handle.
Fixed session data structures to properly map an input handle to a link.
Renamed handle fields and supporting types to follow spec nomenclature.
Added a live test that reproduced the issue.

* set release date in changelog

* add debug logging message on link attach complete

* bump release date
2023-06-08 15:45:09 -07:00
Joel Hendrix aa7222e4a5
Prep for 1.0.0 release (#289) 2023-05-04 17:16:27 -07:00
Joel Hendrix 9a458066a7
Refine README.md (#288)
* Refine README.md

* add a few more docs
2023-05-04 17:11:31 -07:00
Joel Hendrix 5397f862f2
Update docs for Message type (#287) 2023-05-04 10:50:32 -07:00
Richard Park 8209e21973
Return a programatically distinguishable error when the message is too big to send (#284)
Return a programmatically useful error if the message or delivery tag is bigger than can be sent on the link.
2023-05-01 15:16:17 -07:00
Joel Hendrix 87ae095630
Make writes deterministic (#282)
* Make writes deterministic

Added Conn.WriteDeadline to control the write deadline when writing to
net.Conn.  The default value is 30 seconds.  This can be overridden by
APIs that take a context and the context has a deadline/timeout.
For APIs that directly send frames, wait for the frame to be written to
the underlying net.Conn before considering the write a success.

* add clarifying comments on Sent channel usage

* don't send if the deadline has exceeded

* don't allow cancellation of sending a frame

* remove TODO

* add TODO for receiver disposition ack timeout

* return transfer limit exceeded error for sender

* add another clarifying comment
2023-04-21 11:38:47 -07:00
Joel Hendrix fd64bdff17
Don't leak message settlement on context cancel/timeout (#283)
* Don't leak message settlement on context cancel/timeout

For receivers in mode second, handle clean-up of in-flight messages from
the mux instead of the disposition call.  This ensures that the link
credit is reclaimed if the disposition API is cancelled or times out
waiting for the disposition acknowledgement.

* fix semaphore release count
2023-04-19 18:09:52 -07:00
Joel Hendrix b6b3ce0fc7
Robust handling of context expiration/cancellation (#276)
* Robust handling of context expiration/cancellation

If a context expires or is cancelled during session/link creation while
waiting for the ack, add the instance to a slice for later cleanup.
Removed force-closing of sessions/links.
Exhausting available session channels will return a *ConnError and close
the Conn.
Exhausting available link handles will return a *SessionError and close
the Session.

* add some additional tests

* add logging for abandoned sessions and links

* fix off-by-one error for default max links value
2023-04-18 12:59:38 -07:00
Joel Hendrix 62a379591c
Sending frames synchronizes with mux (#279)
* Sending frames synchronizes with mux

Session mux no longer consumes frames once the end performative has been
sent.  Instead, added channel endSent that links can select on.
Added method link.txFrame for proper muxing of frames to session.
Receivers send disposition frames through the mux to properly sync with
the receiver being closed.
Senders disable the outgoing transfers channel once close has started.

* minor tweaks

* fix comment

* don't send session flow frames after end performative
2023-04-17 15:55:41 -07:00
Joel Hendrix dae49eb73f
fakes: distinguish between local and remote channels (#275)
The fakes used the same, or hard-coded, values for the local and remote
channels which prevented writing certain kinds of tests.
2023-04-06 07:11:17 -07:00
Joel Hendrix 36806c759e
Improved logging diagnostics (#272)
Include address of Conn/Session/Sender/Receiver when writing log
entries.  This helps when a process contains multiple instances.
Include the link name in the error string when a link is forcibly
closed.
Include the channel number in the error string when a session is
forcibly closed.
Add log entries when session/link is forcibly closed.
Add log entry for muxing from Session to Conn.
2023-04-05 14:26:10 -07:00
Joel Hendrix 5d9dc3a55b
Fix potential race in Conn.Close() (#274)
Bumped up context timeout in TestFuzzConnCrashers.  This is unrelated to
the race change.  Some iterations of the test starting failing with a
context.DeadlineExceeded error.
2023-04-05 10:29:13 -07:00
Joel Hendrix 3f5680733a
Honor context cancellation in Dial and NewConn (#273)
* Honor context cancellation in Dial and NewConn

Previously they only honored a deadline, now they handle both.
TLS dialer now calls DialContext().

* make linter happy

* switch to context.WithCancel just because
2023-04-03 13:32:37 -07:00
Joel Hendrix 968a4440db
Prep for v0.19.1 release (#271) 2023-03-31 07:02:12 -07:00
Joel Hendrix cd4d5106e3
Fix race on Session/Sender/Receiver Close (#270)
If Close() exits due to cancellation/timeout and the mux is still
running, subsequent calls to Close() will read from doneErr which will
race with the mux.
Record closing state while synchronizing with the mux and cache the
value so subsequent calls return the same value.
2023-03-30 15:35:32 -07:00
Joel Hendrix 48a018f8dc
Update changelog with v0.19.0 release date (#268) 2023-03-30 12:05:15 -07:00
Joel Hendrix 791a79c970
Remove method Message.LinkName (#267)
The data isn't germane to the Message and should be tracked externally
as required.
2023-03-29 15:16:21 -07:00
Joel Hendrix e892449141
Clean up tests that trigger the race detector (#266)
* Clean up tests that trigger the race detector

Added some mux test hooks and supporting test infrastructure.

* fix enabling of race detection in CI

fixed race in logging
cleaned up a few logging statements for consistency
2023-03-29 11:05:22 -07:00
Joel Hendrix 52dabed423
Remove type aliases (#265)
Replaced with their aliased types.
2023-03-24 14:16:15 -07:00
Joel Hendrix 5655287b17
Don't swallow unexpected frames (#248)
* Don't swallow unexpected frames

Terminate a session/link on receiving an unexpected frame.
The change uncovered a race introduced in #223 where it's possible to
send an *Error to a closed s.close causing a panic.

* cover a few more cases

* tweak test

* send detach performative on client-side close due to error

* include context channel when initiating shutdown

added some additional logging and added some missing : in log statements

* switch back to using close struct{} channel
2023-03-23 19:55:59 -07:00
Joel Hendrix d9666db6c5
Move per-message presettlement setting to SendOptions (#264)
It's purely a client side value and is not part of the message proper.
Send now returns an error if the setting conflicts with the Sender.
2023-03-23 19:51:51 -07:00
Joel Hendrix 90b211b163
Remove disposition batching from Receiver (#263)
The feature will be redesigned and added at a later date.
2023-03-23 16:18:53 -07:00
Joel Hendrix 68b300c2a4
Don't close Sender when peer rejects message (#262)
This is not required per spec and there is no good reason for doing so.
2023-03-23 16:14:14 -07:00
Joel Hendrix 4a014debf1
Clean up state on context timeout/cancellation (#237)
* Clean up state on context timeout/cancellation

Document the potential for connection errors.
This required refactoring the link closing code.  It now follows the
same pattern as Session.

* reword comment and ensure force-close only happens once
2023-03-21 09:43:24 -07:00
Joel Hendrix b3476ce99d
Don't swallow unrecognized link handles (#259)
* Don't swallow unrecognized link handles

Per spec section 2.8.17, the session must be terminated.

* fix potential hang in session mux

* fix race in test

* add two more missed cases

* add logging and consolidate
2023-03-17 16:01:42 -07:00
Joel Hendrix d6e714bcf7
Disable Session sending frames after end performative (#261)
* Disable Session sending frames after end performative

This is against the spec and results in the peer terminating the
connection.  Just ignore any outgoing frames.

* add debug logging when discarding frames
2023-03-17 15:49:07 -07:00
Joel Hendrix 48da0e91c3
Merge flowcontrol branch into main (#260)
* Replace messages channel with a queue (#244)

* Replace messages channel with a queue

The Receiver.messages channel placed an arbitrary restriction on the
amount of link credit that could be issued to a Receiver.  Once the
Receiver has been created, it can never be issued credit that exceeds
the size of the channel.
In addition, if the Receiver were to receive messages that exceeds the
size of the channel, due to flow control bugs or other, the writes to
the channel could block leading to hangs.
The channel has been replaced with a segmented FIFO queue.  While this
in theory could allow for unbounded growth, the reality is that the
total size can never be greater than that of the Session's incoming
window.

* use Ring from standard library

* switch to require.Same for pointer comparisons

fixed issue in last seg check and added another test

* refine and add another test

* size message queue to the incoming window

* add Holder[T] to abstract syncronized access

* Remove concept of "max credit" from Receivers (#251)

* Remove concept of "max credit" from Receivers

This exposed an implementation detail of how Receivers worked.  With the
removal of the Message channel, this is no longer required and never
really made sense anyways.
The MaxCredit and ManualCredits options have been consolidated into a
single Credit option.  This is used to set the total credit for a
Receiver in auto-flow mode, or to disable auto-flow.
Disposition batching needed some slight refactoring.  Now you can
directly specify the batch size instead of it being tied to link credit.
Received messages that are sender-settled now correctly count towards a
Receiver's credit and must be settled to reclaim it.

* fix linter

* back out double-buffering change for now

* refine threshold logic

* switch to mutex instead of channel for better perf

* add back fix to remove double buffering

* rename local var for clarity

* revert cosmetic change

* Replace incoming frame channels with queues (#253)

* Replace incoming frame channels with queues

The rx channel in Session and link has been replaced with a queue. This
ensures that parents enqueueing frames to their children is always a non
blocking operation and removes the need to "pump the mux".
Consolidated some link creation code into newLink().
Links echoing a flow frame now correctly include session info.
Reverted workaround for sending disposition frames from senders as we
can now send directly from muxHandleFrame.

* minor cleanup from review

* Remove configuration of session window (#257)

The values weren't actually honored which is ok per spec, so remove them
from the public surface area.
Cleaned up handling of sender link credit.  Since we don't use
availableCredit, it's been removed.

* Improve handling of sender-settled messages (#258)

Reclaim credit for sender-settled messages when Prefetch or Receive are
called.  This removes the need to explicitly settle the message.
2023-03-15 12:51:36 -07:00