func newVolume(logger lager.Logger, bcVol baggageclaim.Volume, clock clock.Clock, db VolumeFactoryDB) Volume { vol := &volume{ Volume: bcVol, db: db, heartbeating: new(sync.WaitGroup), release: make(chan time.Duration, 1), } ttl, err := vol.db.GetVolumeTTL(vol.Handle()) if err != nil { logger.Info("failed-to-lookup-ttl", lager.Data{"error": err.Error()}) ttl, _, err = bcVol.Expiration() if err != nil { logger.Error("failed-to-lookup-expiration-of-volume", err) return nil } } vol.heartbeat(logger.Session("initial-heartbeat"), ttl) vol.heartbeating.Add(1) go vol.heartbeatContinuously( logger.Session("continuos-heartbeat"), clock.NewTicker(volumeKeepalive), ttl, ) return vol }
func (vf *volumeFactory) Build(bcVol baggageclaim.Volume) (Volume, error) { bcVol.Release(0) vol := newVolume(vf.logger, bcVol, vf.clock, vf.db) return vol, nil }
func selectLowestAlphabeticalVolume(logger lager.Logger, volumes []baggageclaim.Volume) baggageclaim.Volume { var lowestVolume baggageclaim.Volume for _, v := range volumes { if lowestVolume == nil { lowestVolume = v } else if v.Handle() < lowestVolume.Handle() { lowestVolume = v } } for _, v := range volumes { if v != lowestVolume { v.Release(reapExtraVolumeTTL) } } return lowestVolume }
func (vf *volumeFactory) Build(logger lager.Logger, bcVol baggageclaim.Volume) (Volume, bool, error) { bcVol.Release(nil) return newVolume(logger, bcVol, vf.clock, vf.db) }