looplab / fsm

Finite State Machine for Go
Apache License 2.0
2.86k stars 312 forks source link

Generics #86

Open majst01 opened 2 years ago

majst01 commented 2 years ago

Hi Max,

This is just a POC to see what it might look like, not so convinced if its worth the effort. Callback handling is hard to transform because it depends on string prefixes of events or states. Callback handling is now generic as well.

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.3%) to 93.366% when pulling 2925185a8877453e733e6accb3d8bfca38795811 on majst01:generics into 0b86adf5b01f0dbf1861141ea62554aaa8fc7440 on looplab:main.

maxekman commented 2 years ago

Really cool! I’ll take some time to read it soon.

majst01 commented 2 years ago

OK, now callbacks are transformed to generics as well, no more string concat and matching. This is all obviously breaking for existing users.

majst01 commented 2 years ago

As this PR is obviously much to big to review, i would have no problem maintaining a fork of it in our org (https://github.com/metal-stack) because we will most probably use the generic version of it in our main api.

But if you are willing to take it, this will of course be much appreciated and i will try hard to make this possible. So if you have time to comment, do so, i will help pushing it.

maxekman commented 2 years ago

Great work so far! I’m thinking we should maybe release it as a v2, WDYT? In that case I think it needs to go into a v2 folder..

https://go.dev/blog/v2-go-modules

majst01 commented 2 years ago

Great work so far! I’m thinking we should maybe release it as a v2, WDYT? In that case I think it needs to go into a v2 folder..

https://go.dev/blog/v2-go-modules

Yes sure, i can modify my branch to act as v2, but i am not so much a fan of a /v2 subdirectory, what about a branch ? Main points to the generic version and v1 branch is the "old" one. A sample can be seen here: https://github.com/urfave/cli Up to you

majst01 commented 2 years ago

Hi @maxekman

How should we proceed ?

maxekman commented 2 years ago

I think I prefer a branch too, but haven’t read too much about it. Let’s start with that. As long as the package name contains v2 it should be fine.

See here for update on releasing a v1: https://github.com/looplab/fsm/pull/82#issuecomment-1195337254

maxekman commented 1 year ago

I published v1.0.0 now, so all is prepared if this should target v2.

https://github.com/looplab/fsm/releases/tag/v1.0.0

majst01 commented 1 year ago

Hi @maxekman

This is great news, i am short in free time ATM, polishing it and make it ready for v2 will take a bit effort though. Will come back once time allows.

victorkt commented 9 months ago

Hi, I'd be interested in using this library with generics. Are there any plans to release these changes as v2?

majst01 commented 9 months ago

Hi, I'd be interested in using this library with generics. Are there any plans to release these changes as v2?

This was the plan, but with the very last changes to master right before, i got so many conflicts that i was not able to fix them in a couple of hours. If you want to try, would be great