Skip to content

replace ctor with linkme#2181

Merged
garypen merged 14 commits intodevfrom
garypen/ctor-to-linkme
Dec 6, 2022
Merged

replace ctor with linkme#2181
garypen merged 14 commits intodevfrom
garypen/ctor-to-linkme

Conversation

@garypen
Copy link
Contributor

@garypen garypen commented Nov 30, 2022

ctor is completely replaced with linkme.

pros:

  • no code executes before main.
  • simplified plugin registration/management

cons:

  • all crates must include linkme 0.3.6
  • increased public footprint by exposing PLUGINS, linkme etc...

This gives us a more stable foundation for plugin loading/registration and we could (in future, not this PR) add mechanisms to exclude plugins or re-order them or ... The main benefit is in reducing the risk of UB creeping in to the codebase in future via plugin registration.

I believe the change is fundamentally a compatible change. , but it may require plugins generated using scaffold to be modified (to include the linkme crate) so that they continue to compile

Gary Pennington added 9 commits November 29, 2022 10:54
Fully functional migrate from ctor to linkme.

Current status:
 - all tests and examples passing/working on OS X
 - new flexibility introduced for processing plugins (including
   modifying plugin selection, ordering of plugins, etc..)
 - no risk of UB due to ctor mis-use

One drawback: all plugin crates (including scaffold) must include the
linkme crate. This wasn't a requirement with ctor.
lint found issues that it couldn't find with the ctor approach. Fix
them.
Windows test failed but other platforms passed, which is odd. I feel
like they should all fail or pass. Anyway, try to trigger the load of
plugins from the test_harness and see if that changes behaviour.

Also, fix the warning about unused stuff in the axum_factory tests.
Still failing on windows. Revert the change to test_harness and cfg out
the test on windows for now...
We don't really need a HashMap. There are very few plugins and most of
the time we are just iterating over them repeatedly. This change exposes
an iterator for plugins.

Also: update linkme to 0.3.6 to see if Windows is fixed.
commented out bits mainly...
Using a profile for testing which shouldn't be in the PR.
@garypen garypen self-assigned this Nov 30, 2022
@github-actions

This comment has been minimized.

Gary Pennington added 2 commits December 5, 2022 08:29
Since the feature is undocumented, I'm a bit nervous, but let's do it
because the worst that can happen is that we need to make the change in
the future.
Copy link
Contributor

@SimonSapin SimonSapin left a comment

Choose a reason for hiding this comment

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

(Note that ctor is still in the dependency graph, through proteus / typetag / inventory)

@garypen garypen enabled auto-merge (squash) December 6, 2022 12:57
@garypen garypen merged commit fdb57cc into dev Dec 6, 2022
@garypen garypen deleted the garypen/ctor-to-linkme branch December 6, 2022 13:16
@BrynCooke BrynCooke added this to the v1.6.0 milestone Dec 13, 2022
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.

4 participants