mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-21 11:16:47 +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:**
|
3. **Build the project:**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go build -ldflags "-s -w" -o dodo
|
go build -o dodo
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate an executable named `dodo` in the project directory.
|
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",
|
"method": "GET",
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"no_proxy_check": false,
|
"timeout": 10000,
|
||||||
"timeout": 2000,
|
"dodos_count": 50,
|
||||||
"dodos_count": 10,
|
|
||||||
"request_count": 1000,
|
"request_count": 1000,
|
||||||
"params": {},
|
"params": {},
|
||||||
"headers": {},
|
"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
|
```sh
|
||||||
dodo -c /path/config.json
|
dodo -c /path/config.json
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION string = "0.5.2"
|
VERSION string = "0.5.1"
|
||||||
DefaultUserAgent string = "Dodo/" + VERSION
|
DefaultUserAgent string = "Dodo/" + VERSION
|
||||||
ProxyCheckURL string = "https://www.google.com"
|
ProxyCheckURL string = "https://www.google.com"
|
||||||
DefaultMethod string = "GET"
|
DefaultMethod string = "GET"
|
||||||
|
@ -31,7 +31,7 @@ func CLIConfigReader() (*config.CLIConfig, error) {
|
|||||||
dodo -c /path/to/config/file/config.json
|
dodo -c /path/to/config/file/config.json
|
||||||
|
|
||||||
Usage with all flags:
|
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) {},
|
Run: func(cmd *cobra.Command, args []string) {},
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
|
@ -2,6 +2,7 @@ package requests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ import (
|
|||||||
// - Responses: A collection of responses from the executed requests.
|
// - Responses: A collection of responses from the executed requests.
|
||||||
// - error: An error if the operation fails, such as no internet connection or an interrupt.
|
// - 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) {
|
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)
|
checkConnectionCtx, checkConnectionCtxCancel := context.WithTimeout(ctx, 8*time.Second)
|
||||||
if !checkConnection(checkConnectionCtx) {
|
if !checkConnection(checkConnectionCtx) {
|
||||||
checkConnectionCtxCancel()
|
checkConnectionCtxCancel()
|
||||||
|
@ -5,11 +5,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Don't call this struct directly, use NewOption[T] or NewNoneOption[T] instead.
|
|
||||||
type Option[T any] struct {
|
type Option[T any] struct {
|
||||||
// value holds the actual value of the Option if it is not None.
|
|
||||||
value T
|
value T
|
||||||
// none indicates whether the Option is None (i.e., has no value).
|
|
||||||
none bool
|
none bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +14,6 @@ func (o *Option[T]) IsNone() bool {
|
|||||||
return o.none
|
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) {
|
func (o *Option[T]) ValueOrErr() (*T, error) {
|
||||||
if o.IsNone() {
|
if o.IsNone() {
|
||||||
return nil, errors.New("Option is None")
|
return nil, errors.New("Option is None")
|
||||||
@ -25,7 +21,6 @@ func (o *Option[T]) ValueOrErr() (*T, error) {
|
|||||||
return &o.value, nil
|
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 {
|
func (o *Option[T]) ValueOr(def *T) *T {
|
||||||
if o.IsNone() {
|
if o.IsNone() {
|
||||||
return def
|
return def
|
||||||
@ -33,7 +28,6 @@ func (o *Option[T]) ValueOr(def *T) *T {
|
|||||||
return &o.value
|
return &o.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// The returned value can't be nil, if the Option is None, it will panic.
|
|
||||||
func (o *Option[T]) ValueOrPanic() *T {
|
func (o *Option[T]) ValueOrPanic() *T {
|
||||||
if o.IsNone() {
|
if o.IsNone() {
|
||||||
panic("Option is None")
|
panic("Option is None")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user