Skip to content

Commit

Permalink
Entry point improvements (#1227)
Browse files Browse the repository at this point in the history
* Removed ApolloRouterBuilder in favor of buildstructor.

* Entry point improvements

`ApolloRouterBuilder` has been migrated to `buildstructor` for consistency with other code.
Calls to `ApolloRouterBuilder::default()` should be migrated to `ApolloRouter::builder`.
`FederatedServerHandle` has been renamed to `ApolloRouterHandle`.

Removed functionality:
* The ability to supply your own `RouterServiceFactory`. This may be added back if there is a concrete use case for it.
* `StateListener`. This made the internal state machine unnecessarily complex. `ready()` remains on `ApolloRouterHandle`.
* `ApolloRouterHandle#shutdown()` has been removed. Instead dropping `ApolloRouterHandle` will cause the router to shutdown.

Co-authored-by: bryn <bryn@apollographql.com>
  • Loading branch information
BrynCooke and bryn authored Jun 14, 2022
1 parent 5864087 commit ebe7a70
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 332 deletions.
13 changes: 13 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ This is a breaking change since slightly invalid input might have validated befo

By [@o0Ignition0o](https://github.com/o0Ignition0o) in https://github.com/apollographql/router/pull/1211

### Entry point improvements ([PR #1227](https://github.com/apollographql/router/pull/1227))
`ApolloRouterBuilder` has been migrated to `buildstructor` for consistency with other code.
Calls to `ApolloRouterBuilder::default()` should be migrated to `ApolloRouter::builder`.
`FederatedServerHandle` has been renamed to `ApolloRouterHandle`.

Migration tips:
* The ability to supply your own `RouterServiceFactory` has been removed.
* `StateListener`. This made the internal state machine unnecessarily complex. `listen_address()` remains on `ApolloRouterHandle`.
* `FederatedServerHandle#shutdown()` has been removed. Instead, dropping `ApolloRouterHandle` will cause the router to shutdown.
* `FederatedServerHandle#ready()` has been renamed to `FederatedServerHandle#listen_address()`, it will return the address when the router is ready to serve requests.

By [@bryncooke](https://github.com/bryncooke) in https://github.com/apollographql/router/pull/1227

## 🚀 Features
### Add trace logs for parsing recursion consumption ([PR #1222](https://github.com/apollographql/router/pull/1222))
Apollo Parser now includes recursion limits which can be examined after parse execution. The router logs these
Expand Down
8 changes: 3 additions & 5 deletions apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::configuration::generate_config_schema;
use crate::{
configuration::Configuration,
subscriber::{set_global_subscriber, RouterSubscriber},
ApolloRouterBuilder, ConfigurationKind, SchemaKind, ShutdownKind,
ApolloRouter, ConfigurationKind, SchemaKind, ShutdownKind,
};
use anyhow::{anyhow, Context, Result};
use clap::{AppSettings, CommandFactory, Parser};
Expand Down Expand Up @@ -265,15 +265,13 @@ pub async fn rt_main() -> Result<()> {
}
};

let server = ApolloRouterBuilder::default()
let router = ApolloRouter::builder()
.configuration(configuration)
.schema(schema)
.shutdown(ShutdownKind::CtrlC)
.build();
let mut server_handle = server.serve();
server_handle.with_default_state_receiver().await;

if let Err(err) = server_handle.await {
if let Err(err) = router.serve().await {
tracing::error!("{}", err);
return Err(err.into());
}
Expand Down
Loading

0 comments on commit ebe7a70

Please sign in to comment.