heartbeat

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled  bool
	Interval time.Duration
	MaxIdle  time.Duration
}

Config controls heartbeat runtime behavior.

type DispatchFunc

type DispatchFunc func(ctx context.Context, channel, chatID, content, requestID string) error

DispatchFunc sends heartbeat output to a target session.

type ProbeFunc

type ProbeFunc func(ctx context.Context) (string, error)

ProbeFunc runs a heartbeat probe and returns a short summary.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service periodically probes runtime health and sends output to the most recently active session.

func NewService

func NewService(cfg Config, probe ProbeFunc, dispatch DispatchFunc, stateMgr *appstate.Manager) *Service

NewService creates a heartbeat service.

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns true when the service loop is active.

func (*Service) RunOnce

func (s *Service) RunOnce(ctx context.Context) error

RunOnce runs a single heartbeat probe and dispatches the result to the latest active session.

func (*Service) Start

func (s *Service) Start() error

Start launches the periodic heartbeat loop.

func (*Service) Stop

func (s *Service) Stop()

Stop halts the periodic heartbeat loop.

func (*Service) TrackActivity

func (s *Service) TrackActivity(channel, chatID string)

TrackActivity marks a channel/chat as the newest active session for heartbeat delivery.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL