Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: take reference instead of owned value for spring_open() to make C API more natural #57

Merged
merged 2 commits into from Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down Expand Up @@ -43,6 +49,7 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh
<!-- Versions -->
[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
2 changes: 1 addition & 1 deletion springql-core/examples/demo_pipeline.rs
Expand Up @@ -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(
"
Expand Down
2 changes: 1 addition & 1 deletion springql-core/src/api/high_level_rs.rs
Expand Up @@ -13,7 +13,7 @@ pub struct SpringPipelineHL(SpringPipeline);

impl SpringPipelineHL {
/// Creates and open an in-process stream pipeline.
pub fn new(config: SpringConfig) -> Result<Self> {
pub fn new(config: &SpringConfig) -> Result<Self> {
let low_level = spring_open(config)?;
Ok(Self(low_level))
}
Expand Down
4 changes: 2 additions & 2 deletions springql-core/src/api/low_level_rs.rs
Expand Up @@ -53,10 +53,10 @@ impl From<SinkRow> for SpringRow {
}

/// Creates and open an in-process stream pipeline.
pub fn spring_open(config: SpringConfig) -> Result<SpringPipeline> {
pub fn spring_open(config: &SpringConfig) -> Result<SpringPipeline> {
setup_logger();

let engine = EngineMutex::new(&config);
let engine = EngineMutex::new(config);
let sql_processor = SqlProcessor::default();

Ok(SpringPipeline {
Expand Down
5 changes: 3 additions & 2 deletions springql-core/tests/feat_spring_open_twice.rs
Expand Up @@ -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();
}
4 changes: 2 additions & 2 deletions springql-core/tests/test_support/mod.rs
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down