Skip to content

Commit 0537406

Browse files
committed
Removed useless comments.
1 parent d1acea2 commit 0537406

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ go get github.com/hyperf/roc
1212

1313
[roc-skeleton](https://github.com/limingxinleo/roc-skeleton)
1414

15+
### For Server
16+
1517
- action/foo_save_action.go
1618

1719
```go
@@ -121,6 +123,84 @@ func main() {
121123

122124
```
123125

126+
### For Client
127+
128+
```go
129+
package main
130+
131+
import (
132+
"fmt"
133+
cli "github.com/hyperf/roc/client"
134+
"github.com/hyperf/roc/formatter"
135+
"time"
136+
)
137+
138+
type FooSaveInput struct {
139+
Name string `json:"name"`
140+
Gender int `json:"gender"`
141+
}
142+
143+
type FooSaveRequest struct {
144+
ID int
145+
Input *FooSaveInput
146+
}
147+
148+
type FooSaveResult struct {
149+
IsSuccess bool `json:"is_success"`
150+
}
151+
152+
type LocalAddr struct {
153+
}
154+
155+
func (l LocalAddr) Network() string {
156+
return "tcp"
157+
}
158+
159+
func (l LocalAddr) String() string {
160+
return "127.0.0.1:9501"
161+
}
162+
163+
func (f *FooSaveRequest) MarshalJSON() ([]byte, error) {
164+
return formatter.FormatRequestToByte(f)
165+
}
166+
167+
var client *cli.Client
168+
169+
func init() {
170+
var err error
171+
client, err = cli.NewAddrClient(&LocalAddr{})
172+
if err != nil {
173+
fmt.Println(err)
174+
}
175+
}
176+
func main() {
177+
req := FooSaveRequest{ID: 1, Input: &FooSaveInput{Name: "limx", Gender: 1}}
178+
id, _ := client.SendRequest("/foo/save", &req)
179+
180+
ret := &formatter.JsonRPCResponse[FooSaveResult, any]{}
181+
err := client.Recv(id, ret, cli.NewDefaultRecvOption())
182+
if err != nil {
183+
fmt.Println(err)
184+
}
185+
186+
fmt.Println(ret.Result.IsSuccess)
187+
188+
for {
189+
req = FooSaveRequest{ID: 1, Input: &FooSaveInput{Name: "error", Gender: 1}}
190+
id, _ = client.SendRequest("/foo/save", &req)
191+
192+
ret = &formatter.JsonRPCResponse[FooSaveResult, any]{}
193+
err = client.Recv(id, ret, cli.NewDefaultRecvOption())
194+
if err != nil {
195+
fmt.Println(err)
196+
}
197+
198+
time.Sleep(time.Second)
199+
}
200+
}
201+
202+
```
203+
124204
## Related Repositories
125205

126206
- [multiplex](https://github.com/hyperf/multiplex) Channel driven multiplexing connection for PHP.

client/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func (c *Client) SendRequest(path string, r json.Marshaler) (uint32, error) {
9292
}
9393

9494
func (c *Client) Recv(id uint32, ret interface{}, option *RecvOption) exception.ExceptionInterface {
95-
// TODO: 增加超时
9695
select {
9796
case bt, ok := <-c.ChannelManager.Get(id, false):
9897
if !ok {

0 commit comments

Comments
 (0)