package engine import ( "fmt" "github.com/imkira/go-observer" "sirlab.de/go/knyt/handler" "time" ) type Engine struct { obs observer.Property } func NewEngine() *Engine { engine := Engine{ obs: observer.NewProperty(handler.Value{}), } return &engine } func (engine *Engine) Run() { for { value := engine.obs.Value().(handler.Value) fmt.Printf("sleep: %d\n", value.VersionRef) time.Sleep(1 * time.Second) value.VersionRef++ engine.obs.Update(value) } } func (engine *Engine) GetHttpHandler() handler.HandlerFunc { return handler.SyncFactory(engine.obs) }