| | |
| | | |
| | | return nil, errors.New("please choose a suitable deliver.mode") |
| | | } |
| | | |
| | | // NewServerWithTimeout with timeout |
| | | func NewServerWithTimeout(m Mode, url string, tm int, args ...interface{}) (Deliver, error) { |
| | | if m > ModeStart && m < ModeNNG { |
| | | setTimeOut(tm) |
| | | s := nngServer(m, url, args...) |
| | | if s == nil { |
| | | return nil, errors.New("nng create server error") |
| | | } |
| | | return s, nil |
| | | } else if m == Shm { |
| | | return shmServer(m, url, args...) |
| | | } |
| | | return nil, errors.New("please choose a suitable deliver.mode") |
| | | } |
| | | |
| | | // NewClientWithTimeout with timeout, tm unit millisecond |
| | | func NewClientWithTimeout(m Mode, url string, tm int, args ...interface{}) (Deliver, error) { |
| | | if m > ModeStart && m < ModeNNG { |
| | | setTimeOut(tm) |
| | | |
| | | s := nngClient(m, url, args...) |
| | | if s == nil { |
| | | return nil, errors.New("nng create client error") |
| | | } |
| | | return s, nil |
| | | } else if m == Shm { |
| | | return shmClient(m, url, args...) |
| | | } |
| | | |
| | | return nil, errors.New("please choose a suitable deliver.mode") |
| | | } |
| | |
| | | var ( |
| | | maxRecvSize = 33 * 1024 * 1024 |
| | | surveyorTime = 0 |
| | | timeout = time.Duration(25) |
| | | ) |
| | | |
| | | func setTimeOut(tm int) { |
| | | timeout = time.Duration(tm) |
| | | } |
| | | |
| | | func optDefault() map[string]interface{} { |
| | | timeout := time.Duration(25) |
| | | |
| | | options := make(map[string]interface{}) |
| | | |