mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-20 19:13:06 +00:00
Compare commits
1 Commits
2bd45e22a4
...
159ab66b58
Author | SHA1 | Date | |
---|---|---|---|
159ab66b58 |
@ -33,7 +33,7 @@ Follow the steps below to build dodo:
|
||||
3. **Build the project:**
|
||||
|
||||
```sh
|
||||
go build -ldflags "-s -w" -o dodo
|
||||
go build -o dodo
|
||||
```
|
||||
|
||||
This will generate an executable named `dodo` in the project directory.
|
||||
@ -58,9 +58,8 @@ You can find an example config structure in the [config.json](https://github.com
|
||||
{
|
||||
"method": "GET",
|
||||
"url": "https://example.com",
|
||||
"no_proxy_check": false,
|
||||
"timeout": 2000,
|
||||
"dodos_count": 10,
|
||||
"timeout": 10000,
|
||||
"dodos_count": 50,
|
||||
"request_count": 1000,
|
||||
"params": {},
|
||||
"headers": {},
|
||||
@ -78,7 +77,7 @@ You can find an example config structure in the [config.json](https://github.com
|
||||
]
|
||||
}
|
||||
```
|
||||
Send 1000 GET requests to https://example.com with 10 parallel dodos (threads) and a timeout of 2000 milliseconds:
|
||||
Send 1000 GET requests to https://example.com with 5 parallel dodos (threads) and a timeout of 10000 milliseconds:
|
||||
|
||||
```sh
|
||||
dodo -c /path/config.json
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION string = "0.5.2"
|
||||
VERSION string = "0.5.1"
|
||||
DefaultUserAgent string = "Dodo/" + VERSION
|
||||
ProxyCheckURL string = "https://www.google.com"
|
||||
DefaultMethod string = "GET"
|
||||
|
@ -31,7 +31,7 @@ func CLIConfigReader() (*config.CLIConfig, error) {
|
||||
dodo -c /path/to/config/file/config.json
|
||||
|
||||
Usage with all flags:
|
||||
dodo -c /path/to/config/file/config.json -u https://example.com -m POST -d 10 -r 1000 -t 2000 --no-proxy-check -y`,
|
||||
dodo -c /path/to/config/file/config.json -u https://example.com -m POST -d 10 -r 1000 -t 2000`,
|
||||
Run: func(cmd *cobra.Command, args []string) {},
|
||||
SilenceErrors: true,
|
||||
SilenceUsage: true,
|
||||
|
@ -2,6 +2,7 @@ package requests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -24,6 +25,8 @@ import (
|
||||
// - Responses: A collection of responses from the executed requests.
|
||||
// - error: An error if the operation fails, such as no internet connection or an interrupt.
|
||||
func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) {
|
||||
fmt.Println("No Proxy Check:", requestConfig.NoProxyCheck)
|
||||
|
||||
checkConnectionCtx, checkConnectionCtxCancel := context.WithTimeout(ctx, 8*time.Second)
|
||||
if !checkConnection(checkConnectionCtx) {
|
||||
checkConnectionCtxCancel()
|
||||
|
@ -5,19 +5,15 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Don't call this struct directly, use NewOption[T] or NewNoneOption[T] instead.
|
||||
type Option[T any] struct {
|
||||
// value holds the actual value of the Option if it is not None.
|
||||
value T
|
||||
// none indicates whether the Option is None (i.e., has no value).
|
||||
none bool
|
||||
none bool
|
||||
}
|
||||
|
||||
func (o *Option[T]) IsNone() bool {
|
||||
return o.none
|
||||
}
|
||||
|
||||
// The returned value can be nil, if the Option is None, it will return nil and an error.
|
||||
func (o *Option[T]) ValueOrErr() (*T, error) {
|
||||
if o.IsNone() {
|
||||
return nil, errors.New("Option is None")
|
||||
@ -25,7 +21,6 @@ func (o *Option[T]) ValueOrErr() (*T, error) {
|
||||
return &o.value, nil
|
||||
}
|
||||
|
||||
// The returned value can't be nil, if the Option is None, it will return the default value.
|
||||
func (o *Option[T]) ValueOr(def *T) *T {
|
||||
if o.IsNone() {
|
||||
return def
|
||||
@ -33,7 +28,6 @@ func (o *Option[T]) ValueOr(def *T) *T {
|
||||
return &o.value
|
||||
}
|
||||
|
||||
// The returned value can't be nil, if the Option is None, it will panic.
|
||||
func (o *Option[T]) ValueOrPanic() *T {
|
||||
if o.IsNone() {
|
||||
panic("Option is None")
|
||||
|
Loading…
x
Reference in New Issue
Block a user