forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asim: extract history into its own package
Previously, the history struct (capturing store metrics at each tick and simulator’s current state) resided within the asim package. Another PR is introducing assertion registration which enables scheduled assertion checks to run as delayed events. Since these assertion events use simulation’s history to conduct assertion checks, the event package would have to depend on the asim package. However, the asim package would also have to depend on the event package’s event executor for event ticking, creating a circular dependency. To address this issue, this patch moves the history component out of the asim package to its own package. Note that this commit does not change any existing behavior, and the main purpose is to make future commits cleaner. See also: cockroachdb#109316 Part of: cockroachdb#106192 Release note: none
- Loading branch information
Showing
10 changed files
with
66 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "history", | ||
srcs = ["history.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/history", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/kv/kvserver/asim/metrics", | ||
"//pkg/kv/kvserver/asim/state", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package history | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/metrics" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/state" | ||
) | ||
|
||
// History contains recorded information that summarizes a simulation run. | ||
// Currently it only contains the store metrics of the run. | ||
// TODO(kvoli): Add a range log like structure to the history. | ||
type History struct { | ||
Recorded [][]metrics.StoreMetrics | ||
S state.State | ||
} | ||
|
||
// Listen implements the metrics.StoreMetricListener interface. | ||
func (h *History) Listen(ctx context.Context, sms []metrics.StoreMetrics) { | ||
h.Recorded = append(h.Recorded, sms) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters