29 lines
552 B
Go
29 lines
552 B
Go
package wecomrpc
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"lone-services/pkg/rpcclient"
|
|
"lone-services/pkg/utils"
|
|
wecompb "lone-services/rpc/wecom/pb"
|
|
)
|
|
|
|
func getClient(wecomSvcName string) (wecompb.WecomClient, error) {
|
|
if wecomSvcName == utils.StringEmpty {
|
|
return nil, fmt.Errorf("services.wecom empty")
|
|
}
|
|
cli, err := rpcclient.Get(wecomSvcName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return wecompb.NewWecomClient(cli.Conn()), nil
|
|
}
|
|
|
|
func ensureCtx(ctx context.Context) context.Context {
|
|
if ctx == nil {
|
|
return context.Background()
|
|
}
|
|
return ctx
|
|
}
|