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 TransformsFromConfig trait #278

Merged
merged 1 commit into from
Oct 21, 2021
Merged

Remove TransformsFromConfig trait #278

merged 1 commit into from
Oct 21, 2021

Conversation

rukai
Copy link
Member

@rukai rukai commented Oct 15, 2021

Understanding how config works is easier without the extra layer of indirection.

Copy link
Member

@conorbros conorbros left a comment

Choose a reason for hiding this comment

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

This refactor makes sense to me. Nice one

@benbromhead
Copy link
Member

benbromhead commented Oct 18, 2021

This makes sense... though would it be better to actually just have the config as a dyn trait object and remove the enum? I think I've looked at this before and can't remember if it makes serialization of the config struct hard?

Config is just done at startup... so no perf concerns

@rukai
Copy link
Member Author

rukai commented Oct 18, 2021

I thought you couldnt serialize trait objects.
But looking into it I found this: https://github.com/dtolnay/typetag
So ill have to investigate to see if that way is better.

@rukai rukai marked this pull request as draft October 18, 2021 04:42
@rukai
Copy link
Member Author

rukai commented Oct 20, 2021

I got a 95% solution for a config trait.
It compiles and works: rukai@9c0b560

However among various minor complications such as extra complexity + compile times the main problem comes down to a limitation in deserialization with typetag.
There is no way to express a Config struct without any fields like Loopback.
The only way to express that would be via something like : Loopback: {} or Loopback: ~
Which is really unintuitive.

So because of this lets stick with this PR and abandon using a trait.
We might have important reasons for wanting a trait in the future and we can try again then.

@rukai rukai marked this pull request as ready for review October 20, 2021 23:10
Copy link
Member

@benbromhead benbromhead left a comment

Choose a reason for hiding this comment

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

It's a bit disapointing that typetag makes the UX worse as it looked like a simple solution to "registering" config objects.

This largely looks good to me.

Can you update the docs. cargo doc throws some warnings for refs to the now non-existent config trait. The docs folder might also need updating (docs.shotover.io)

@rukai
Copy link
Member Author

rukai commented Oct 21, 2021

cargo doc changes should be good.
I didnt see anything documenting writing transform config code in the docs/ folder.

@github-actions
Copy link

1 benchmarks reported regressed performance. Please check the benchmark workflow logs for details: https://github.com/shotover/shotover-proxy/actions/runs/1366148068

@rukai rukai merged commit 6235a07 into shotover:main Oct 21, 2021
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