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 constraints from default_main where possible. #96

Merged
merged 4 commits into from
Feb 13, 2024

Conversation

SamirTalwar
Copy link
Contributor

I have made a few changes here.

  1. I moved Sync + Send to the connector type constraints, because they're so basic that I can't imagine a connector working without them.
  2. I removed the constraint on connectors themselves being cloneable by manually implementing Clone on ServerState.
  3. I removed all unused constraints that I could find.

If we derive `Clone` manually for `ServerState`, we can avoid the
unnecessary constraint on connectors implementing `Clone`.
These are so basic for passing configuration and state around across
async boundaries that we should just require them in the trait itself.
C::RawConfiguration: Serialize + DeserializeOwned + JsonSchema + Sync + Send,
C::Configuration: Serialize + DeserializeOwned + Sync + Send + Clone,
C::State: Sync + Send + Clone,
C::RawConfiguration: Serialize + DeserializeOwned + JsonSchema,
Copy link
Contributor

Choose a reason for hiding this comment

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

Taking the argument of this PR a bit further, is there any sense to any impl Connector for C that doesn't satisfy the constraints of default_main?

A connector that doesn't might as well not use ndc-sdk at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, you can make your own main, in theory. I was wondering this but didn't want to push it too far.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, maybe. I'm just wondering what if anything anyone who makes their own main function actually gets from using the sdk.

At any rate this is still a fine improvement.

@SamirTalwar SamirTalwar merged commit 5124caf into main Feb 13, 2024
4 checks passed
@SamirTalwar SamirTalwar deleted the samirtalwar/remove-constraints branch February 13, 2024 23:09
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