Skip to content

Commit 680fbd4

Browse files
authored
refactor: move MatchSeq to external crate map-api (#17610)
* Add new crate databend-common-meta-app-types, defining the types used by meta-service application, that depend on meta-service but meta-service does not depend on them. move NonEmptyString to app-types crate. remove unused DATABEND_COMMIT_VERSION from meta-types crate. Extract `Node` from mod `cluster` to mod `node`. * refactor: move MatchSeq to external crate map-api
1 parent 68fb600 commit 680fbd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+205
-349
lines changed

Cargo.lock

Lines changed: 38 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ members = [
9191
"src/query/ee",
9292
"src/meta/api",
9393
"src/meta/app",
94+
"src/meta/app-types",
9495
"src/meta/binaries",
9596
"src/meta/client",
9697
"src/meta/control",
@@ -138,6 +139,7 @@ databend-common-license = { path = "src/common/license" }
138139
databend-common-management = { path = "src/query/management" }
139140
databend-common-meta-api = { path = "src/meta/api" }
140141
databend-common-meta-app = { path = "src/meta/app" }
142+
databend-common-meta-app-types = { path = "src/meta/app-types" }
141143
databend-common-meta-client = { path = "src/meta/client" }
142144
databend-common-meta-control = { path = "src/meta/control" }
143145
databend-common-meta-embedded = { path = "src/meta/embedded" }
@@ -355,7 +357,7 @@ logforth = { version = "0.14", features = [
355357
'fastrace',
356358
] }
357359
lz4 = "1.24.0"
358-
map-api = { version = "0.2.1" }
360+
map-api = { version = "0.2.3" }
359361
maplit = "1.0.2"
360362
match-template = "0.0.1"
361363
md-5 = "0.10.5"
@@ -632,7 +634,7 @@ backtrace = { git = "https://github.com/rust-lang/backtrace-rs.git", rev = "7226
632634
color-eyre = { git = "https://github.com/eyre-rs/eyre.git", rev = "e5d92c3" }
633635
deltalake = { git = "https://github.com/delta-io/delta-rs", rev = "c149502" }
634636
ethnum = { git = "https://github.com/datafuse-extras/ethnum-rs", rev = "4cb05f1" }
635-
map-api = { git = "https://github.com/databendlabs/map-api", tag = "v0.2.1" }
637+
map-api = { git = "https://github.com/databendlabs/map-api", tag = "v0.2.3" }
636638
openai_api_rust = { git = "https://github.com/datafuse-extras/openai-api", rev = "819a0ed" }
637639
openraft = { git = "https://github.com/databendlabs/openraft", tag = "v0.10.0-alpha.7" }
638640
orc-rust = { git = "https://github.com/youngsofun/orc-rust", rev = "94ab8e9" }

src/meta/api/src/background_api_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ use databend_common_meta_app::KeyWithTenant;
4242
use databend_common_meta_kvapi::kvapi;
4343
use databend_common_meta_kvapi::kvapi::DirName;
4444
use databend_common_meta_kvapi::kvapi::Key;
45+
use databend_common_meta_types::match_seq::MatchSeq::Any;
4546
use databend_common_meta_types::seq_value::SeqValue;
46-
use databend_common_meta_types::MatchSeq::Any;
4747
use databend_common_meta_types::MetaError;
4848
use databend_common_meta_types::MetaSpec;
4949
use databend_common_meta_types::Operation;

src/meta/api/src/schema_api_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SchemaApi for KV {
22422242
UnknownTableId::new(req.0.table_id, "update_multi_table_meta"),
22432243
)));
22442244
}
2245-
if req_seq.match_seq(*tb_meta_seq).is_err() {
2245+
if req_seq.match_seq(tb_meta_seq).is_err() {
22462246
mismatched_tbs.push((
22472247
req.0.table_id,
22482248
*tb_meta_seq,
@@ -2356,7 +2356,7 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SchemaApi for KV {
23562356
)));
23572357
}
23582358

2359-
if req.seq.match_seq(stream_meta_seq).is_err() {
2359+
if req.seq.match_seq(&stream_meta_seq).is_err() {
23602360
return Err(KVAppError::AppError(AppError::from(
23612361
StreamVersionMismatched::new(
23622362
req.stream_id,
@@ -2403,7 +2403,7 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SchemaApi for KV {
24032403
};
24042404

24052405
// check table version
2406-
if req.0.seq.match_seq(tb_meta_seq).is_err() {
2406+
if req.0.seq.match_seq(&tb_meta_seq).is_err() {
24072407
mismatched_tbs.push((req.0.table_id, tb_meta_seq, table_meta));
24082408
}
24092409
}
@@ -2445,7 +2445,7 @@ impl<KV: kvapi::KVApi<Error = MetaError> + ?Sized> SchemaApi for KV {
24452445
)));
24462446
};
24472447

2448-
if req_seq.match_seq(seq_meta.seq).is_err() {
2448+
if req_seq.match_seq(&seq_meta.seq).is_err() {
24492449
return Err(KVAppError::AppError(AppError::from(
24502450
TableVersionMismatched::new(
24512451
req.table_id,

src/meta/app-types/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "databend-common-meta-app-types"
3+
version = { workspace = true }
4+
authors = { workspace = true }
5+
license = { workspace = true }
6+
publish = { workspace = true }
7+
edition = { workspace = true }
8+
9+
[lib]
10+
doctest = false
11+
test = true
12+
13+
[dependencies]
14+
num-derive = { workspace = true }
15+
prost = { workspace = true }
16+
serde = { workspace = true }
17+
18+
[dev-dependencies]
19+
anyhow = { workspace = true }
20+
21+
[package.metadata.cargo-machete]
22+
ignored = ["num-derive", "prost"]
23+
24+
[lints]
25+
workspace = true

src/meta/app-types/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Defines types used by meta-service applications.
2+
In other words, these types depend on the meta-service but meta-service does not depend on them.

src/meta/types/src/seq_errors.rs renamed to src/meta/app-types/src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,4 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use serde::Deserialize;
16-
use serde::Serialize;
17-
18-
use crate::MatchSeq;
19-
20-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error)]
21-
pub enum ConflictSeq {
22-
#[error("ConflictSeq: Want: {want}, Got: {got}")]
23-
NotMatch { want: MatchSeq, got: u64 },
24-
}
15+
pub mod non_empty;
File renamed without changes.

src/meta/app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ databend-common-base = { workspace = true }
2323
databend-common-exception = { workspace = true }
2424
databend-common-expression = { workspace = true }
2525
databend-common-io = { workspace = true }
26+
databend-common-meta-app-types = { workspace = true }
2627
databend-common-meta-kvapi = { workspace = true }
2728
databend-common-meta-types = { workspace = true }
2829
derive_more = { workspace = true }

src/meta/app/src/tenant/tenant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
use std::fmt::Display;
1919

20-
use databend_common_meta_types::NonEmptyString;
20+
use databend_common_meta_app_types::non_empty::NonEmptyString;
2121

2222
use crate::app_error::TenantIsEmpty;
2323

0 commit comments

Comments
 (0)