pool

package
v0.0.0-...-aa11ac5 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package pool implements client pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	AppID   int
	AppHash string
	Log     *zap.Logger
	Debug   bool
}

type Pool

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

Pool of clients.

func NewPool

func NewPool(statePath string, opt Options) (*Pool, error)

func (*Pool) Do

func (p *Pool) Do(ctx context.Context, token Token, fn func(client *botapi.BotAPI) error) error

Do acquires telegram client by token.

Returns error if token is invalid. Block until client is available, authentication error or context cancelled.

func (*Pool) Kill

func (p *Pool) Kill(token Token)

Kill shutdowns client by token.

func (*Pool) RunGC

func (p *Pool) RunGC(timeout time.Duration)

type Token

type Token struct {
	ID     int    // 123456
	Secret string // ABC-DEF1234ghIkl-zyx57W2v1u123ew11
}

Token represents bot token, like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11

func ParseToken

func ParseToken(s string) (Token, error)

ParseToken parses bot token from given string.

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

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