Update Trans docs with new concurrency rules

This commit is contained in:
Sasha Koshka 2025-11-19 20:56:16 -05:00
parent c5073e5f20
commit 874ae2e011

View File

@ -34,8 +34,8 @@ type Conn interface {
}
// Trans is a HOPP transaction. Methods of this interface are not safe for
// concurrent use with the exception of the Close and ID methods. The
// recommended use case is one goroutine per transaction.
// concurrent use with the exception of the Write, SendWriter, Close, and ID
// methods. The recommended use case is one goroutine per transaction.
type Trans interface {
// Close closes the transaction. Any blocked operations will be
// unblocked and return errors. This method is safe for concurrent use.
@ -45,13 +45,13 @@ type Trans interface {
// unique within the connection. This method is safe for concurrent use.
ID() int64
// Send sends a message. This method is not safe for concurrent use.
// Send sends a message. This method is safe for concurrent use.
Send(method uint16, data []byte) error
// SendWriter sends data written to an [io.Writer]. The writer must be
// closed after use. Closing the writer flushes any data that hasn't
// been written yet. Any writer previously opened through this function
// will be discarded. This method is not safe for concurrent use, and
// neither is its result.
// will be discarded. This method is safe for concurrent use, but its
// result isn't.
SendWriter(method uint16) (io.WriteCloser, error)
// Receive receives a message. This method is not safe for concurrent
// use.