MCPcopy Create free account
hub / github.com/LockGit/gochat / GetRpcClientByServerId

Method GetRpcClientByServerId

task/rpc.go:42–57  ·  view source on GitHub ↗
(serverId string)

Source from the content-addressed store, hash-verified

40}
41
42func (rc *RpcConnectClient) GetRpcClientByServerId(serverId string) (c client.XClient, err error) {
43 rc.lock.Lock()
44 defer rc.lock.Unlock()
45 if _, ok := rc.ServerInsMap[serverId]; !ok || len(rc.ServerInsMap[serverId]) <= 0 {
46 return nil, errors.New("no connect layer ip:" + serverId)
47 }
48 if _, ok := rc.IndexMap[serverId]; !ok {
49 rc.IndexMap = map[string]int{
50 serverId: 0,
51 }
52 }
53 idx := rc.IndexMap[serverId] % len(rc.ServerInsMap[serverId])
54 ins := rc.ServerInsMap[serverId][idx]
55 rc.IndexMap[serverId] = (rc.IndexMap[serverId] + 1) % len(rc.ServerInsMap[serverId])
56 return ins.Client, nil
57}
58
59func (rc *RpcConnectClient) GetAllConnectTypeRpcClient() (rpcClientList []client.XClient) {
60 for serverId, _ := range rc.ServerInsMap {

Callers 2

pushSingleToConnectMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected