Skip to content
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

Store request #28

Merged
merged 24 commits into from
Jun 14, 2024
Merged

Store request #28

merged 24 commits into from
Jun 14, 2024

Conversation

hatchan
Copy link
Member

@hatchan hatchan commented Jun 7, 2024

This is a initial implementation of inspectors, storage, and some other major refactorings.

Creating this PR now otherwise it will grow even bigger and becomes even more difficult to manage. Some of the major shortcoming with this PR won't be resolved here, rather they will be made into tickets which will result in their own PR's.

fpx/src/api.rs Show resolved Hide resolved
fpx/src/api.rs Outdated Show resolved Hide resolved
fpx/src/api/types.rs Outdated Show resolved Hide resolved
fpx/src/api/types.rs Outdated Show resolved Hide resolved
fpx/src/api/types.rs Outdated Show resolved Hide resolved
fpx/src/api/types.rs Outdated Show resolved Hide resolved
fpx/src/commands/debug/ws.rs Outdated Show resolved Hide resolved
fpx/src/commands/dev.rs Outdated Show resolved Hide resolved
fpx/src/commands/system.rs Outdated Show resolved Hide resolved
fpx/src/data/libsql.rs Outdated Show resolved Hide resolved
fpx/src/data/libsql.rs Outdated Show resolved Hide resolved
fpx/src/data/libsql.rs Outdated Show resolved Hide resolved
fpx/src/data/libsql.rs Outdated Show resolved Hide resolved
fpx/src/data/libsql.rs Outdated Show resolved Hide resolved
@hatchan hatchan marked this pull request as ready for review June 13, 2024 12:53
@hatchan hatchan requested review from stephlow and mellowagain June 13, 2024 12:55
Copy link
Member

@mellowagain mellowagain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • lots of .unwraps in the handlers but i assume these will be fixed later
  • we should also use concrete return types in handlers instead of the impl IntoResponse
  • good job on switching over to the api.rs + api module instead of api module + mod.rs


#[tracing::instrument(skip_all)]
pub async fn inspect_request_handler(
State(ApiState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it'd be cleaner if we used State(inspector_service): State<Arc<InspectorService>> instead of desugaring the ApiState, or is that not possible here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only possible to use 1 State object. In our case that is the ApiState with all of the references to the other components.

We can do this FromRef trick from the docs: https://docs.rs/axum/latest/axum/extract/struct.State.html#substates

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it and it does work atm with Arc<T> with the FromRef<T> impl. I have not changed any of the handlers though. I do think this will do an extra clone on the inner arc, though that is probably negligible.

I think we need to flip the Arc over the type. What I mean by that is that we should have Store, that is cloneable and has a inner Arc. That way we can simply require State<Store> instead of having to require the Arc in there (as we require right now State<Arc<Store>>. This will make it a lot easier to work with the store or any other shareable object. (we can also type alias this, though that feels like a bandaid 🤔 )

This will be something that we should do in a future improvement PR.

fpx/src/api/handlers/inspect.rs Show resolved Hide resolved
fpx/src/api/types.rs Show resolved Hide resolved
fpx/src/commands/client/inspectors.rs Outdated Show resolved Hide resolved
fpx/src/commands/dev.rs Show resolved Hide resolved
fpx/src/commands/system/database.rs Show resolved Hide resolved
fpx/src/data/libsql.rs Show resolved Hide resolved
fpx/src/main.rs Outdated Show resolved Hide resolved
@hatchan
Copy link
Member Author

hatchan commented Jun 13, 2024

  • lots of .unwraps in the handlers but i assume these will be fixed later

Yes indeed. This was done to get this out the door quickly. The lack of tests is also something that I'm not proud of.

  • we should also use concrete return types in handlers instead of the impl IntoResponse

Indeed. I think we need to revisit our plans to have a ApiServerError which mirrors the ApiClientError that we have for the fiberplane client.

  • good job on switching over to the api.rs + api module instead of api module + mod.rs

Yeah I know you like that 😄 I don't like that the api.rs and its child modules are spaced far apart tbh. But I don't like naming everyhting mod.rs either. I'm fine either way, but let's go with this since you like this best

@hatchan hatchan requested a review from mellowagain June 14, 2024 08:45
@hatchan hatchan merged commit ca617a9 into main Jun 14, 2024
2 checks passed
@hatchan hatchan deleted the store_requests branch June 14, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants