Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于客户端的address配置问题 #762

Open
sanyecao-w opened this issue Oct 9, 2022 · 4 comments
Open

关于客户端的address配置问题 #762

sanyecao-w opened this issue Oct 9, 2022 · 4 comments
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage

Comments

@sanyecao-w
Copy link

你好,目前推荐的客户端配置服务器地址是通过application.yml方式配置,如果我不想通过这种方式(因为我使用grpc client构建了一个jar包,提供给其他的应用使用,不想每个引用该jar包的系统都做address的配置,想在代码中写死),还有其他的方式可以设置目标服务的adress吗

@sanyecao-w sanyecao-w added the question A question about this library or its usage label Oct 9, 2022
@ST-DDT
Copy link
Collaborator

ST-DDT commented Oct 9, 2022

English


You can set the address directly in the client configuration. Just inject GrpcChannelsProperties and set the address there before making the first call.

@hiyoungman
Copy link

use command line argument
such as:
-Dserver.port=8080

@ST-DDT ST-DDT added the feedback required Information are missing or feedback for suggestions is requested label Nov 17, 2022
@simbel
Copy link

simbel commented Apr 7, 2023

English

You can set the address directly in the client configuration. Just inject GrpcChannelsProperties and set the address there before making the first call.

Could you please provide some codes to demo how to do it? A more complex case is: the client project may import multiple grpc clients at the same time. Each client's initialization config should not bother others. tks

@ST-DDT
Copy link
Collaborator

ST-DDT commented Apr 7, 2023

Could you please provide some codes to demo how to do it?

@Autowired
GrpcChannelsProperties clientProperties;

@PostConstruct
void init() {
    // Must be before the very first call
    clientProperties.getClient("test").setAddress("...");
}

A more complex case is: the client project may import multiple grpc clients at the same time. Each client's initialization config should not bother others.

Currently it is not possible to dynamically inject clients, but you can still create the clients yourself for now using the same approach as above (with unique client names of course).

See also https://github.com/yidongnan/grpc-spring-boot-starter/issues/741#issuecomment-1247148603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

4 participants