Skip to content

Commit

Permalink
agent: refactor resource_configs.update_materialization_resource_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mdibaiee committed Sep 26, 2024
1 parent 410d406 commit 6def9e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
36 changes: 16 additions & 20 deletions crates/agent/src/resource_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,31 @@ pub fn update_materialization_resource_spec(
let source_capture_def = source_capture.to_normalized_def();

if source_capture_def.target_schema == SourceCaptureSchemaMode::FromSourceName {
if let Some(x_schema_name_ptr) = &resource_spec_pointers.x_schema_name {
if let Some(x_schema_name_prev) = x_schema_name_ptr.create_value(resource_spec) {
let _ = std::mem::replace(x_schema_name_prev, x_schema_name.into());
} else {
anyhow::bail!(
"cannot create location '{x_schema_name_ptr}' in resource spec '{resource_spec}'"
);
}
} else {
let Some(x_schema_name_ptr) = &resource_spec_pointers.x_schema_name else {
anyhow::bail!(
"sourceCapture.targetSchema set on a materialization which does not have x-schema-name annotation"
);
}
};
let Some(x_schema_name_prev) = x_schema_name_ptr.create_value(resource_spec) else {
anyhow::bail!(
"cannot create location '{x_schema_name_ptr}' in resource spec '{resource_spec}'"
);
};
let _ = std::mem::replace(x_schema_name_prev, x_schema_name.into());
}

if source_capture_def.delta_updates {
if let Some(x_delta_updates_ptr) = &resource_spec_pointers.x_delta_updates {
if let Some(x_delta_updates_prev) = x_delta_updates_ptr.create_value(resource_spec) {
let _ = std::mem::replace(x_delta_updates_prev, true.into());
} else {
anyhow::bail!(
"cannot create location '{x_delta_updates_ptr}' in resource spec '{resource_spec}'"
);
}
} else {
let Some(x_delta_updates_ptr) = &resource_spec_pointers.x_delta_updates else {
anyhow::bail!(
"sourceCapture.deltaUpdates set on a materialization which does not have x-delta-updates annotation"
);
}
};
let Some(x_delta_updates_prev) = x_delta_updates_ptr.create_value(resource_spec) else {
anyhow::bail!(
"cannot create location '{x_delta_updates_ptr}' in resource spec '{resource_spec}'"
);
};
let _ = std::mem::replace(x_delta_updates_prev, true.into());
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PROFILE="${PROFILE:-release}"

export CGO_LDFLAGS="-L $(pwd)/target/${CARGO_BUILD_TARGET}/${PROFILE} -L $(pwd)/target/${CARGO_BUILD_TARGET}/${PROFILE}/librocksdb-exp -lbindings -lrocksdb -lsnappy -lstdc++ -lssl -lcrypto -ldl -lm"
export CGO_LDFLAGS="-L $(pwd)/target/${CARGO_BUILD_TARGET}/${PROFILE} -L $(pwd)/target/${CARGO_BUILD_TARGET}/${PROFILE}/librocksdb-exp -lbindings -lrocksdb -lsnappy -lstdc++ -ldl -lm"
if [ "$(uname)" == "Darwin" ]; then
export CGO_CFLAGS="-I $(pwd)/target/${CARGO_BUILD_TARGET}/${PROFILE}/librocksdb-exp/include -I $(brew --prefix)/include -I $(brew --prefix)/opt/sqlite3/include"
export CC="$(brew --prefix)/opt/llvm/bin/clang"
Expand Down

0 comments on commit 6def9e5

Please sign in to comment.