// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package impl import ( "context" "smart-alarm/impl/v1/monitor" "smart-alarm/pb" "smart-alarm/pb/v1" "github.com/jaryhe/gopkgs/tasker/rpctasker" "google.golang.org/grpc" ) // 具体实现 type Rcvr struct { } func Register(s *grpc.Server) { pb.RegisterSmartAlarmServer(s, &Rcvr{}) } func (c *Rcvr) AlarmAdd(ctx context.Context, req *v1.AlarmAddRequest) (reply *v1.AlarmAddReply, err error) { t1 := func() error { reply, err = monitor.AlarmAdd(ctx, req) return err } return reply, rpctasker.Exec(ctx, t1) }