Skip to content

Commit b0c73e9

Browse files
committed
gee-rpc/day7 add registry
1 parent 4c368a9 commit b0c73e9

File tree

32 files changed

+1546
-13
lines changed

32 files changed

+1546
-13
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
推荐先阅读 **[Go 语言简明教程](https://geektutu.com/post/quick-golang.html)**,一篇文章了解Go的基本语法、并发编程,依赖管理等内容。
1212

13+
另外推荐 **[Go 语言笔试面试题](https://geektutu.com/post/qa-golang.html)**,加深对 Go 语言的理解。
14+
1315
期待关注我的「[知乎专栏](https://zhuanlan.zhihu.com/geekgo)」和「[微博](http://weibo.com/geektutu)」,查看最近的文章和动态。
1416

1517
### 7天用Go从零实现Web框架 - Gee
@@ -50,6 +52,20 @@ gorm 准备推出完全重写的 v2 版本(目前还在开发中),相对 gorm-
5052
- 第六天:[支持事务(Transaction)](https://geektutu.com/post/geeorm-day6.html) | [Code](gee-orm/day6-transaction)
5153
- 第七天:[数据库迁移(Migrate)](https://geektutu.com/post/geeorm-day7.html) | [Code](gee-orm/day7-migrate)
5254

55+
56+
### 7天用Go从零实现RPC框架 GeeRPC
57+
58+
[GeeRPC](https://geektutu.com/post/geerpc.html) 是一个基于 [net/rpc](https://github.com/golang/go/tree/master/src/net/rpc) 开发的 RPC 框架
59+
GeeRPC 是基于 Go 语言标准库 `net/rpc` 实现的,添加了协议交换、服务注册与发现、负载均衡等功能,代码约 1k。
60+
61+
- 第一天 - [服务端与消息编码](https://geektutu.com/post/geerpc-day1.html) | [Code](gee-rpc/day1-codec)
62+
- 第二天 - [支持并发与异步的客户端](https://geektutu.com/post/geerpc-day2.html) | [Code](gee-rpc/day2-client)
63+
- 第三天 - [服务注册(service register)](https://geektutu.com/post/geerpc-day3.html) | [Code](gee-rpc/day3-service )
64+
- 第四天 - [超时处理(timeout)](https://geektutu.com/post/geerpc-day4.html) | [Code](gee-rpc/day4-timeout )
65+
- 第五天 - [支持HTTP协议](https://geektutu.com/post/geerpc-day5.html) | [Code](gee-rpc/day5-http-debug)
66+
- 第六天 - [负载均衡(load balance)](https://geektutu.com/post/geerpc-day6.html) | [Code](gee-rpc/day6-load-balance)
67+
- 第七天 - [服务发现与注册中心(registry)](https://geektutu.com/post/geerpc-day7.html) | [Code](gee-rpc/day7-registry)
68+
5369
### WebAssembly 使用示例
5470

5571
具体的实践过程记录在 [Go WebAssembly 简明教程](https://geektutu.com/post/quick-go-wasm.html)
@@ -102,6 +118,18 @@ Xorm's desgin is easier to understand than gorm-v1, so the main designs referenc
102118
- Day 6 - Support Transaction | [Code](gee-orm/day6-transaction)
103119
- Day 7 - Migrate Database | [Code](gee-orm/day7-migrate)
104120

121+
[GeeRPC](https://geektutu.com/post/geerpc.html) is a [net/rpc](https://github.com/golang/go/tree/master/src/net/rpc)-like RPC framework
122+
123+
Based on golang standard library `net/rpc`, GeeRPC implements more features. eg, protocol exchange, service registration and discovery, load balance, etc.
124+
125+
- Day 1 - Server Message Codec | [Code](gee-rpc/day1-codec)
126+
- Day 2 - Concurrent Client | [Code](gee-rpc/day2-client)
127+
- Day 3 - Service Register | [Code](gee-rpc/day3-service )
128+
- Day 4 - Timeout Processing | [Code](gee-rpc/day4-timeout )
129+
- Day 5 - Support HTTP Protocol | [Code](gee-rpc/day5-http-debug)
130+
- Day 6 - Load Balance | [Code](gee-rpc/day6-load-balance)
131+
- Day 7 - Discovery and Registry | [Code](gee-rpc/day7-registry)
132+
105133
## Golang WebAssembly Demo
106134

107135
- Demo 1 - Hello World [Code](demo-wasm/hello-world)

gee-rpc/day1-codec/main/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"geerpc/codec"
88
"log"
99
"net"
10+
"time"
1011
)
1112

1213
func startServer(addr chan string) {
@@ -28,6 +29,7 @@ func main() {
2829
conn, _ := net.Dial("tcp", <-addr)
2930
defer func() { _ = conn.Close() }()
3031

32+
time.Sleep(time.Second)
3133
// send options
3234
_ = json.NewEncoder(conn).Encode(geerpc.DefaultOption)
3335
cc := codec.NewGobCodec(conn)

gee-rpc/day2-client/main/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"net"
88
"sync"
9+
"time"
910
)
1011

1112
func startServer(addr chan string) {
@@ -25,6 +26,7 @@ func main() {
2526
client, _ := geerpc.Dial("tcp", <-addr)
2627
defer func() { _ = client.Close() }()
2728

29+
time.Sleep(time.Second)
2830
// send request & receive response
2931
var wg sync.WaitGroup
3032
for i := 0; i < 5; i++ {

gee-rpc/day3-service/main/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
"net"
77
"sync"
8+
"time"
89
)
910

1011
type Foo int
@@ -37,6 +38,7 @@ func main() {
3738
client, _ := geerpc.Dial("tcp", <-addr)
3839
defer func() { _ = client.Close() }()
3940

41+
time.Sleep(time.Second)
4042
// send request & receive response
4143
var wg sync.WaitGroup
4244
for i := 0; i < 5; i++ {

gee-rpc/day4-timeout/main/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"net"
88
"sync"
9+
"time"
910
)
1011

1112
type Foo int
@@ -38,6 +39,7 @@ func main() {
3839
client, _ := geerpc.Dial("tcp", <-addr)
3940
defer func() { _ = client.Close() }()
4041

42+
time.Sleep(time.Second)
4143
// send request & receive response
4244
var wg sync.WaitGroup
4345
for i := 0; i < 5; i++ {

gee-rpc/day5-http-debug/main/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net"
88
"net/http"
99
"sync"
10+
"time"
1011
)
1112

1213
type Foo int
@@ -31,6 +32,7 @@ func call(addrCh chan string) {
3132
client, _ := geerpc.DialHTTP("tcp", <-addrCh)
3233
defer func() { _ = client.Close() }()
3334

35+
time.Sleep(time.Second)
3436
// send request & receive response
3537
var wg sync.WaitGroup
3638
for i := 0; i < 5; i++ {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)