pool

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pool contains Telegram connections pool.

Index

Constants

This section is empty.

Variables

View Source
var ErrConnDead = errors.New("connection dead")

ErrConnDead means that connection is closed and can't be used anymore.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Run(ctx context.Context) error
	Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error
	Ping(ctx context.Context) error
	Ready() <-chan struct{}
}

Conn represents Telegram MTProto connection.

type DC

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

DC represents connection pool to one data center.

func NewDC

func NewDC(ctx context.Context, id int, newConn func() Conn, opts DCOptions) *DC

NewDC creates new uninitialized DC.

func (*DC) Close

func (c *DC) Close() error

Close waits while all ongoing requests will be done or until given context is done. Then, closes the DC.

func (*DC) Invoke

func (c *DC) Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error

Invoke sends MTProto request using one of pool connection.

type DCOptions

type DCOptions struct {
	// Logger is the structured logger. No logs by default.
	Logger log.Logger
	// MTProto options for connections.
	// Opened connection limit to the DC.
	MaxOpenConnections int64
}

DCOptions is a Telegram data center connections pool options.

type Session

type Session struct {
	DC      int
	AuthKey crypto.AuthKey
	Salt    int64
}

Session represents DC session.

type SyncSession

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

SyncSession is synchronization helper for Session.

func NewSyncSession

func NewSyncSession(data Session) *SyncSession

NewSyncSession creates new SyncSession.

func (*SyncSession) Load

func (s *SyncSession) Load() (data Session)

Load gets session and returns it.

func (*SyncSession) Migrate

func (s *SyncSession) Migrate(dc int)

Migrate changes current DC and its addr, zeroes AuthKey and Salt.

func (*SyncSession) Options

func (s *SyncSession) Options(opts mtproto.Options) (mtproto.Options, Session)

Options fills Key and Salt field of given Options using stored session and returns it.

func (*SyncSession) Store

func (s *SyncSession) Store(data Session)

Store saves given Session.

Jump to

Keyboard shortcuts

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