summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/session.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-31 09:46:40 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-31 09:46:40 (GMT)
commit0ef8fcb03fc4f51b8bc6b1a24f2e964b6a03d50c (patch)
treed065a87002893b693e17f2fe503a6f9631564c2b /src/helsinki.at/rhimport/session.go
parent620d1b76807f6ecffda54347db7b58107d03c2a5 (diff)
improved coding style
Diffstat (limited to 'src/helsinki.at/rhimport/session.go')
-rw-r--r--src/helsinki.at/rhimport/session.go29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/helsinki.at/rhimport/session.go b/src/helsinki.at/rhimport/session.go
index 36e7938..82ab3cf 100644
--- a/src/helsinki.at/rhimport/session.go
+++ b/src/helsinki.at/rhimport/session.go
@@ -92,13 +92,13 @@ type sessionAddDoneHandlerRequest struct {
response chan<- sessionAddDoneHandlerResponse
}
-func session_progress_callback(step int, step_name string, progress float64, userdata interface{}) bool {
+func sessionProgressCallback(step int, stepName string, progress float64, userdata interface{}) bool {
out := userdata.(chan<- ProgressData)
- out <- ProgressData{step, step_name, progress}
+ out <- ProgressData{step, stepName, progress}
return true
}
-func session_import_run(ctx ImportContext, done chan<- ImportResult) {
+func sessionImportRun(ctx ImportContext, done chan<- ImportResult) {
if err := ctx.SanityCheck(); err != nil {
done <- ImportResult{http.StatusBadRequest, err.Error(), 0, 0}
return
@@ -122,10 +122,10 @@ func session_import_run(ctx ImportContext, done chan<- ImportResult) {
}
func (self *Session) run(timeout time.Duration) {
- self.ctx.ProgressCallBack = session_progress_callback
+ self.ctx.ProgressCallBack = sessionProgressCallback
self.ctx.ProgressCallBackData = (chan<- ProgressData)(self.progressIntChan)
self.ctx.Cancel = self.cancelIntChan
- go session_import_run(self.ctx, self.doneIntChan)
+ go sessionImportRun(self.ctx, self.doneIntChan)
self.state = SESSION_RUNNING
self.timer.Reset(timeout)
return
@@ -247,37 +247,40 @@ func (self *SessionChan) Cancel() {
}
func (self *SessionChan) AddProgressHandler(userdata interface{}, cb ImportProgressCB) error {
- res_ch := make(chan sessionAddProgressHandlerResponse)
+ resCh := make(chan sessionAddProgressHandlerResponse)
req := sessionAddProgressHandlerRequest{}
req.userdata = userdata
req.callback = cb
- req.response = res_ch
+ req.response = resCh
select {
case self.addProgressChan <- req:
default:
return fmt.Errorf("session is about to be closed/removed")
}
- res := <-res_ch
+ res := <-resCh
return res.err
}
func (self *SessionChan) AddDoneHandler(userdata interface{}, cb func(ImportResult, interface{}) bool) error {
- res_ch := make(chan sessionAddDoneHandlerResponse)
+ resCh := make(chan sessionAddDoneHandlerResponse)
req := sessionAddDoneHandlerRequest{}
req.userdata = userdata
req.callback = cb
- req.response = res_ch
+ req.response = resCh
select {
case self.addDoneChan <- req:
default:
return fmt.Errorf("session is about to be closed/removed")
}
- res := <-res_ch
+ res := <-resCh
return res.err
}
+// *********************************************************
+// Semi-Public Interface (only used by sessionStore)
+
func (self *Session) getInterface() *SessionChan {
ch := &SessionChan{}
ch.runChan = self.runChan
@@ -287,7 +290,7 @@ func (self *Session) getInterface() *SessionChan {
return ch
}
-func (self *Session) Cleanup() {
+func (self *Session) cleanup() {
self.quit <- true
rhdl.Printf("waiting for session to close")
<-self.done
@@ -306,7 +309,7 @@ func (self *Session) Cleanup() {
rhdl.Printf("session is now cleaned up")
}
-func NewSession(ctx *ImportContext, removeFunc func()) (session *Session) {
+func newSession(ctx *ImportContext, removeFunc func()) (session *Session) {
session = new(Session)
session.state = SESSION_NEW
session.removeFunc = removeFunc