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