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

Make source tcp listener address configurable #260

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All other sections are for end-users.

- (Breaking Change) Remove `TimedStream` from foreign-service ([#250](https://github.com/SpringQL/SpringQL/pull/250)

### Fixed
- Make TCP server source address configurable, set it to "0.0.0.0" per default ([#260](https://github.com/SpringQL/SpringQL/pull/260))

## [v0.18.1] - 2022-10-07

### For developers
Expand Down
2 changes: 1 addition & 1 deletion springql-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "springql-core"
version = "0.18.1"
version = "0.18.2"

authors = ["Sho Nakatani <lay.sakura@gmail.com>"]
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 3 additions & 1 deletion springql-core/src/api/spring_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ timeout_msec = 3_000
[source_reader]
net_connect_timeout_msec = 1_000
net_read_timeout_msec = 100
net_address = "0.0.0.0"

can_read_timeout_msec = 100

Expand Down Expand Up @@ -175,10 +176,11 @@ pub struct SpringWebConsoleConfig {

/// Config related to source reader
#[allow(missing_docs)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Deserialize)]
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
pub struct SpringSourceReaderConfig {
pub net_connect_timeout_msec: u32,
pub net_read_timeout_msec: u32,
pub net_address: String,
AntonOellerer marked this conversation as resolved.
Show resolved Hide resolved

pub can_read_timeout_msec: u32,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Repositories {
Self {
row_queue_repository: RowQueueRepository::default(),
window_queue_repository: WindowQueueRepository::default(),
source_reader_repository: SourceReaderRepository::new(config.source_reader),
source_reader_repository: SourceReaderRepository::new(config.source_reader.clone()),
sink_writer_repository: SinkWriterRepository::new(config.sink_writer),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl SourceReader for NetServerSourceReader {
"unsupported protocol"
);

let listener = TcpListener::bind(("127.0.0.1", options.port)).unwrap();
let listener = TcpListener::bind((config.net_address.clone(), options.port)).unwrap();
let my_addr = listener.local_addr().unwrap();

let (tx, rx) = mpsc::channel();
Expand Down Expand Up @@ -96,7 +96,10 @@ impl NetServerSourceReader {
fn stream_handler(stream: TcpStream, tx: mpsc::Sender<serde_json::Value>) {
log::info!(
"[NetServerSourceReader] Connection from {}",
stream.peer_addr().unwrap()
stream
.peer_addr()
.map(|peer_addr| peer_addr.to_string())
.unwrap_or("unknown".to_string())
);

let mut tcp_reader = BufReader::new(stream);
Expand Down Expand Up @@ -128,7 +131,6 @@ impl NetServerSourceReader {

#[cfg(test)]
mod tests {
use super::*;
use crate::{
api::SpringSinkWriterConfig,
pipeline::OptionsBuilder,
Expand All @@ -137,6 +139,9 @@ mod tests {
SchemalessRow,
},
};

use super::*;

fn ephemeral_port() -> u16 {
let addr = TcpListener::bind("127.0.0.1:0").unwrap();
addr.local_addr().unwrap().port()
Expand Down