github.com/christoph-karpowicz/db_mediator@v0.0.0-20210207102849-61a28a1071d8/internal/server/synch/iteration.go (about) 1 package synch 2 3 import ( 4 "fmt" 5 "strconv" 6 "time" 7 ) 8 9 type iteration struct { 10 id string 11 synch *Synch 12 operations []operation 13 } 14 15 func newIteration(synch *Synch) *iteration { 16 return &iteration{ 17 id: getNewIterationID(synch), 18 synch: synch, 19 } 20 } 21 22 func getNewIterationID(synch *Synch) string { 23 return synch.cfg.Name + "-" + strconv.FormatInt(time.Now().UnixNano(), 10) 24 } 25 26 func (i *iteration) addOperation(op operation) { 27 i.operations = append(i.operations, op) 28 if !i.synch.IsSimulation() { 29 fmt.Println(op.toJSON()) 30 } 31 } 32 33 func (i *iteration) flush() { 34 i.synch.result.Operations = append(i.synch.result.Operations, i.operations...) 35 }