mirror of https://github.com/mastodon/flodgatt
Unix sockets WIP (#77)
* Initial WIP Unix socket implementation * Bump version to v0.4.5 * Update type data
This commit is contained in:
parent
b216a81e26
commit
67c59401fd
|
@ -404,7 +404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flodgatt"
|
name = "flodgatt"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"dotenv 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "flodgatt"
|
name = "flodgatt"
|
||||||
description = "A blazingly fast drop-in replacement for the Mastodon streaming api server"
|
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>"]
|
authors = ["Daniel Long Sockwell <daniel@codesections.com", "Julian Laubstein <contact@julianlaubstein.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ use crate::from_env_var;
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
net::{IpAddr, Ipv4Addr},
|
net::{IpAddr, Ipv4Addr},
|
||||||
os::unix::net::UnixListener,
|
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
@ -35,12 +34,9 @@ from_env_var!(
|
||||||
from_env_var!(
|
from_env_var!(
|
||||||
/// A Unix Socket to use in place of a local address
|
/// A Unix Socket to use in place of a local address
|
||||||
let name = Socket;
|
let name = Socket;
|
||||||
let default: Option<UnixListener> = None;
|
let default: Option<String> = None;
|
||||||
let (env_var, allowed_values) = ("SOCKET", "a valid Unix Socket".to_string());
|
let (env_var, allowed_values) = ("SOCKET", "any string".to_string());
|
||||||
let from_str = |s| match UnixListener::bind(s).ok() {
|
let from_str = |s| Some(Some(s.to_string()));
|
||||||
Some(socket) => Some(Some(socket)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
);
|
);
|
||||||
from_env_var!(
|
from_env_var!(
|
||||||
/// The time between replies sent via WebSocket
|
/// The time between replies sent via WebSocket
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
use flodgatt::{
|
use flodgatt::{
|
||||||
config, dbg_and_die, err,
|
config, err,
|
||||||
parse_client_request::{sse, user, ws},
|
parse_client_request::{sse, user, ws},
|
||||||
redis_to_client_stream::{self, ClientAgent},
|
redis_to_client_stream::{self, ClientAgent},
|
||||||
};
|
};
|
||||||
|
@ -89,8 +89,12 @@ fn main() {
|
||||||
|
|
||||||
let health = warp::path!("api" / "v1" / "streaming" / "health").map(|| "OK");
|
let health = warp::path!("api" / "v1" / "streaming" / "health").map(|| "OK");
|
||||||
|
|
||||||
if let Some(_socket) = cfg.unix_socket.0.as_ref() {
|
if let Some(socket) = &*cfg.unix_socket {
|
||||||
dbg_and_die!("Unix socket support not yet implemented");
|
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 {
|
} else {
|
||||||
warp::serve(health.or(websocket_routes.or(sse_routes).with(cors))).run(server_addr);
|
warp::serve(health.or(websocket_routes.or(sse_routes).with(cors))).run(server_addr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue