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

Remove Datum trait in mapper #27

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

BulkBeing
Copy link
Collaborator

@BulkBeing BulkBeing commented Jan 8, 2024

This PR changes the input to map function from a trait to a concrete struct type. Many of the common Rust server crates seems to use a concrete struct to represent the request eg. hyper, axum, actix_web. As of now, the read function in the source::Sourcer also accepts a struct as input.

If the current API (i.e, the MapRequest struct) needs changes in future, most likely we will be able to abstract that with generics and making the struct fields private.

I directly created the PR since the effort needed for explaining it in an issue would be almost same as implementing the code. If needed, I will revert back to using trait.

Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
pub async fn start_uds_server<T>(m: T) -> Result<(), Box<dyn std::error::Error>>
where
T: Sourcer + Send + Sync + 'static,
T: Sourcer + Clone + Send + Sync + 'static,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Allows Arc<Sourcer> to be created at user's side and reusing the same. Reduces one possible heap allocation if user also has to create an Arc<Sourcer>.

@BulkBeing BulkBeing marked this pull request as ready for review January 8, 2024 15:09
@vigith
Copy link
Member

vigith commented Jan 8, 2024

Could you please add why you want to remove that trait in the description? The reason it was added was to abstract the data type.

@vigith vigith changed the base branch from main to mapper_changes January 22, 2024 03:59
@vigith vigith merged commit 8096016 into numaproj:mapper_changes Jan 22, 2024
2 checks passed
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.

2 participants