go-hep.org/x/hep@v0.38.1/fwk/job/ui.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package job 6 7 import ( 8 "io" 9 10 "go-hep.org/x/hep/fwk" 11 ) 12 13 // UI wraps a fwk.Scripter and panics when an error occurs 14 type UI struct { 15 ui fwk.Scripter 16 } 17 18 // Configure configures the underlying fwk.App. 19 // Configure panics if an error occurs. 20 func (ui UI) Configure() { 21 err := ui.ui.Configure() 22 if err != nil { 23 panic(err) 24 } 25 } 26 27 // Start starts the underlying fwk.App. 28 // Start panics if an error occurs. 29 func (ui UI) Start() { 30 err := ui.ui.Start() 31 if err != nil { 32 panic(err) 33 } 34 } 35 36 // Run runs the event-loop of the underlying fwk.App. 37 // Run panics if an error different than io.EOF occurs. 38 func (ui UI) Run(evtmax int64) { 39 err := ui.ui.Run(evtmax) 40 if err != nil && err != io.EOF { 41 panic(err) 42 } 43 } 44 45 // Stop stops the underlying fwk.App. 46 // Stopt panics if an error occurs. 47 func (ui UI) Stop() { 48 err := ui.ui.Stop() 49 if err != nil { 50 panic(err) 51 } 52 } 53 54 // Shutdown shuts the underlying fwk.App down. 55 // Shutdown panics if an error occurs. 56 func (ui UI) Shutdown() { 57 err := ui.ui.Shutdown() 58 if err != nil { 59 panic(err) 60 } 61 }