(name string, args ...interface{})
| 85 | } |
| 86 | |
| 87 | func (this *ModuleWorkerPool) RpcCall(name string, args ...interface{}) { |
| 88 | var hashkey uint32 = 0 |
| 89 | length := len(name) |
| 90 | if length > 0 { |
| 91 | hashkey += uint32(name[0]) |
| 92 | hashkey += uint32(name[length-1]) |
| 93 | hashkey += uint32(name[(length-1)/2]) |
| 94 | hashkey += uint32(length) |
| 95 | } |
| 96 | m := this.modules[hashkey%this.size] //route the rpc to worker by a simple hash key |
| 97 | m.RpcCall(name, args...) |
| 98 | } |
| 99 | |
| 100 | func (this *ModuleWorkerPool) Balancer() Module { |
| 101 | idx := this.balance_id % this.size |