Updated Handler
This commit is contained in:
parent
3a5166eece
commit
eddda81fcf
1 changed files with 9 additions and 9 deletions
|
|
@ -18,26 +18,26 @@ func createConnection() *grpc.ClientConn{
|
|||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
return conn
|
||||
}
|
||||
|
||||
func createRegistryClient() (proto.LpmRegistryClient, context.Context){
|
||||
func createRegistryClient(conn *grpc.ClientConn) (proto.LpmRegistryClient, context.Context, context.CancelFunc){
|
||||
|
||||
lrc := proto.NewLpmRegistryClient(createConnection())
|
||||
lrc := proto.NewLpmRegistryClient(conn)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second * 10)
|
||||
|
||||
defer cancel()
|
||||
|
||||
return lrc, ctx
|
||||
return lrc, ctx, cancel
|
||||
}
|
||||
|
||||
func SearchPackages(platform string, architecture []string, query string) []PackageMetadata {
|
||||
|
||||
logger := Lotus.DetailedLogger("ProtoHandler", "sendSearchRequest")
|
||||
|
||||
client, ctx := createRegistryClient()
|
||||
conn := createConnection()
|
||||
defer conn.Close()
|
||||
|
||||
client, ctx, cancel := createRegistryClient(conn)
|
||||
defer cancel()
|
||||
|
||||
res, connErr := client.Search(ctx, &proto.SearchRequest{Platform: platform, Architecture: architecture, Query: query})
|
||||
if connErr != nil{
|
||||
logger.Fatal(connErr)
|
||||
|
|
|
|||
Reference in a new issue