work

package
v0.0.0-...-ba5ae49 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2014 hey Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2014 hey Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpWork

type HttpWork struct {
	// H2 is an option to make HTTP/2 requests
	H2 bool

	// Timeout in seconds.
	Timeout int

	// DisableCompression is an option to disable compression in response
	DisableCompression bool

	// DisableKeepAlives is an option to prevents re-use of TCP connections between different HTTP requests
	DisableKeepAlives bool

	// DisableRedirects is an option to prevent the following of HTTP redirects
	DisableRedirects bool

	// ProxyAddr is the address of HTTP proxy server in the format on "host:port".
	// Optional.
	ProxyAddr *url.URL
	// contains filtered or unexported fields
}

func (*HttpWork) CloneRequest

func (this *HttpWork) CloneRequest(r *http.Request, body []byte) *http.Request

cloneRequest returns a clone of the provided *http.Request. The clone is a shallow copy of the struct and its Header map.

func (*HttpWork) GetClient

func (this *HttpWork) GetClient() *http.Client

func (*HttpWork) MakeRequest

func (this *HttpWork) MakeRequest(client *http.Client, req *http.Request) *Result

type MqttWork

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

func (*MqttWork) Connect

func (this *MqttWork) Connect(opts *MQTT.ClientOptions) error

func (*MqttWork) Finish

func (this *MqttWork) Finish()

func (*MqttWork) GetClient

func (this *MqttWork) GetClient() MQTT.Client

func (*MqttWork) GetDefaultOptions

func (this *MqttWork) GetDefaultOptions(addrURI string) *MQTT.ClientOptions

func (*MqttWork) On

func (this *MqttWork) On(topic string, callback func(client MQTT.Client, msg MQTT.Message))

*

  • 监听指定类型的topic消息
  • @param topic
  • @param callback

func (*MqttWork) Request

func (this *MqttWork) Request(ctx context.Context, topic string, body []byte) (MQTT.Message, error)

*

  • 向服务器发送一条消息
  • @param topic
  • @param msg
  • @param callback

func (*MqttWork) RequestNR

func (this *MqttWork) RequestNR(topic string, body []byte)

*

  • 向服务器发送一条消息,但不要求服务器返回结果
  • @param topic
  • @param msg

func (*MqttWork) RequestURI

func (this *MqttWork) RequestURI(ctx context.Context, u *url.URL, body []byte) (MQTT.Message, error)

*

  • 向服务器发送一条消息
  • @param topic
  • @param msg
  • @param callback

func (*MqttWork) RequestURINR

func (this *MqttWork) RequestURINR(url *url.URL, body []byte)

*

  • 向服务器发送一条消息
  • @param topic
  • @param msg
  • @param callback

type Report

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

func NewReport

func NewReport(w io.Writer, size int, results chan *Result, output string, total time.Duration) *Report

func (*Report) Finalize

func (r *Report) Finalize()

type Result

type Result struct {
	Err           error
	StatusCode    int
	Duration      time.Duration
	ConnDuration  time.Duration // connection setup(DNS lookup + Dial up) duration
	DnsDuration   time.Duration // dns lookup duration
	ReqDuration   time.Duration // request "write" duration
	ResDuration   time.Duration // response "read" duration
	DelayDuration time.Duration // delay between response and request
	ContentLength int64
	Body          []byte
}

Jump to

Keyboard shortcuts

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