tgtest

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package tgtest provides test Telegram server for end-to-end test.

Index

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)

func (*BufferedConn) Recv added in v0.15.1

func (c *BufferedConn) Recv(ctx context.Context, b *bin.Buffer) error

func (*BufferedConn) Send added in v0.15.1

func (c *BufferedConn) Send(ctx context.Context, b *bin.Buffer) error

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 Handler added in v0.11.0

type Handler interface {
	OnMessage(server *Server, req *Request) error
}

func TestTransport added in v0.12.0

func TestTransport(t testing.TB, logger *zap.Logger, message string) Handler

type HandlerFunc added in v0.12.0

type HandlerFunc func(server *Server, req *Request) error

HandlerFunc is functional adapter for Handler.OnMessage method.

func (HandlerFunc) OnMessage added in v0.12.0

func (h HandlerFunc) OnMessage(server *Server, req *Request) error

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 NewQuorum added in v0.30.0

func NewQuorum(codec func() transport.Codec) *Quorum

NewQuorum creates new Quorum.

func (*Quorum) Common added in v0.30.0

func (q *Quorum) Common() *Dispatcher

Common returns common dispatcher.

func (*Quorum) Config added in v0.30.0

func (q *Quorum) Config() tg.Config

Config returns config for client.

func (*Quorum) DC added in v0.30.0

func (q *Quorum) DC(id int, name string) *Server

DC registers new server and returns it.

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) Keys added in v0.30.0

func (q *Quorum) Keys() []*rsa.PublicKey

Keys returns all servers public keys.

func (*Quorum) Ready added in v0.30.0

func (q *Quorum) Ready() <-chan struct{}

Ready returns signal channel to await readiness.

func (*Quorum) Up added in v0.30.0

func (q *Quorum) Up(ctx context.Context) error

Up runs all servers in a quorum.

func (*Quorum) WithLogger added in v0.30.0

func (q *Quorum) WithLogger(log *zap.Logger) *Quorum

WithLogger sets logger.

type Request added in v0.30.0

type Request struct {
	DC         int
	Session    Session
	MsgID      int64
	Buf        *bin.Buffer
	RequestCtx context.Context
}

type Server

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

func NewUnstartedServer

func NewUnstartedServer(dcID int, log *zap.Logger, codec func() transport.Codec) *Server

func (*Server) AddSession added in v0.21.0

func (s *Server) AddSession(key crypto.AuthKey)

func (*Server) Dispatcher added in v0.30.0

func (s *Server) Dispatcher() *Dispatcher

func (*Server) ForceDisconnect added in v0.12.0

func (s *Server) ForceDisconnect(k Session)

func (*Server) Key

func (s *Server) Key() *rsa.PublicKey

func (*Server) Send added in v0.11.0

func (s *Server) Send(ctx context.Context, k Session, t proto.MessageType, encoder bin.Encoder) error

func (*Server) SendAck added in v0.12.0

func (s *Server) SendAck(ctx context.Context, k Session, ids ...int64) error

func (*Server) SendBool added in v0.31.0

func (s *Server) SendBool(req *Request, r bool) error

func (*Server) SendConfig added in v0.12.0

func (s *Server) SendConfig(req *Request) error

func (*Server) SendErr added in v0.31.0

func (s *Server) SendErr(req *Request, e *tgerr.Error) error

func (*Server) SendEternalSalt added in v0.28.0

func (s *Server) SendEternalSalt(req *Request) error

func (*Server) SendFutureSalts added in v0.28.0

func (s *Server) SendFutureSalts(req *Request, salts ...mt.FutureSalt) error

func (*Server) SendPong added in v0.12.0

func (s *Server) SendPong(req *Request, pingID int64) error

func (*Server) SendResult added in v0.11.0

func (s *Server) SendResult(req *Request, msg bin.Encoder) error

func (*Server) SendUpdates added in v0.12.0

func (s *Server) SendUpdates(ctx context.Context, k Session, updates ...tg.UpdateClass) error

func (*Server) SendVector added in v0.30.0

func (s *Server) SendVector(req *Request, msgs ...bin.Encoder) error

func (*Server) Serve added in v0.15.0

func (s *Server) Serve(ctx context.Context, l net.Listener) error

type Session added in v0.11.0

type Session struct {
	SessionID int64
	crypto.AuthKey
}

type Suite added in v0.12.0

type Suite struct {
	testing.TB
	Ctx context.Context
	Log *zap.Logger
}

func NewSuite added in v0.12.0

func NewSuite(ctx context.Context, tb testing.TB, log *zap.Logger) Suite

type TB

type TB interface {
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Fatal(args ...interface{})
}

Directories

Path Synopsis
services
file
Package file contains file service implementation for tgtest server.
Package file contains file service implementation for tgtest server.

Jump to

Keyboard shortcuts

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