1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package sso
- import (
- "context"
- "eta/eta_mini_crm_ht/rpc"
- "eta/eta_mini_crm_ht/utils"
- "fmt"
- "sync"
- )
- var (
- once sync.Once
- rpcPool utils.ClientPool
- SSOServiceImpl *SSOService
- )
- type SSOService struct {
- ssoRPCService
- }
- type ssoRPCService struct {
- rpc.DefaultRpcClient
- }
- func GetSSOService() *SSOService {
- once.Do(func() {
- c := ssoRPCService{}
- rpcPool = c.GetPool(utils.SSO_URL)
- SSOServiceImpl = &SSOService{c}
- })
- return SSOServiceImpl
- }
- func (s *SSOService) SSOLogin(request *LoginRequest) {
- conn := rpcPool.Get()
- defer rpcPool.Put(conn)
- ssoLoginService := NewSSOLoginClient(conn)
- s.WrapSign(request, func(ctx context.Context, request interface{}) (err error) {
- loginReq := request.(*LoginRequest)
- rep, err := ssoLoginService.Login(ctx, loginReq)
- if err != nil {
- fmt.Printf("rpc error: %v", err)
- } else {
- fmt.Printf("rpc result: %v", rep)
- }
- return
- })
- }
|