deliver

package
v0.0.0-...-853a2e8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Client stands for a client which send requests to remote server, client can clone at request level, since request is not related to the underlining tcp packet sequence, so more flexible.

Deliver stands for a remote host to send traffic to

Sender writes request bytes to remote connections it can maintain multiple connections concurrently and receive bytes from the chan C.

Index

Constants

View Source
const (
	TBinaryProtocol = iota
	TCompactProtocol
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Idx    int
	Config *ClientConfig
	S      Sender
	Ctx    context.Context
	Stat   *Stat
}

func NewClient

func NewClient(ctx context.Context, c *ClientConfig) (*Client, error)

type ClientConfig

type ClientConfig struct {
	RemoteAddr string
	IsLong     bool
	Clone      int
}

type Deliver

type Deliver struct {
	Config  *DeliverConfig
	Stat    *Stat
	Clients []*Client
	Ctx     context.Context
	C       chan []byte
}

func NewDeliver

func NewDeliver(ctx context.Context, config *DeliverConfig) (*Deliver, error)

func (*Deliver) Run

func (d *Deliver) Run() error

type DeliverConfig

type DeliverConfig struct {
	IsLong       bool
	Concurrency  int
	RemoteAddr   string
	Last         int
	Clone        int
	ProtocolType int
	Mode         ModeType
}

type LongConnSender

type LongConnSender struct {
	RemoteAddr string
	ConnNum    int
	Remotes    []net.Conn
	ConnState  []bool
	Ctx        context.Context
	C          chan []byte
	Stat       *Stat
}

func (*LongConnSender) Data

func (s *LongConnSender) Data() chan []byte

type ModeType

type ModeType int
const (
	ModeRequest ModeType = iota
	ModeRaw
)

type Sender

type Sender interface {
	Data() chan []byte
	// contains filtered or unexported methods
}

func NewLongConnSender

func NewLongConnSender(ctx context.Context, n int, addr string) (Sender, error)

func NewShortConnSender

func NewShortConnSender(ctx context.Context, n int, addr string) (Sender, error)

type ShortConnSender

type ShortConnSender struct {
	RemoteAddr string
	ConnNum    int
	Ctx        context.Context
	C          chan []byte
	Stat       *Stat
}

func (*ShortConnSender) Data

func (s *ShortConnSender) Data() chan []byte

type Stat

type Stat struct {
	TotalRequest     int64
	StartTime        time.Time
	RequestPerSecond int64
	LastTotalRequest int64
	LastStatTime     time.Time
}

Jump to

Keyboard shortcuts

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