Skip to content

sqlinstance: get rid of sqlinstance.Provider #90777

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
andreimatei:sqlliveness.refactor-sqlinstance
Oct 27, 2022
Merged

sqlinstance: get rid of sqlinstance.Provider #90777
craig[bot] merged 2 commits intocockroachdb:masterfrom
andreimatei:sqlliveness.refactor-sqlinstance

Conversation

@andreimatei
Copy link
Copy Markdown
Contributor

@andreimatei andreimatei commented Oct 27, 2022

This interface, together with its implementation, were the worst. It
combined an AddressResolver with allocating an instance ID, which are
two things have very little to do with one another. The implementation
also did a 3rd thing - it was remembering the allocated instance ID,
seemingly giving this object state, although nobody was benefiting from
that. The implementation was also hiding clues about how the instance ID
was being created, namely with the help of a session (i.e. a
sqlliveness.Instance). This connection between the sqlliveness package
and the sqlinstance package was quite hidden (for example it was not
apparent in this Provider interface), and it deserves to be more
visible.

This patch gets rid of both the interface and the implementation, in
favor of breaking down the two main parts. The SQLServer now has a
instancestorage.Reader and a instancestorage.Storage; these are concrete
types, so there's no more interface hell. These fields are nil for
single-tenant instead of dummy interface implementations and that seems
to be fine, so the need for dummy interfaces was reduced.

Release note: None
Epic: None

This interface, together with its implementation, were the worst. It
combined an AddressResolver with allocating an instance ID, which are
two things have very little to do with one another. The implementation
also did a 3rd thing - it was remembering the allocated instance ID,
seemingly giving this object state, although nobody was benefiting from
that. The implementation was also hiding clues about how the instance ID
was being created, namely with the help of a session (i.e. a
sqlliveness.Instance). This connection between the sqlliveness package
and the sqlinstance package was quite hidden (for example it was not
apparent in this Provider interface), and it deserves to be more
visible.

This patch gets rid of both the interface and the implementation, in
favor of breaking down the two main parts. The SQLServer now has a
instancestorage.Reader and a instancestorage.Storage; these are concrete
types, so there's no more interface hell. These fields are nil for
single-tenant instead of dummy interface implementations and that seems
to be fine, so the need for dummy interfaces was reduced.

Release note: None
@andreimatei andreimatei requested review from a team and ajwerner October 27, 2022 15:49
@andreimatei andreimatei requested review from a team as code owners October 27, 2022 15:49
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1, 14 of 14 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aadityasondhi)

@andreimatei
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 27, 2022

Build succeeded:

@craig craig bot merged commit acb266e into cockroachdb:master Oct 27, 2022
@andreimatei andreimatei deleted the sqlliveness.refactor-sqlinstance branch October 27, 2022 21:44
@ajwerner ajwerner changed the title sqlliveness: get rid of sqlinstance.Provider sqlinstance: get rid of sqlinstance.Provider Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants