eduvpn / eduvpn-common

Code to be shared between eduVPN clients
MIT License
5 stars 3 forks source link

FSM implementation accross packages #2

Closed peske closed 1 year ago

peske commented 1 year ago

As far as I can see, FSM is implemented in https://github.com/eduvpn/eduvpn-common/blob/main/internal/fsm/fsm.go, but for some reason constructor function and some FSM related errors are implemented in https://github.com/eduvpn/eduvpn-common/blob/main/client/fsm.go . Such distributed implementation kinda breaks the core idea of packages. Is there any reason for that?

jwijenbergh commented 1 year ago

The internal FSM package makes a general state machine implementation, whereas the client/fsm.go file uses this package to create a state machine that is specific for the client. I had it in one file before but I want e.g. the states to be public. The constructor newFSM simply forwards the client specific states and transitions to the internal package. It's the same with the 'server.go' file inside of the client that uses the internal server.

I do agree it seems to be a bit messy

jwijenbergh commented 1 year ago

i feel like I have explained why that is and it makes sense to me