func (p *pgSerDe) FlushDataSource(ds *rrd.DataSource) error { for _, rra := range ds.RRAs() { if rra.PointCount() > 0 { if err := p.flushRoundRobinArchive(rra); err != nil { log.Printf("FlushDataSource(): error flushing RRA, probable data loss: %v", err) return err } } } if debug { log.Printf("FlushDataSource(): Id %d: LastUpdate: %v, LastDs: %v, Value: %v, Duration: %v", ds.Id(), ds.LastUpdate(), ds.LastDs(), ds.Value(), ds.Duration()) } durationMs := ds.Duration().Nanoseconds() / 1000000 if rows, err := p.sql7.Query(ds.LastUpdate(), ds.LastDs(), ds.Value(), durationMs, ds.Id()); err != nil { log.Printf("FlushDataSource(): database error: %v flushing data source %#v", err, ds) return err } else { rows.Close() } return nil }