28 lines
595 B
Go
28 lines
595 B
Go
|
|
package imagesProvider
|
||
|
|
|
||
|
|
import (
|
||
|
|
log "github.com/sirupsen/logrus"
|
||
|
|
"google.golang.org/grpc"
|
||
|
|
"google.golang.org/grpc/credentials/insecure"
|
||
|
|
is "merch-parser-api/proto/imageStorage"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Handler struct{}
|
||
|
|
|
||
|
|
func NewClient(address string) is.ImageStorageClient {
|
||
|
|
var opts []grpc.DialOption
|
||
|
|
insec := grpc.WithTransportCredentials(insecure.NewCredentials())
|
||
|
|
opts = append(opts, insec)
|
||
|
|
|
||
|
|
conn, err := grpc.NewClient(address, opts...)
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
log.WithFields(log.Fields{
|
||
|
|
"address": address,
|
||
|
|
}).Debug("gRPC | API client")
|
||
|
|
|
||
|
|
return is.NewImageStorageClient(conn)
|
||
|
|
}
|