Files
full/module/ec/order/test/rpc/bisic_test.go

29 lines
662 B
Go
Raw Normal View History

package rpc
import (
"context"
"os"
"git.apinb.com/bsm-sdk/core/utils"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
)
var url = "127.0.0.1:12442"
var token = os.Getenv("BSM_ORDER_TOKEN")
func GetCoon() (*grpc.ClientConn, context.Context) {
md := metadata.New(map[string]string{"request_id": utils.UUID(), "workspace": "scf"})
md.Append("authorization", token)
ctx := metadata.NewOutgoingContext(context.Background(), md)
// 建立GRPC连接
conn, err := grpc.NewClient(url, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
panic(err)
}
return conn, ctx
}