Documentation ¶
Overview ¶
Package tgtest provides test Telegram server for basic end-to-end tests.
Index ¶
- type BufferedConn
- type Cluster
- func (c *Cluster) Common() *Dispatcher
- func (c *Cluster) Config() tg.Config
- func (c *Cluster) DC(id int, name string) *Server
- func (c *Cluster) Dispatch(id int, name string) *Dispatcher
- func (c *Cluster) Keys() []*rsa.PublicKey
- func (c *Cluster) Ready() <-chan struct{}
- func (c *Cluster) Up(ctx context.Context) error
- func (c *Cluster) WithLogger(log *zap.Logger) *Cluster
- type Dispatcher
- func (d *Dispatcher) Fallback(h Handler) *Dispatcher
- func (d *Dispatcher) Handle(id uint32, h Handler) *Dispatcher
- func (d *Dispatcher) HandleFunc(id uint32, h func(server *Server, req *Request) error) *Dispatcher
- func (d *Dispatcher) OnMessage(server *Server, req *Request) error
- func (d *Dispatcher) Result(id uint32, msg bin.Encoder) *Dispatcher
- func (d *Dispatcher) Vector(id uint32, msgs ...bin.Encoder) *Dispatcher
- type Handler
- type HandlerFunc
- type Request
- type Server
- func (s *Server) AddSession(key crypto.AuthKey)
- func (s *Server) Dispatcher() *Dispatcher
- func (s *Server) ForceDisconnect(k Session)
- func (s *Server) Key() *rsa.PublicKey
- func (s *Server) Send(ctx context.Context, k Session, t proto.MessageType, encoder bin.Encoder) error
- func (s *Server) SendAck(ctx context.Context, k Session, ids ...int64) error
- func (s *Server) SendBool(req *Request, r bool) error
- func (s *Server) SendConfig(req *Request) error
- func (s *Server) SendErr(req *Request, e *tgerr.Error) error
- func (s *Server) SendEternalSalt(req *Request) error
- func (s *Server) SendFutureSalts(req *Request, salts ...mt.FutureSalt) error
- func (s *Server) SendPong(req *Request, pingID int64) error
- func (s *Server) SendResult(req *Request, msg bin.Encoder) error
- func (s *Server) SendUpdates(ctx context.Context, k Session, updates ...tg.UpdateClass) error
- func (s *Server) SendVector(req *Request, msgs ...bin.Encoder) error
- func (s *Server) Serve(ctx context.Context, l net.Listener) error
- type Session
- type Suite
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedConn ¶
type BufferedConn struct {
// contains filtered or unexported fields
}
func NewBufferedConn ¶
func NewBufferedConn(conn transport.Conn) *BufferedConn
func (*BufferedConn) Close ¶
func (c *BufferedConn) Close() error
func (*BufferedConn) Push ¶
func (c *BufferedConn) Push(b *bin.Buffer)
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster creates cluster of multiple servers, representing telegram multiple datacenters.
func NewCluster ¶
NewCluster creates new server Cluster.
func (*Cluster) Dispatch ¶
func (c *Cluster) Dispatch(id int, name string) *Dispatcher
Dispatch registers new server and returns its dispatcher.
func (*Cluster) Ready ¶
func (c *Cluster) Ready() <-chan struct{}
Ready returns signal channel to await readiness.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is a plain handler to map requests by ID.
func (*Dispatcher) Fallback ¶
func (d *Dispatcher) Fallback(h Handler) *Dispatcher
Fallback sets fallback handler.
func (*Dispatcher) Handle ¶
func (d *Dispatcher) Handle(id uint32, h Handler) *Dispatcher
Handle sets handler for given TypeID.
func (*Dispatcher) HandleFunc ¶
func (d *Dispatcher) HandleFunc(id uint32, h func(server *Server, req *Request) error) *Dispatcher
HandleFunc sets handler for given TypeID.
func (*Dispatcher) OnMessage ¶
func (d *Dispatcher) OnMessage(server *Server, req *Request) error
OnMessage implements Handler
func (*Dispatcher) Result ¶
func (d *Dispatcher) Result(id uint32, msg bin.Encoder) *Dispatcher
Result sets constant result for given TypeID. NB: it uses rpc_result to pack given encoder.
func (*Dispatcher) Vector ¶
func (d *Dispatcher) Vector(id uint32, msgs ...bin.Encoder) *Dispatcher
Vector sets constant Vector result for given TypeID. NB: it uses rpc_result to pack generic vector with given encoders.
type HandlerFunc ¶
HandlerFunc is functional adapter for Handler.OnMessage method.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewUnstartedServer ¶
func (*Server) AddSession ¶
func (*Server) Dispatcher ¶
func (s *Server) Dispatcher() *Dispatcher
func (*Server) ForceDisconnect ¶
func (*Server) SendConfig ¶
func (*Server) SendEternalSalt ¶
func (*Server) SendFutureSalts ¶
func (s *Server) SendFutureSalts(req *Request, salts ...mt.FutureSalt) error