Let's say I have the following
type Stater interface{
name() string
doTransition()
driver.Valuer
}
type Session struct {
username string
currentState Stater
}
I'm building an FSM for each user session. So each session ( The model ) should have a column in the database storing the current state. Each state is a type that implements Stater which contains ( Name(), doTransition() and so on ) by implementing the driver.Valuer
now the current state gets serialized correctly. What I need now is that when I fetch the session from the database the Session.CurrentState
( of type Stater ) get's deserialized correctly and assigned the correct concrete type. I know about the sql.Scanner
interface but I don't know what exactly should implement it. Thank you.