Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at
package netlog
import (
// SegmentMonitor periodically checks for segments
// to split or discard at a given interval.
type SegmentMonitor struct {
nl *NetLog
func (sm *SegmentMonitor) start(interval time.Duration) {
ticker := time.NewTicker(interval)
for range ticker.C {
log.Printf("trace: running segment monitor")
for name, t := range {
sm.check(name, t)
func (sm *SegmentMonitor) check(name string, t *Topic) {
defer func() {
if err := recover(); err != nil {
log.Printf("alert: segment check failed: %s", err)
if t == nil {
log.Printf("alert: nil topic detected for %q", name)
err := t.CheckSegments()
if err != nil {
log.Printf("error: check segments failed %s", err)