Skip to content

Commit

Permalink
fix: 新增注解
Browse files Browse the repository at this point in the history
  • Loading branch information
googs1025 committed Mar 12, 2024
1 parent 6b5e01a commit da201cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions other/loadbalance-pattern/loadbalance/interface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package loadbalance

// LoadBalance 负载均衡代理接口
type LoadBalance interface {
// SetBackendServer 设置后端 server
SetBackendServer(backend []string)
// Run 启动反向代理
Run(addr string)
}
3 changes: 3 additions & 0 deletions other/loadbalance-pattern/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

func main() {

// 模拟后端存储
go server1()
go server2()
go server3()
Expand All @@ -17,9 +18,11 @@ func main() {
"http://localhost:8083",
}

// 随机模式
//rl := random.NewLoadBalancerForRandomMode()
//rl.SetBackendServer(backends)

// 轮询模式
rl := round.NewLoadBalancerForRoundRobinMode()
rl.SetBackendServer(backends)
rl.Run(":8080")
Expand Down

0 comments on commit da201cd

Please sign in to comment.