Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:SeldonIO Seldon core Hodometer Punctuate

From Leeroopedia
Knowledge Sources
Domains Scheduling, Observability, Usage_Telemetry
Last Updated 2026-02-13 14:00 GMT

Overview

Concrete tool for executing a periodic action at a configured interval provided by the Hodometer package.

Description

The Punctuator struct implements a simple infinite-loop timer that executes a provided callback function at regular intervals. It logs the execution timestamp and the next scheduled run time. It is used by Hodometer to periodically invoke the collect-and-publish cycle for usage metrics.

The Run method blocks indefinitely, executing the action immediately on first invocation and then sleeping for the configured duration between subsequent executions.

Usage

Use this when scheduling repeated execution of a function at fixed intervals. In the Hodometer context, it drives the periodic collection and publishing of usage metrics.

Code Reference

Source Location

Signature

type Punctuator struct {
    logger   logrus.FieldLogger
    interval time.Duration
}

func NewPunctuator(
    l logrus.FieldLogger,
    i time.Duration,
) *Punctuator

func (p *Punctuator) Run(description string, action func())

Import

import "github.com/seldonio/seldon-core/hodometer/pkg/hodometer"

I/O Contract

Inputs

Name Type Required Description
l logrus.FieldLogger Yes Structured logger
i time.Duration Yes Interval between action executions
description string Yes Human-readable description logged before each execution
action func() Yes Callback function to execute on each cycle

Outputs

Name Type Description
(blocking) Run blocks indefinitely; no return value

Usage Examples

Periodic Metrics Collection

package main

import (
    "time"
    "github.com/sirupsen/logrus"
    "github.com/seldonio/seldon-core/hodometer/pkg/hodometer"
)

func main() {
    logger := logrus.New()

    punctuator := hodometer.NewPunctuator(logger, 5*time.Minute)

    // This blocks forever, running the action every 5 minutes
    punctuator.Run("collecting usage metrics", func() {
        // collector.Collect(ctx, level)
        // publisher.Publish(ctx, metrics)
        logger.Info("metrics collected and published")
    })
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment