Skip to content

chore: simplify implementing decorators#28576

Draft
andig wants to merge 2 commits intomasterfrom
chore/decorator-implementations
Draft

chore: simplify implementing decorators#28576
andig wants to merge 2 commits intomasterfrom
chore/decorator-implementations

Conversation

@andig
Copy link
Copy Markdown
Member

@andig andig commented Mar 26, 2026

Depends on #28565

Experiment to further simplify decorating interfaces while waiting for golang/go#47487

@andig andig added infrastructure Basic functionality backlog Things to do later labels Mar 26, 2026
@andig andig marked this pull request as draft March 26, 2026 17:33
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

@andig andig changed the title Chore/decorator implementations chore: simplify decorator implementations Mar 26, 2026
@andig andig changed the title chore: simplify decorator implementations chore: simplify implementing decorators Mar 26, 2026
@andig andig force-pushed the chore/decorator-implementations branch from 8e2c45a to ecbffcb Compare March 27, 2026 08:29
@andig
Copy link
Copy Markdown
Member Author

andig commented Mar 28, 2026

@Maschga right now we're still creating one implementation wrapper per interface and instance, for example:

type decorateVehicleChargeStateImpl struct {
	chargeState func() (api.ChargeStatus, error)
}

func (impl *decorateVehicleChargeStateImpl) Status() (api.ChargeStatus, error) {
	return impl.chargeState()
}

It would be nice if we could make them unique and global instead of repeating the code. I have started an implement package, hand-crafting those but they could really be auto-generated using a variant or part of decorate. Any chance you could take a look how we could invoce a generate-implementations as part of the implement package to pre-create all "default" interfaces that we'd need. The needed ones are simply the best of for all current decorators.

We also need a single global function per interface for creating the interface from function and decorator like https://github.com/evcc-io/evcc/pull/28576/changes#diff-efd8c72d5ba5a9182a27e6f1f9827a9a8dc11703de2c51d5fdaa38d5f9fedf25R7-R9.

Would be great if you could look into this. Maybe AI could even help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backlog Things to do later infrastructure Basic functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant