new image provider
This commit is contained in:
parent
a3fbd3b8e0
commit
fa8990ed8c
1 changed files with 27 additions and 0 deletions
27
internal/imagesProvider/handler.go
Normal file
27
internal/imagesProvider/handler.go
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
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)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue