Commit 3a81ddff authored by 张醒狮's avatar 张醒狮

add gitignore file

parent 663098df
.idea
\ No newline at end of file
package client
import (
"context"
"git.zmcms.cn/publicsource/guidon-client/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"time"
)
type ResourceCenterClient struct {
conn *grpc.ClientConn
client pb.ResourceCenterClient
}
func NewResourceCenterClient(addr string) (*ResourceCenterClient, error) {
conn, err := grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
return &ResourceCenterClient{conn: conn, client: pb.NewResourceCenterClient(conn)}, nil
}
func (rc *ResourceCenterClient) Close() error {
return rc.conn.Close()
}
func (rc *ResourceCenterClient) GetOwnership(ctx context.Context, resourceId string) (*pb.OwnershipResponse, error) {
req := &pb.OwnershipRequest{InstanceId: resourceId}
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
defer cancel()
return rc.client.GetOwnership(ctx, req)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment