Beispiel #1
0
func (r *PushRpcs) Init() (err error) {
	r.Config = Conf.Server.RpcPush
	r.pushRpc = make([]*PushRpc, 0)
	for _, node := range r.Config {
		rpc := NewPushRpc()
		if err = rpc.Init(node); err != nil {
			log.Errorf("init push rpc failed : %v", err)
			panic(err)
		} else {
			r.pushRpc = append(r.pushRpc, rpc)
		}
	}
	// if len(r.pushRpc) == 0 {
	// 	log.Errorln(r.Config)
	// 	return ErrPushRpc
	// }
	return nil
}
Beispiel #2
0
func (r *PushRpcs) UpdateConfig() {
	var err error
	config := Conf.Server.RpcPush
	pushrpc := make([]*PushRpc, 0)
	for _, node := range config {
		rpc := NewPushRpc()
		if err = rpc.Init(node); err != nil {
			continue
		} else {
			pushrpc = append(pushrpc, rpc)
		}
	}
	if err == nil && len(pushrpc) != 0 {
		for _, rpc := range r.pushRpc {
			rpc.Close()
		}
		r.Config = config
		r.pushRpc = pushrpc
	} else {
		log.Fatalf("push rpc update config failed")
	}
}