Commit fdb4fc9e authored by MrMan's avatar MrMan

Add host, port

parent 1a1a43c1
Pipeline #47781529 failed with stage
in 2 minutes and 7 seconds
......@@ -6,14 +6,15 @@ use self::rand::{thread_rng, Rng};
use self::rand::distributions::Alphanumeric;
use self::rand::seq::sample_iter;
use self::rs_docker::Docker;
use std::net::TcpListener;
use std::io::{Error as IOError};
use std::net::{TcpListener, Ipv4Addr};
// use std::io::{Error as IOError};
// Get available port
// https://elliotekj.com/2017/07/25/find-available-tcp-port-rust/
const TMP_PORT_RANGE_START: u16 = 8000;
const TMP_PORT_RANGE_END: u16 = 9000;
const STARTUP_EXTRA_WAIT: u64 = 100;
const POSTMGR_DOCKER_IMAGE_NAME: &'static str = "postmgr";
fn get_available_port() -> Option<u16> {
let mut rng = thread_rng();
......@@ -34,16 +35,22 @@ fn port_is_available(port: u16) -> bool {
pub struct DockerizedPostmgr {
id: String,
port: u16,
host: Ipv4Addr,
}
impl DockerizedPostmgr {
pub fn new() -> DockerizedPostmgr {
let host = Ipv4Addr::LOCALHOST;
let port = get_available_port().unwrap();
let id = thread_rng()
.sample_iter(&Alphanumeric)
.take(10)
.collect::<String>();
DockerizedPostmgr{ id }
// TODO: Create and start docker container
DockerizedPostmgr{ id, port, host }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment