Skip to content

storage/apply: rename Batch.Commit to Batch.ApplyToStateMachine#39468

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/applyToSM
Aug 8, 2019
Merged

storage/apply: rename Batch.Commit to Batch.ApplyToStateMachine#39468
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/applyToSM

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Aug 8, 2019

This came out of a discussion with Dan. The method can't be moved
to StateMachine because then we'll need a type switch to handle the
different kinds of Batch implementations, but it can be renamed to
provide more symmetry with StateMachine.ApplySideEffects.

The commit also tries to clean up some of the phrasing around the
persistent state transition updates and the side-effects of these
state transition updates.

Release note: None

This came out of a discussion with Dan. The method can't be moved
to StateMachine because then we'll need a type switch to handle the
different kinds of Batch implementations, but it can be renamed to
provide more symmetry with StateMachine.ApplySideEffects.

The commit also tries to clean up some of the phrasing around the
persistent state transition updates and the side-effects of these
state transition updates.

Release note: None
@nvb nvb requested a review from danhhz August 8, 2019 19:19
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@danhhz
Copy link
Copy Markdown
Contributor

danhhz commented Aug 8, 2019

can you elaborate on the type switch? it is similar to the one at the beginning of (*replicaStateMachine).ApplySideEffects or something else?

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Aug 8, 2019

No, this would be a type switch on the type of the Batch passed to the method. A big part of why Batch is an interface is because we're going to introduce an ephemeral batch implementation in the next PR (this was part of #39254 until the very end, but it was pulled before merging because it actually belongs in #38954). This ephemeral batch will return an error from ApplyToStateMachine because it's ... ephemeral.

Making ApplyBatch a method on StateMachine that has specialized behavior for different implementations of Batch instead of letting each implementation of Batch implement an ApplyToStateMachine method seems like the wrong way to go.

@danhhz
Copy link
Copy Markdown
Contributor

danhhz commented Aug 8, 2019

Gotcha, I forgot about ephemeral batches. LGTM

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Aug 8, 2019

bors r=danhhz

craig bot pushed a commit that referenced this pull request Aug 8, 2019
39468: storage/apply: rename Batch.Commit to Batch.ApplyToStateMachine r=danhhz a=nvanbenschoten

This came out of a discussion with Dan. The method can't be moved
to StateMachine because then we'll need a type switch to handle the
different kinds of Batch implementations, but it can be renamed to
provide more symmetry with StateMachine.ApplySideEffects.

The commit also tries to clean up some of the phrasing around the
persistent state transition updates and the side-effects of these
state transition updates.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 8, 2019

Build succeeded

@craig craig bot merged commit 57fee7b into cockroachdb:master Aug 8, 2019
@nvb nvb deleted the nvanbenschoten/applyToSM branch August 9, 2019 03:05
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