// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package v1 import pb_v1 "tower-monitor/pb/v1" var snKey map[string]*pb_v1.DeviceInfoReply // 初始化map func Init() { snKey = make(map[string]*pb_v1.DeviceInfoReply) } /* // 获取key func GetKey(sn string) (*pb_v1.DeviceInfoReply, error) { if value, ok := snKey[sn]; ok { return value, nil } reply, err := GetDeviceInfo(sn) if err == nil { snKey[sn] = reply } return reply, err } // 从数据库中获取key func GetDeviceInfo(sn string) (*pb_v1.DeviceInfoReply, error) { req := &pb_v1.DeviceInfoRequest{Sn: sn, DeviceCode: consts.DustDeviceCode} reply, err := pb.SmartAuth.DeviceInfo(context.Background(), req) if err != nil { logger.Error("func", zap.String("call", "DeviceInfo"), zap.String("args", sn), zap.String("error", err.Error())) } return reply, err } */