auth provider
This commit is contained in:
parent
08d8450dac
commit
a66873d12d
6 changed files with 432 additions and 0 deletions
40
pkg/authCheck/handler.go
Normal file
40
pkg/authCheck/handler.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package authCheck
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
verifyV1 "merch-api/pkg/verify/v1"
|
||||
"time"
|
||||
)
|
||||
|
||||
const pkgLogHeader string = "Remote session checker |"
|
||||
|
||||
type Handler struct {
|
||||
client verifyV1.AuthServiceClient
|
||||
*service
|
||||
}
|
||||
|
||||
type Deps struct {
|
||||
Addr string
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
func New(deps Deps) *Handler {
|
||||
var opts []grpc.DialOption
|
||||
insec := grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
opts = append(opts, insec)
|
||||
|
||||
conn, err := grpc.NewClient(deps.Addr, opts...)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatalf("%v grpc connection failed", pkgLogHeader)
|
||||
}
|
||||
|
||||
client := verifyV1.NewAuthServiceClient(conn)
|
||||
log.WithField("address", deps.Addr).Debugf("%v client", pkgLogHeader)
|
||||
|
||||
return &Handler{
|
||||
client: client,
|
||||
service: newService(client, deps.Timeout),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue