Skip to content

Commit 608fa34

Browse files
committed
all: Remove ws routes and related settings
1 parent d1100e8 commit 608fa34

File tree

8 files changed

+18
-53
lines changed

8 files changed

+18
-53
lines changed

docs/environment-variables.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ those.
112112
result is checked while the response is being constructed, so that
113113
execution does not take more memory than what is configured. The default
114114
value for both is unlimited.
115-
- `GRAPH_GRAPHQL_MAX_OPERATIONS_PER_CONNECTION`: maximum number of GraphQL
116-
operations per WebSocket connection. Any operation created after the limit
117-
will return an error to the client. Default: 1000.
118115
- `GRAPH_GRAPHQL_HTTP_PORT` : Port for the GraphQL HTTP server
119-
- `GRAPH_GRAPHQL_WS_PORT` : Port for the GraphQL WebSocket server
120116
- `GRAPH_SQL_STATEMENT_TIMEOUT`: the maximum number of seconds an
121117
individual SQL query is allowed to take during GraphQL
122118
execution. Default: unlimited
@@ -181,11 +177,10 @@ those.
181177
query, and the `query_id` of the GraphQL query that caused the SQL
182178
query. These SQL queries are marked with `component: GraphQlRunner` There
183179
are additional SQL queries that get logged when `sql` is given. These are
184-
queries caused by mappings when processing blocks for a subgraph, and
185-
queries caused by subscriptions. If `cache` is present in addition to
186-
`gql`, also logs information for each toplevel GraphQL query field
187-
whether that could be retrieved from cache or not. Defaults to no
188-
logging.
180+
queries caused by mappings when processing blocks for a subgraph. If
181+
`cache` is present in addition to `gql`, also logs information for each
182+
toplevel GraphQL query field whether that could be retrieved from cache
183+
or not. Defaults to no logging.
189184
- `GRAPH_LOG_TIME_FORMAT`: Custom log time format.Default value is `%b %d %H:%M:%S%.3f`. More information [here](https://docs.rs/chrono/latest/chrono/#formatting-and-parsing).
190185
- `STORE_CONNECTION_POOL_SIZE`: How many simultaneous connections to allow to the store.
191186
Due to implementation details, this value may not be strictly adhered to. Defaults to 10.

graph/src/env/graphql.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ pub struct EnvVarsGraphQl {
8686
/// Set by the environment variable `GRAPH_GRAPHQL_ERROR_RESULT_SIZE`. The
8787
/// default value is [`usize::MAX`].
8888
pub error_result_size: usize,
89-
/// Set by the flag `GRAPH_GRAPHQL_MAX_OPERATIONS_PER_CONNECTION`.
90-
/// Defaults to 1000.
91-
pub max_operations_per_connection: usize,
9289
/// Set by the flag `GRAPH_GRAPHQL_DISABLE_BOOL_FILTERS`. Off by default.
9390
/// Disables AND/OR filters
9491
pub disable_bool_filters: bool,
@@ -144,7 +141,6 @@ impl From<InnerGraphQl> for EnvVarsGraphQl {
144141
allow_deployment_change: x.allow_deployment_change.0,
145142
warn_result_size: x.warn_result_size.0 .0,
146143
error_result_size: x.error_result_size.0 .0,
147-
max_operations_per_connection: x.max_operations_per_connection,
148144
disable_bool_filters: x.disable_bool_filters.0,
149145
disable_child_sorting: x.disable_child_sorting.0,
150146
query_trace_token: x.query_trace_token,
@@ -192,8 +188,6 @@ pub struct InnerGraphQl {
192188
warn_result_size: WithDefaultUsize<NoUnderscores<usize>, { usize::MAX }>,
193189
#[envconfig(from = "GRAPH_GRAPHQL_ERROR_RESULT_SIZE", default = "")]
194190
error_result_size: WithDefaultUsize<NoUnderscores<usize>, { usize::MAX }>,
195-
#[envconfig(from = "GRAPH_GRAPHQL_MAX_OPERATIONS_PER_CONNECTION", default = "1000")]
196-
max_operations_per_connection: usize,
197191
#[envconfig(from = "GRAPH_GRAPHQL_DISABLE_BOOL_FILTERS", default = "false")]
198192
pub disable_bool_filters: EnvVarBoolean,
199193
#[envconfig(from = "GRAPH_GRAPHQL_DISABLE_CHILD_SORTING", default = "false")]

node/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ async fn main() {
141141

142142
// Obtain ports to use for the GraphQL server(s)
143143
let http_port = opt.http_port;
144-
let ws_port = opt.ws_port;
145144

146145
// Obtain JSON-RPC server port
147146
let json_rpc_port = opt.admin_port;
@@ -442,7 +441,6 @@ async fn main() {
442441
let json_rpc_server = JsonRpcServer::serve(
443442
json_rpc_port,
444443
http_port,
445-
ws_port,
446444
subgraph_registrar.clone(),
447445
node_id.clone(),
448446
logger.clone(),
@@ -504,7 +502,7 @@ async fn main() {
504502
}
505503

506504
// Serve GraphQL queries over HTTP
507-
graph::spawn(async move { graphql_server.start(http_port, ws_port).await });
505+
graph::spawn(async move { graphql_server.start(http_port).await });
508506

509507
// Run the index node server
510508
graph::spawn(async move { index_node_server.start(index_node_port).await });

node/src/opt.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,6 @@ pub struct Opt {
132132
help = "Port for the index node server"
133133
)]
134134
pub index_node_port: u16,
135-
#[clap(
136-
long,
137-
default_value = "8001",
138-
value_name = "PORT",
139-
help = "Port for the GraphQL WebSocket server",
140-
env = "GRAPH_GRAPHQL_WS_PORT"
141-
)]
142-
pub ws_port: u16,
143135
#[clap(
144136
long,
145137
default_value = "8020",

server/http/src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<Q: GraphQlRunner> GraphQLServer<Q> {
3232
}
3333
}
3434

35-
pub async fn start(&self, port: u16, ws_port: u16) -> Result<ServerHandle, anyhow::Error> {
35+
pub async fn start(&self, port: u16) -> Result<ServerHandle, anyhow::Error> {
3636
let logger = self.logger.clone();
3737

3838
info!(
@@ -42,7 +42,7 @@ impl<Q: GraphQlRunner> GraphQLServer<Q> {
4242

4343
let graphql_runner = self.graphql_runner.clone();
4444

45-
let service = Arc::new(GraphQLService::new(logger.clone(), graphql_runner, ws_port));
45+
let service = Arc::new(GraphQLService::new(logger.clone(), graphql_runner));
4646

4747
start(logger, port, move |req| {
4848
let service = service.cheap_clone();

server/http/src/service.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,22 @@ fn client_error(msg: impl Into<String>) -> ServerResponse {
4848
pub struct GraphQLService<Q> {
4949
logger: Logger,
5050
graphql_runner: Arc<Q>,
51-
ws_port: u16,
5251
}
5352

5453
impl<Q> GraphQLService<Q>
5554
where
5655
Q: GraphQlRunner,
5756
{
5857
/// Creates a new GraphQL service.
59-
pub fn new(logger: Logger, graphql_runner: Arc<Q>, ws_port: u16) -> Self {
58+
pub fn new(logger: Logger, graphql_runner: Arc<Q>) -> Self {
6059
GraphQLService {
6160
logger,
6261
graphql_runner,
63-
ws_port,
6462
}
6563
}
6664

6765
fn graphiql_html(&self) -> String {
68-
include_str!("../assets/index.html")
69-
.replace("__WS_PORT__", format!("{}", self.ws_port).as_str())
66+
include_str!("../assets/index.html").to_string()
7067
}
7168

7269
async fn index(&self) -> ServerResult {
@@ -459,7 +456,7 @@ mod tests {
459456
let logger = Logger::root(slog::Discard, o!());
460457
let graphql_runner = Arc::new(TestGraphQlRunner);
461458

462-
let service = GraphQLService::new(logger, graphql_runner, 8001);
459+
let service = GraphQLService::new(logger, graphql_runner);
463460

464461
let request: Request<Full<Bytes>> = Request::builder()
465462
.method(Method::GET)
@@ -491,7 +488,7 @@ mod tests {
491488
let subgraph_id = USERS.clone();
492489
let graphql_runner = Arc::new(TestGraphQlRunner);
493490

494-
let service = GraphQLService::new(logger, graphql_runner, 8001);
491+
let service = GraphQLService::new(logger, graphql_runner);
495492

496493
let request: Request<Full<Bytes>> = Request::builder()
497494
.method(Method::POST)
@@ -523,7 +520,7 @@ mod tests {
523520
let subgraph_id = USERS.clone();
524521
let graphql_runner = Arc::new(TestGraphQlRunner);
525522

526-
let service = GraphQLService::new(logger, graphql_runner, 8001);
523+
let service = GraphQLService::new(logger, graphql_runner);
527524

528525
let request: Request<Full<Bytes>> = Request::builder()
529526
.method(Method::POST)

server/http/tests/server.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod test {
165165
let query_runner = Arc::new(TestGraphQlRunner);
166166
let server = HyperGraphQLServer::new(&logger_factory, query_runner);
167167
let server_handle = server
168-
.start(8007, 8008)
168+
.start(8007)
169169
.await
170170
.expect("Failed to start GraphQL server");
171171
while !server_handle.accepting.load(Ordering::SeqCst) {
@@ -197,7 +197,7 @@ mod test {
197197
let query_runner = Arc::new(TestGraphQlRunner);
198198
let server = HyperGraphQLServer::new(&logger_factory, query_runner);
199199
let server_handle = server
200-
.start(8002, 8003)
200+
.start(8002)
201201
.await
202202
.expect("Failed to start GraphQL server");
203203
while !server_handle.accepting.load(Ordering::SeqCst) {
@@ -269,7 +269,7 @@ mod test {
269269
let query_runner = Arc::new(TestGraphQlRunner);
270270
let server = HyperGraphQLServer::new(&logger_factory, query_runner);
271271
let server_handle = server
272-
.start(8003, 8004)
272+
.start(8003)
273273
.await
274274
.expect("Failed to start GraphQL server");
275275
while !server_handle.accepting.load(Ordering::SeqCst) {
@@ -306,7 +306,7 @@ mod test {
306306
let query_runner = Arc::new(TestGraphQlRunner);
307307
let server = HyperGraphQLServer::new(&logger_factory, query_runner);
308308
let server_handle = server
309-
.start(8005, 8006)
309+
.start(8005)
310310
.await
311311
.expect("Failed to start GraphQL server");
312312
while !server_handle.accepting.load(Ordering::SeqCst) {

server/json-rpc/src/lib.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ impl JsonRpcServer {
2121
pub async fn serve<R>(
2222
port: u16,
2323
http_port: u16,
24-
ws_port: u16,
2524
registrar: Arc<R>,
2625
node_id: NodeId,
2726
logger: Logger,
@@ -39,7 +38,6 @@ impl JsonRpcServer {
3938
let state = ServerState {
4039
registrar,
4140
http_port,
42-
ws_port,
4341
node_id,
4442
logger,
4543
};
@@ -87,7 +85,6 @@ impl JsonRpcServer {
8785
struct ServerState<R> {
8886
registrar: Arc<R>,
8987
http_port: u16,
90-
ws_port: u16,
9188
node_id: NodeId,
9289
logger: Logger,
9390
}
@@ -123,7 +120,7 @@ impl<R: SubgraphRegistrar> ServerState<R> {
123120
info!(&self.logger, "Received subgraph_deploy request"; "params" => format!("{:?}", params));
124121

125122
let node_id = params.node_id.clone().unwrap_or(self.node_id.clone());
126-
let routes = subgraph_routes(&params.name, self.http_port, self.ws_port);
123+
let routes = subgraph_routes(&params.name, self.http_port);
127124
match self
128125
.registrar
129126
.create_subgraph_version(
@@ -243,15 +240,11 @@ fn json_rpc_error(
243240
)))
244241
}
245242

246-
fn subgraph_routes(name: &SubgraphName, http_port: u16, ws_port: u16) -> JsonValue {
243+
fn subgraph_routes(name: &SubgraphName, http_port: u16) -> JsonValue {
247244
let http_base_url = ENV_VARS
248245
.external_http_base_url
249246
.clone()
250247
.unwrap_or_else(|| format!(":{}", http_port));
251-
let ws_base_url = ENV_VARS
252-
.external_ws_base_url
253-
.clone()
254-
.unwrap_or_else(|| format!(":{}", ws_port));
255248

256249
let mut map = BTreeMap::new();
257250
map.insert(
@@ -262,10 +255,6 @@ fn subgraph_routes(name: &SubgraphName, http_port: u16, ws_port: u16) -> JsonVal
262255
"queries",
263256
format!("{}/subgraphs/name/{}", http_base_url, name),
264257
);
265-
map.insert(
266-
"subscriptions",
267-
format!("{}/subgraphs/name/{}", ws_base_url, name),
268-
);
269258

270259
serde_json::to_value(map).expect("invalid subgraph routes")
271260
}

0 commit comments

Comments
 (0)