{"id":18877135,"url":"https://github.com/trpc-ecosystem/go-naming-consul","last_synced_at":"2025-08-08T20:10:40.418Z","repository":{"id":200695977,"uuid":"701648176","full_name":"trpc-ecosystem/go-naming-consul","owner":"trpc-ecosystem","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-24T12:07:21.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-03T23:04:43.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trpc-ecosystem.png","metadata":{"files":{"readme":"README.zh_CN.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-07T06:45:51.000Z","updated_at":"2024-12-01T06:47:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"23756a23-95da-413c-bf1e-33800ca21ff3","html_url":"https://github.com/trpc-ecosystem/go-naming-consul","commit_stats":null,"previous_names":["trpc-ecosystem/go-naming-consul"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trpc-ecosystem%2Fgo-naming-consul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trpc-ecosystem%2Fgo-naming-consul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trpc-ecosystem%2Fgo-naming-consul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trpc-ecosystem%2Fgo-naming-consul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trpc-ecosystem","download_url":"https://codeload.github.com/trpc-ecosystem/go-naming-consul/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239832981,"owners_count":19704617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T06:17:05.305Z","updated_at":"2025-08-08T20:10:40.406Z","avatar_url":"https://github.com/trpc-ecosystem.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tRPC Consul 名字服务\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/trpc-ecosystem/go-naming-consul.svg)](https://pkg.go.dev/github.com/trpc-ecosystem/go-naming-consul)\n[![Go Report Card](https://goreportcard.com/badge/github.com/trpc.group/trpc-go/trpc-naming-consul)](https://goreportcard.com/report/github.com/trpc.group/trpc-go/trpc-naming-consul)\n[![LICENSE](https://img.shields.io/github/license/trpc-ecosystem/go-naming-consul.svg?style=flat-square)](https://github.com/trpc-ecosystem/go-naming-consul/blob/main/LICENSE)\n[![Releases](https://img.shields.io/github/release/trpc-ecosystem/go-naming-consul.svg?style=flat-square)](https://github.com/trpc-ecosystem/go-naming-consul/releases)\n[![Docs](https://img.shields.io/badge/docs-latest-green)](http://test.trpc.group.woa.com/docs/)\n[![Tests](https://github.com/trpc-ecosystem/go-naming-consul/actions/workflows/prc.yaml/badge.svg)](https://github.com/trpc-ecosystem/go-naming-consul/actions/workflows/prc.yaml)\n[![Coverage](https://codecov.io/gh/trpc-ecosystem/go-naming-consul/branch/main/graph/badge.svg)](https://app.codecov.io/gh/trpc-ecosystem/go-naming-consul/tree/main)\n\n## 关于 consul\n\n见 [HashiCorp - Consul](https://www.consul.io/) \n\n## 示例\n配置：\n```yaml\nplugins:\n  naming:\n    consul:\n      address: dev.cloud.com:8500\n      services:\n        - trpc.test.helloworld.Greeter  # 一定要与 trpc service 相同\n      register:  #  默认注册配置，上面的 services 会使用\n        interval: 1s\n        timeout: 1s\n        tags:\n          - test\n        meta:\n          appid: 1\n        weight: 10\n        deregister_critical_service_after: 10m\n      services_register:  # 独立注册配置，不同服务可以有不同配置\n        - service: trpc.test.helloworld.Greeter  # 一定要与 trpc service 相同\n          register:  #  默认注册配置，上面的 services 会使用\n            interval: 1s\n            timeout: 1s\n            tags:\n              - test\n            meta:\n              appid: 1\n            weight: 10\n            deregister_critical_service_after: 10m\n      selector:\n        loadBalancer: random\n\nclient:  # 客户端调用的后端配置\n  service:  # 针对单个后端的配置\n    - callee: trpc.test.helloworld.Greeter  # 后端服务协议文件的 service name, 如何 callee 和下面的 name 一样，那只需要配置一个即可\n      target: consul://trpc.test.helloworld.Greeter  # 后端服务地址 consul\n      network: tcp  # 后端服务的网络类型 tcp udp\n      protocol: http  # 应用层协议 trpc http\n      timeout: 10000  # 请求最长处理时间\n      serialization: 2  # 序列化方式 0-pb 2-json 3-flatbuffer，默认不要配置\n\n```\n\nmain 入口：\n```go\npackage main\n\nimport (\n  trpc  \"trpc.group/trpc-go/trpc-go\"\n    \"trpc.group/trpc-go/trpc-go/server\"\n    _ \"trpc.group/trpc-go/trpc-naming-consul\"\n)\n\nfunc main() {\n    s := trpc.NewServer()\n    // do sth ...\n    \n    s.Serve()\n}\n```\n\n## Copyright\n\nThe copyright notice pertaining to the Tencent code in this repo was previously in the name of “THL A29 Limited.”  That entity has now been de-registered.  You should treat all previously distributed copies of the code as if the copyright notice was in the name of “Tencent.”\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrpc-ecosystem%2Fgo-naming-consul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrpc-ecosystem%2Fgo-naming-consul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrpc-ecosystem%2Fgo-naming-consul/lists"}