bg

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 3 Imported by: 21

Documentation

Overview

Package bg implements wrapper for running client in background.

Index

Constants

This section is empty.

Variables

View Source
var ErrStartupTimeout = errors.New("bg: client startup timeout")

ErrStartupTimeout is returned by Connect when the client did not become ready within the configured startup timeout. See WithStartupTimeout.

Functions

This section is empty.

Types

type Client

type Client interface {
	Run(ctx context.Context, f func(ctx context.Context) error) error
}

Client abstracts telegram client.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option for Connect.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets base context for client.

func WithStartupTimeout added in v0.22.0

func WithStartupTimeout(d time.Duration) Option

WithStartupTimeout bounds how long Connect waits for the client to become ready before giving up with ErrStartupTimeout.

The client retries connection attempts indefinitely, so without a deadline (either via this option or a cancelable context, see WithContext) Connect can block forever if the connection never becomes ready. A non-positive duration disables the timeout, which is the default.

type StopFunc

type StopFunc func() error

StopFunc closes Client and waits until Run returns.

func Connect

func Connect(client Client, options ...Option) (StopFunc, error)

Connect blocks until the client is connected and ready for requests, calling Run internally in background.

The returned StopFunc terminates the client and waits until Run returns.

Jump to

Keyboard shortcuts

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