You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
package message |
|
|
|
import ( |
|
"context" |
|
v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/message/v1" |
|
k8s_client "git.gz.internal.jumaiyx.cn/pkg/k8s-client" |
|
"git.gz.internal.jumaiyx.cn/pkg/kubediscovery" |
|
"git.gz.internal.jumaiyx.cn/pkg/log" |
|
"github.com/go-kratos/kratos/v2/transport/grpc" |
|
) |
|
|
|
func NewMessageClient(logger log.Logger) v1.MessageClient { |
|
ctx := context.Background() |
|
discovery, err := kubediscovery.Discovery(ctx, logger, "message-service", kubediscovery.Namespace(k8s_client.DevNamespace)) |
|
|
|
if err != nil { |
|
logger.Errorf("user profile link failed:%v", err) |
|
return nil |
|
} |
|
|
|
client := v1.NewMessageClient(discovery) |
|
return client |
|
} |
|
|
|
func NewMessageTest(ctx context.Context, logger log.Logger) v1.MessageClient { |
|
conn, err := grpc.DialInsecure( |
|
context.Background(), |
|
grpc.WithEndpoint("127.0.0.1:9001"), |
|
) |
|
if err != nil { |
|
logger.Errorf("user profile link failed:%v", err) |
|
} |
|
client := v1.NewMessageClient(conn) |
|
return client |
|
} |
|
|
|
func NewMessageT(ctx context.Context, logger log.Logger) v1.MessageClient { |
|
discovery, err := kubediscovery.Discovery(ctx, logger, "message-service", kubediscovery.Namespace(k8s_client.DevNamespace)) |
|
if err != nil { |
|
logger.Errorf("user profile link failed:%v", err) |
|
} |
|
|
|
if err != nil { |
|
logger.Errorf("user profile link failed:%v", err) |
|
return nil |
|
} |
|
|
|
client := v1.NewMessageClient(discovery) |
|
return client |
|
}
|
|
|