updatepoller

package
v0.0.0-...-422e9ff Latest Latest
Warning

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

Go to latest
Published: May 12, 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 WithAllowedUpdates

func WithAllowedUpdates(opt []string) OptOptionsSetter

allowedUpdates restricts the Telegram update types returned by polling.

func WithBufferSize

func WithBufferSize(opt int) OptOptionsSetter

bufferSize is the capacity of the update channel.

func WithLimit

func WithLimit(opt int) OptOptionsSetter

limit is the maximum number of updates to fetch per request.

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.

func WithRequestTimeout

func WithRequestTimeout(opt time.Duration) OptOptionsSetter

requestTimeout is the per-GetUpdates transport deadline. Zero disables it.

func WithTimeout

func WithTimeout(opt time.Duration) OptOptionsSetter

timeout is the long-polling timeout sent to Telegram.

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(ctx 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