go-tarantool icon indicating copy to clipboard operation
go-tarantool copied to clipboard

v3: refactor `Stream` struct

Open bigbes opened this issue 1 month ago • 0 comments

Summary

In v3, we want to unexport both fields of the Stream struct to enforce encapsulation and prevent misuse. Access to the stream ID should be provided via a method instead.

Current Definition

type Stream struct {
	Id   uint64
	Conn *Connection
}

Both fields are public, which allows unsafe direct access or mutation (e.g., stream.Conn = nil).

Proposed Change

type Stream struct {
	id   uint64
	conn *Connection
}

func (s *Stream) Id() uint64 { return s.id }
// No accessor for conn — it's internal only.
  • Make both fields unexported (id, conn).
  • Add a read-only Id() method to expose the stream ID.
  • Do not expose conn—users should never need to access the underlying connection directly.

Checklist

  • [ ] Update Stream struct fields to be unexported.
  • [ ] Add Id() method.
  • [ ] Update internal code to use s.id/s.conn.
  • [ ] Verify no external code relies on direct field access (this is a v3 breaking change). (meaning add CHANGELOG.md and MIGRATION.md records)

bigbes avatar Oct 23 '25 01:10 bigbes