poll

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package poll watches subscribed resources for file changes and emits update notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourcePoller

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

ResourcePoller tracks subscribed resources and polls for file changes.

func NewResourcePoller

func NewResourcePoller(
	contextDir string, notifyFn func(proto.Notification),
) *ResourcePoller

NewResourcePoller creates a poller for the given context directory.

Parameters:

  • contextDir: path to the .context/ directory
  • notifyFn: callback to emit resource change notifications

Returns:

  • *ResourcePoller: initialized poller (not yet polling)

func (*ResourcePoller) CheckChanges

func (p *ResourcePoller) CheckChanges()

CheckChanges compares current mtimes to snapshots and emits notifications. Exported for tests that need to trigger a poll cycle without waiting for the timer.

func (*ResourcePoller) SetNotifyFunc

func (p *ResourcePoller) SetNotifyFunc(fn func(proto.Notification))

SetNotifyFunc replaces the notification callback. Intended for tests that need to capture emitted notifications.

Parameters:

  • fn: replacement notification callback

func (*ResourcePoller) Stop

func (p *ResourcePoller) Stop()

Stop shuts down the poller goroutine.

func (*ResourcePoller) Subscribe

func (p *ResourcePoller) Subscribe(uri string)

Subscribe adds a URI to the watch set and starts polling if needed.

Goroutine lifecycle: the poller goroutine is started on the first subscription and stopped when the last subscription is removed or when Stop is called.

Parameters:

  • uri: resource URI to watch for changes

func (*ResourcePoller) Unsubscribe

func (p *ResourcePoller) Unsubscribe(uri string)

Unsubscribe removes a URI from the watch set and stops polling if empty.

Parameters:

  • uri: resource URI to stop watching

Jump to

Keyboard shortcuts

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