feat: import services and standardize Go 1.26.5
This commit is contained in:
27
apps/ec/delivery/test/rpc/basic.go
Normal file
27
apps/ec/delivery/test/rpc/basic.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"git.apinb.com/bsm-sdk/engine/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var url = "127.0.0.1:12264"
|
||||
|
||||
var token = os.Getenv("BSM_DELIVERY_TOKEN")
|
||||
|
||||
func GetCoon() (*grpc.ClientConn, context.Context) {
|
||||
md := metadata.New(map[string]string{"request_id": utils.ULID(), "workspace": "scf"})
|
||||
md.Append("authorization", token)
|
||||
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||
// 建立GRPC连接
|
||||
conn, err := grpc.Dial(url, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return conn, ctx
|
||||
}
|
||||
Reference in New Issue
Block a user