updatepoller

package
v0.0.0-...-889dc0d Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package updatepoller provides a long-polling mechanism for receiving updates from the Telegram Bot API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OffsetStore

type OffsetStore interface {
	// Load loads the offset from the store.
	Load(ctx context.Context) (int, error)
	// Save saves the offset to the store.
	Save(ctx context.Context, offset int) error
}

OffsetStore is an interface for storing and loading the update offset.

type OptOptionsSetter

type OptOptionsSetter func(o *Options)

func WithLogger

func WithLogger(opt logger.Logger) OptOptionsSetter

logger is the logger to use.

func WithOffsetStore

func WithOffsetStore(opt OffsetStore) OptOptionsSetter

offsetStore is the store to use for storing the update offset.

func WithPollingInterval

func WithPollingInterval(opt time.Duration) OptOptionsSetter

pollingInterval is the interval between polling requests.

type Options

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

Options is the options for the Poller.

func NewOptions

func NewOptions(
	client client.ClientWithResponsesInterface,
	options ...OptOptionsSetter,
) Options

func (*Options) Validate

func (o *Options) Validate() error

type Poller

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

Poller polls the Telegram API for updates.

func NewPoller

func NewPoller(opts Options) (*Poller, error)

NewPoller creates a new Poller instance with the given options.

func (*Poller) Start

func (p *Poller) Start(_ context.Context) error

Start starts the Poller. The context is used only for the startup timeout.

func (*Poller) Stop

func (p *Poller) Stop(ctx context.Context) error

Stop stops the Poller. The context is used only for the shutdown timeout.

func (*Poller) UpdateChan

func (p *Poller) UpdateChan() <-chan client.Update

UpdateChan returns the updates channel.

Directories

Path Synopsis
Package offsetstore provides implementations for storing the update offset.
Package offsetstore provides implementations for storing the update offset.

Jump to

Keyboard shortcuts

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