|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "git.nspix.com/golang/kos/util/env"
|
|
"github.com/peterh/liner"
|
|
"github.com/peterh/liner"
|
|
"io"
|
|
"io"
|
|
"math"
|
|
"math"
|
|
@@ -240,14 +241,22 @@ func (client *Client) Close() (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
func NewClient(ctx context.Context, addr string) *Client {
|
|
func NewClient(ctx context.Context, addr string) *Client {
|
|
|
|
+ var (
|
|
|
|
+ err error
|
|
|
|
+ timeout time.Duration
|
|
|
|
+ )
|
|
if ctx == nil {
|
|
if ctx == nil {
|
|
ctx = context.Background()
|
|
ctx = context.Background()
|
|
}
|
|
}
|
|
|
|
+ duration := env.Get("VOX_TIMEOUT", "30s")
|
|
|
|
+ if timeout, err = time.ParseDuration(duration); err != nil {
|
|
|
|
+ timeout = time.Second * 30
|
|
|
|
+ }
|
|
return &Client{
|
|
return &Client{
|
|
ctx: ctx,
|
|
ctx: ctx,
|
|
address: addr,
|
|
address: addr,
|
|
name: filepath.Base(os.Args[0]),
|
|
name: filepath.Base(os.Args[0]),
|
|
- Timeout: time.Second * 30,
|
|
|
|
|
|
+ Timeout: timeout,
|
|
liner: liner.NewLiner(),
|
|
liner: liner.NewLiner(),
|
|
readyChan: make(chan struct{}, 1),
|
|
readyChan: make(chan struct{}, 1),
|
|
exitChan: make(chan struct{}),
|
|
exitChan: make(chan struct{}),
|