From 4b8b12186049c8ade19c7c04585fd1b95a0d634c Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Mon, 28 Mar 2022 14:47:19 +0900 Subject: [PATCH 1/2] feat: take reference instead of owned value for spring_open() to make C API more natural --- springql-core/examples/demo_pipeline.rs | 2 +- springql-core/src/api/high_level_rs.rs | 2 +- springql-core/src/api/low_level_rs.rs | 4 ++-- springql-core/tests/feat_spring_open_twice.rs | 5 +++-- springql-core/tests/test_support/mod.rs | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/springql-core/examples/demo_pipeline.rs b/springql-core/examples/demo_pipeline.rs index 13aa80f5..42231211 100644 --- a/springql-core/examples/demo_pipeline.rs +++ b/springql-core/examples/demo_pipeline.rs @@ -78,7 +78,7 @@ fn main() { let sink_engine_wheel_speed = ForeignSink::start().unwrap(); let sink_vehicle_speed = ForeignSink::start().unwrap(); - let pipeline = SpringPipelineHL::new(SpringConfig::default()).unwrap(); + let pipeline = SpringPipelineHL::new(&SpringConfig::default()).unwrap(); pipeline .command( " diff --git a/springql-core/src/api/high_level_rs.rs b/springql-core/src/api/high_level_rs.rs index 8e1f042d..02e64ef8 100644 --- a/springql-core/src/api/high_level_rs.rs +++ b/springql-core/src/api/high_level_rs.rs @@ -13,7 +13,7 @@ pub struct SpringPipelineHL(SpringPipeline); impl SpringPipelineHL { /// Creates and open an in-process stream pipeline. - pub fn new(config: SpringConfig) -> Result { + pub fn new(config: &SpringConfig) -> Result { let low_level = spring_open(config)?; Ok(Self(low_level)) } diff --git a/springql-core/src/api/low_level_rs.rs b/springql-core/src/api/low_level_rs.rs index 359a1ac5..94ef241c 100644 --- a/springql-core/src/api/low_level_rs.rs +++ b/springql-core/src/api/low_level_rs.rs @@ -53,10 +53,10 @@ impl From for SpringRow { } /// Creates and open an in-process stream pipeline. -pub fn spring_open(config: SpringConfig) -> Result { +pub fn spring_open(config: &SpringConfig) -> Result { setup_logger(); - let engine = EngineMutex::new(&config); + let engine = EngineMutex::new(config); let sql_processor = SqlProcessor::default(); Ok(SpringPipeline { diff --git a/springql-core/tests/feat_spring_open_twice.rs b/springql-core/tests/feat_spring_open_twice.rs index a8a56c0c..e7bdabbd 100644 --- a/springql-core/tests/feat_spring_open_twice.rs +++ b/springql-core/tests/feat_spring_open_twice.rs @@ -4,6 +4,7 @@ use springql_core::low_level_rs::{spring_config_default, spring_open}; #[test] fn test_spring_open_twice() { - let _ = spring_open(spring_config_default()).unwrap(); - let _ = spring_open(spring_config_default()).unwrap(); + let config = spring_config_default(); + let _ = spring_open(&config).unwrap(); + let _ = spring_open(&config).unwrap(); } diff --git a/springql-core/tests/test_support/mod.rs b/springql-core/tests/test_support/mod.rs index df1d9211..9ca6aa6a 100644 --- a/springql-core/tests/test_support/mod.rs +++ b/springql-core/tests/test_support/mod.rs @@ -10,7 +10,7 @@ use springql_foreign_service::sink::ForeignSink; #[allow(dead_code)] pub(crate) fn apply_ddls(ddls: &[String], config: SpringConfig) -> SpringPipelineHL { - let pipeline = SpringPipelineHL::new(config).unwrap(); + let pipeline = SpringPipelineHL::new(&config).unwrap(); for ddl in ddls { pipeline.command(ddl).unwrap(); } @@ -19,7 +19,7 @@ pub(crate) fn apply_ddls(ddls: &[String], config: SpringConfig) -> SpringPipelin #[allow(dead_code)] pub(crate) fn apply_ddls_low_level(ddls: &[String], config: SpringConfig) -> SpringPipeline { - let pipeline = spring_open(config).unwrap(); + let pipeline = spring_open(&config).unwrap(); for ddl in ddls { spring_command(&pipeline, ddl).unwrap(); } From 6524edc05bb4fbf5f13c1343908884319085b07f Mon Sep 17 00:00:00 2001 From: Sho Nakatani Date: Mon, 28 Mar 2022 14:51:11 +0900 Subject: [PATCH 2/2] docs: update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e92c449..4f8d3c33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh ## [Unreleased] +## [v0.3.0] + +### Changed + +- `spring_open()` and `SpringPipelineHL::new()` are changed to take `SpringConfig`'s reference instead of owned value. + ## [v0.2.0] ### Added @@ -43,6 +49,7 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh [Unreleased]: https://github.com/SpringQL/SpringQL/compare/v0.2.0...HEAD [Released]: https://github.com/SpringQL/SpringQL/releases +[v0.3.0]: https://github.com/SpringQL/SpringQL/compare/v0.2.0...v0.3.0 [v0.2.0]: https://github.com/SpringQL/SpringQL/compare/v0.1.1...v0.2.0 [v0.1.1]: https://github.com/SpringQL/SpringQL/compare/v0.1.0...v0.1.1 [v0.1.0]: https://github.com/SpringQL/SpringQL/releases/v0.1.0