Unix sockets WIP (#77)

* Initial WIP Unix socket implementation

* Bump version to v0.4.5

* Update type data
This commit is contained in:
Daniel Sockwell 2020-01-08 09:51:25 -05:00 committed by GitHub
parent b216a81e26
commit 67c59401fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

2
Cargo.lock generated
View File

@ -404,7 +404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "flodgatt"
version = "0.4.4"
version = "0.4.5"
dependencies = [
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dotenv 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,7 +1,7 @@
[package]
name = "flodgatt"
description = "A blazingly fast drop-in replacement for the Mastodon streaming api server"
version = "0.4.4"
version = "0.4.5"
authors = ["Daniel Long Sockwell <daniel@codesections.com", "Julian Laubstein <contact@julianlaubstein.de>"]
edition = "2018"

View File

@ -2,7 +2,6 @@ use crate::from_env_var;
use std::{
fmt,
net::{IpAddr, Ipv4Addr},
os::unix::net::UnixListener,
str::FromStr,
time::Duration,
};
@ -35,12 +34,9 @@ from_env_var!(
from_env_var!(
/// A Unix Socket to use in place of a local address
let name = Socket;
let default: Option<UnixListener> = None;
let (env_var, allowed_values) = ("SOCKET", "a valid Unix Socket".to_string());
let from_str = |s| match UnixListener::bind(s).ok() {
Some(socket) => Some(Some(socket)),
None => None,
};
let default: Option<String> = None;
let (env_var, allowed_values) = ("SOCKET", "any string".to_string());
let from_str = |s| Some(Some(s.to_string()));
);
from_env_var!(
/// The time between replies sent via WebSocket

View File

@ -1,5 +1,5 @@
use flodgatt::{
config, dbg_and_die, err,
config, err,
parse_client_request::{sse, user, ws},
redis_to_client_stream::{self, ClientAgent},
};
@ -89,8 +89,12 @@ fn main() {
let health = warp::path!("api" / "v1" / "streaming" / "health").map(|| "OK");
if let Some(_socket) = cfg.unix_socket.0.as_ref() {
dbg_and_die!("Unix socket support not yet implemented");
if let Some(socket) = &*cfg.unix_socket {
warn!("Using Unix sockets is a WIP that is currently unsupported and untested.");
std::fs::remove_file(socket).unwrap();
use tokio::net::UnixListener;
let incoming = UnixListener::bind(socket).unwrap().incoming();
warp::serve(health.or(websocket_routes.or(sse_routes).with(cors))).run_incoming(incoming);
} else {
warp::serve(health.or(websocket_routes.or(sse_routes).with(cors))).run(server_addr);
}