-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router v2 #326
Router v2 #326
Conversation
Completed:
|
The following needs to end up in documentation somewhere.We will delay running SFM invalidated queries until all items in the batch are complete. For The response body needs to key items something like: pub enum Key {
Response(u32), // Reference to the request
SFM(String, serde_json::Value), // SFM key (procedure name and input)
}
type ResponseBody = HashMap<Key, Value>; This way we will never have problems with running a SFM query that was also including in the request batch. |
Goal:
Introduce the new router, make it supporting by integrations (rspc_axum
/rspc_tauri
) and allow converting a legacy router into it.General design:
TMeta
generic in favor of improved solution in upcoming middleware system. This has always been a half-baked feature.Using the newlol goodbyespecta::Language
trait for exporting, opening up the door for easily supporting other langauges.specta::Language
you won't be missed.Router::config
. You must export types via the new router with the new bindings format.Bindings
toBindingsLegacy
to use the existing clients.rspc_axum::endpoint
now takesrspc::Router2
(you need it for the types anyway)tracing
feature with no directly replacement.rspc_tauri::plugin
torspc_plugin_rspc::init
(rspc-tauri
totauri-plugin-rspc
(remember to yank old crate), andplugin
toinit
)Breaking changes:
let (routes, types) = Router2::from(legacy_router).build().unwrap();
(must be used for the runtime and the types)Router::config
has been removed. You can usetypes.export_to
.rspc_axum::endpoint(routes)
. Now takesroutes
instead ofrspc::Router
.jsonrpc
executor API with no real replacement for nowProcedures
toProceduresLegacy
in your TS code.location
field toProcedure
legacy
feature to get the old bindings format.For my future reference:
The HTTP interface has been refactored to run on
rspc_core::Procedure
which is designed around the queries path not being namespaced by the type this means keeping full backwards compatibility is really hard. Given we are going to change the bindings format withRouter2
and upgrade the clients to the new stuff first we may as well just do this as a breaking change. The old system beingBox<dyn Layer>
andArc<Router>
makes it tough to do conversions too.Unsorted:
Procedure
'sArc
ing.Procedure2::error
beingOption<DataType>
or not?Serialize
on error. Similar to the regularOk
type.Remaining questions:
rspc_devtools
- Should we provide a way to set CORS header. If we leave it on the user the URL being the same is a problem.Content-Type's within procedures for non-Serde stuff maybe - trpc/trpc#3468
- Allows types to match properly
Defining middleware which don't depend on
rspc
crate.This PR will be merged but work will continue as #328, #332 and specta-rs/website#9.