Documentation ¶
Overview ¶
Package tgtest provides test Telegram server for end-to-end test.
Index ¶
- type BufferedConn
- 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 Quorum
- func (q *Quorum) Common() *Dispatcher
- func (q *Quorum) Config() tg.Config
- func (q *Quorum) DC(id int, name string) *Server
- func (q *Quorum) Dispatch(id int, name string) *Dispatcher
- func (q *Quorum) Keys() []*rsa.PublicKey
- func (q *Quorum) Ready() <-chan struct{}
- func (q *Quorum) Up(ctx context.Context) error
- func (q *Quorum) WithLogger(log *zap.Logger) *Quorum
- 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 ¶ added in v0.15.1
type BufferedConn struct {
// contains filtered or unexported fields
}
func NewBufferedConn ¶ added in v0.15.1
func NewBufferedConn(conn transport.Conn) *BufferedConn
func (*BufferedConn) Close ¶ added in v0.15.1
func (c *BufferedConn) Close() error
func (*BufferedConn) Push ¶ added in v0.15.1
func (c *BufferedConn) Push(b *bin.Buffer)
type Dispatcher ¶ added in v0.30.0
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is a plain handler to map requests by ID.
func NewDispatcher ¶ added in v0.30.0
func NewDispatcher() *Dispatcher
NewDispatcher creates new Dispatcher.
func (*Dispatcher) Fallback ¶ added in v0.30.0
func (d *Dispatcher) Fallback(h Handler) *Dispatcher
Fallback sets fallback handler.
func (*Dispatcher) Handle ¶ added in v0.30.0
func (d *Dispatcher) Handle(id uint32, h Handler) *Dispatcher
Handle sets handler for given TypeID.
func (*Dispatcher) HandleFunc ¶ added in v0.30.0
func (d *Dispatcher) HandleFunc(id uint32, h func(server *Server, req *Request) error) *Dispatcher
HandleFunc sets handler for given TypeID.
func (*Dispatcher) OnMessage ¶ added in v0.30.0
func (d *Dispatcher) OnMessage(server *Server, req *Request) error
OnMessage implements Handler
func (*Dispatcher) Result ¶ added in v0.30.0
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 ¶ added in v0.30.0
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 ¶ added in v0.12.0
HandlerFunc is functional adapter for Handler.OnMessage method.
type Quorum ¶ added in v0.30.0
type Quorum struct {
// contains filtered or unexported fields
}
Quorum is a helper struct to create DC quorum.
func (*Quorum) Common ¶ added in v0.30.0
func (q *Quorum) Common() *Dispatcher
Common returns common dispatcher.
func (*Quorum) Dispatch ¶ added in v0.30.0
func (q *Quorum) Dispatch(id int, name string) *Dispatcher
Dispatch registers new server and returns its dispatcher.
func (*Quorum) Ready ¶ added in v0.30.0
func (q *Quorum) Ready() <-chan struct{}
Ready returns signal channel to await readiness.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewUnstartedServer ¶
func (*Server) AddSession ¶ added in v0.21.0
func (*Server) Dispatcher ¶ added in v0.30.0
func (s *Server) Dispatcher() *Dispatcher
func (*Server) ForceDisconnect ¶ added in v0.12.0
func (*Server) SendConfig ¶ added in v0.12.0
func (*Server) SendEternalSalt ¶ added in v0.28.0
func (*Server) SendFutureSalts ¶ added in v0.28.0
func (s *Server) SendFutureSalts(req *Request, salts ...mt.FutureSalt) error