forked from crossoverJie/ptg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f16ad6a
commit fe76b9d
Showing
13 changed files
with
455 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/crossoverJie/ptg/meta" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
type ( | ||
Client interface { | ||
Request() (*meta.Response, error) | ||
} | ||
) | ||
|
||
const ( | ||
Http = "http" | ||
Grpc = "grpc" | ||
) | ||
|
||
func NewClient(method, url, requestBody string, meta *meta.Meta) Client { | ||
if meta.Protocol() == Http { | ||
return &httpClient{ | ||
Method: method, | ||
Url: url, | ||
RequestBody: requestBody, | ||
httpClient: &http.Client{ | ||
Transport: &http.Transport{ | ||
ResponseHeaderTimeout: time.Millisecond * time.Duration(1000), | ||
DisableKeepAlives: true, | ||
}, | ||
}, | ||
meta: meta, | ||
} | ||
} else { | ||
return NewGrpcClient(meta) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.