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

单进程多服务要怎么配置 #19

Open
manchurio opened this issue Feb 7, 2024 · 1 comment
Open

单进程多服务要怎么配置 #19

manchurio opened this issue Feb 7, 2024 · 1 comment

Comments

@manchurio
Copy link

manchurio commented Feb 7, 2024

如题,  在单进程多服务的时候, 配置文件tpc_go.yaml 
server/service 配置一个就可以, 但是在配置polaris插件registery的service要配置多个, 
server:
  service:
    - name: trpc.helloworld #单进程多服务,这里我也只需要配置一个, 共用一个端口
      ip: 127.0.0.1
      port: 8001


plugins: #  
  registry:  
    polarismesh:  
      register_self: true  
      heartbeat_interval: 3000   
      address_list: "10.100.1.15:8091"
      debug: true  
      instance_location:  
        region: China
        zone: Guangdong
        campus: Shenzhen
      service: 
        - name: trpc.helloworld # 这里的name要和上面的name对应, 单进程有多个服务的时候这里要怎么配置
          namespace: ns-dev1   
          token: xxxxxxxxxxxxxxxxxxxx  
      config.
          instance_id: yyyyyyyyyyyyyyyy
          weight: 100 
@tocrafty
Copy link
Contributor

Every yaml.plugins.registry.polarismesh.service[i].name should equal to a corresponding yaml.server.service[i].name. This is how yaml.plugins.registry.polarismesh.register_self works.
Here, you have only one yaml.server.service to reuse the single port for every services, thus, you must have only one plugins.registry.polarismesh.service.
When calling a service, pay attention to yaml.client.service[i].name and yaml.client.service[i].callee on client side. Client name must match the serveryaml.plugins.registry.service[i].name to find ip:8001 of polaris service trpc.helloworld. Client callee must match the one in generated xxx.trpc.pb.go, such as this.
In a typical scenario where each service has its own port, you don't need to warry about client name and callee. This is because naming service is equal to pb service and client name and callee are backed up to each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants