manager

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package manager contains connection management utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicConfig added in v0.30.0

type AtomicConfig struct {
	atomic.Value
}

AtomicConfig is atomic tg.Config.

func NewAtomicConfig added in v0.30.0

func NewAtomicConfig(cfg tg.Config) *AtomicConfig

NewAtomicConfig creates new AtomicConfig.

func (*AtomicConfig) Load added in v0.30.0

func (c *AtomicConfig) Load() tg.Config

Load loads atomically config and returns it.

func (*AtomicConfig) Store added in v0.30.0

func (c *AtomicConfig) Store(cfg tg.Config)

Store saves given config atomically.

type Conn

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

Conn is a Telegram client connection.

func CreateConn

func CreateConn(
	create mtproto.Dialer,
	mode ConnMode,
	appID int,
	opts mtproto.Options,
	connOpts ConnOptions,
) *Conn

CreateConn creates new connection.

func (*Conn) Invoke added in v0.43.0

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

Invoke implements Invoker.

func (*Conn) OnMessage

func (c *Conn) OnMessage(b *bin.Buffer) error

OnMessage implements mtproto.Handler.

func (*Conn) OnSession

func (c *Conn) OnSession(session mtproto.Session) error

OnSession implements mtproto.Handler.

func (*Conn) Ping added in v0.48.0

func (c *Conn) Ping(ctx context.Context) error

Ping calls ping for underlying protocol connection.

func (*Conn) Ready

func (c *Conn) Ready() <-chan struct{}

Ready returns channel to determine connection readiness. Useful for pooling.

func (*Conn) Run

func (c *Conn) Run(ctx context.Context) (err error)

Run initialize connection.

type ConnMode

type ConnMode byte

ConnMode represents connection mode.

const (
	// ConnModeUpdates is update connection mode.
	ConnModeUpdates ConnMode = iota
	// ConnModeData is data connection mode.
	ConnModeData
	// ConnModeCDN is CDN connection mode.
	ConnModeCDN
)

func (ConnMode) String

func (i ConnMode) String() string

type ConnOptions

type ConnOptions struct {
	DC      int
	Test    bool
	Device  DeviceConfig
	Handler Handler
	Setup   SetupCallback
	Backoff func(ctx context.Context) backoff.BackOff
}

ConnOptions is a Telegram client connection options.

type DeviceConfig

type DeviceConfig struct {
	// Device model.
	DeviceModel string
	// Operating system version.
	SystemVersion string
	// Application version.
	AppVersion string
	// Code for the language used on the device's OS, ISO 639-1 standard.
	SystemLangCode string
	// Language pack to use.
	LangPack string
	// Code for the language used on the client, ISO 639-1 standard.
	LangCode string
	// Info about an MTProto proxy.
	Proxy tg.InputClientProxy
	// Additional initConnection parameters. For now, only the tz_offset field is supported,
	// for specifying timezone offset in seconds.
	Params tg.JSONValueClass
}

DeviceConfig is config which send when Telegram connection session created.

func (*DeviceConfig) SetDefaults

func (c *DeviceConfig) SetDefaults()

SetDefaults sets default values.

type Handler

type Handler interface {
	OnSession(cfg tg.Config, s mtproto.Session) error
	OnMessage(b *bin.Buffer) error
}

Handler abstracts updates and session handler.

type NoopHandler

type NoopHandler struct{}

NoopHandler is a noop handler.

func (NoopHandler) OnMessage

func (n NoopHandler) OnMessage(b *bin.Buffer) error

OnMessage implements Handler

func (NoopHandler) OnSession

func (n NoopHandler) OnSession(cfg tg.Config, s mtproto.Session) error

OnSession implements Handler.

type SetupCallback

type SetupCallback = func(ctx context.Context, invoker tg.Invoker) error

SetupCallback is an optional setup connection callback.

Jump to

Keyboard shortcuts

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