Compare commits

..

No commits in common. "8a3df95491f47b1f85d5e38b5f78f31e24ccec65" and "47645a8fce7a65b7c67a349f4640f2b27a94abb0" have entirely different histories.

View File

@ -28,31 +28,23 @@ type Conn interface {
SetSizeLimit(limit int64) SetSizeLimit(limit int64)
} }
// Trans is a HOPP transaction. Methods of this interface are not safe for // Trans is a HOPP transaction.
// concurrent use with the exception of the Close and ID 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.
Close() error Close() error
// ID returns the transaction ID. This must not change, and it must be // ID returns the transaction ID. This must not change, and it must be
// unique within the connection. This method is safe for concurrent use. // unique within the connection.
ID() int64 ID() int64
// TODO: add methods for setting send and receive deadlines // TODO: add methods for setting send and receive deadlines
// Send sends a message. This method is not safe for concurrent use. // Send sends a message.
Send(method uint16, data []byte) error Send(method uint16, data []byte) error
// SendWriter sends data written to an [io.Writer]. Any writer // Receive receives a message.
// previously opened through this function will be discarded. This
// method is not safe for concurrent use, and neither is its result.
SendWriter(method uint16) (io.Writer, error)
// Receive receives a message. This method is not safe for concurrent
// use.
Receive() (method uint16, data []byte, err error) Receive() (method uint16, data []byte, err error)
// ReceiveReader receives a message as an [io.Reader]. Any reader // ReceiveReader receives a message as an [io.Reader]. Any reader
// previously opened through this function will be discarded. This // previously opened through this function will be discarded.
// method is not safe for concurrent use, and neither is its result.
ReceiveReader() (method uint16, data io.Reader, err error) ReceiveReader() (method uint16, data io.Reader, err error)
} }