{"id":17080388,"url":"https://github.com/allenxuxu/stark","last_synced_at":"2025-03-23T17:31:25.244Z","repository":{"id":38406494,"uuid":"325938959","full_name":"Allenxuxu/stark","owner":"Allenxuxu","description":"Golang 微服务框架，支持 grpc/http，支持多种注册中心 etcd,consul,mdns 等","archived":false,"fork":false,"pushed_at":"2021-12-11T06:25:04.000Z","size":433,"stargazers_count":32,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T22:28:31.893Z","etag":null,"topics":["consul","etcd","go","grpc","grpc-go","http","microservice","microservices","rpc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Allenxuxu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-01T07:53:18.000Z","updated_at":"2024-12-13T14:20:29.000Z","dependencies_parsed_at":"2022-08-31T13:42:24.163Z","dependency_job_id":null,"html_url":"https://github.com/Allenxuxu/stark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Allenxuxu%2Fstark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Allenxuxu%2Fstark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Allenxuxu%2Fstark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Allenxuxu%2Fstark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Allenxuxu","download_url":"https://codeload.github.com/Allenxuxu/stark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245141038,"owners_count":20567496,"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":["consul","etcd","go","grpc","grpc-go","http","microservice","microservices","rpc"],"created_at":"2024-10-14T12:44:12.159Z","updated_at":"2025-03-23T17:31:24.088Z","avatar_url":"https://github.com/Allenxuxu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stark\n\n[![Github Actions](https://github.com/Allenxuxu/gev/workflows/CI/badge.svg)](https://github.com/Allenxuxu/stark/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Allenxuxu/stark)](https://goreportcard.com/report/github.com/Allenxuxu/stark)\n[![LICENSE](https://img.shields.io/badge/LICENSE-MIT-blue)](https://github.com/Allenxuxu/stark/blob/master/LICENSE)\n\n\u003e stark 命名源自漫威 Tony Stark\n\n一个用于构建分布式系统的工具集或者轻框架，支持 grpc 和 http ，支持多种注册中心 consul ，etcd , mdns 等。\n\n## 功能\n\n- 服务发现\n- 负载均衡\n- grpc/http Server 和 Client\n- ...\n\n## stark ctl\n\n```shell\ngo get  github.com/Allenxuxu/stark/cmd/stark\n```\n\n查询注册服务\n\n```shell\nstark service -r consul -rg 127.0.0.1:8500 {service name}\n```\n\n## Example\n\n[grpc server](example/rpc/server/main.go)\n\n```go\nrg, err := mdns.NewRegistry()\nif err != nil {\n    panic(err)\n}\n\ns := stark.NewRPCServer(rg,\n    rpc.Name(\"stark.rpc.test\"),\n    rpc.Version(\"v0.0.1\"),\n)\n\nrs := \u0026routeGuideServer{}\npb.RegisterRouteGuideServer(s.GrpcServer(), rs)\n\nif err := s.Start(); err != nil {\n    panic(err)\n}\n```\n\n```shell\ncd example/rpc/server\ngo run main.go\n```\n\n使用 stark 工具 查看已经注册的服务\n\n```shell\nstark service stark.rpc.test\n```\n\n[grpc client](example/rpc/client/registry)\n\n```go\nrg, err := mdns.NewRegistry()\nif err != nil {\n    panic(err)\n}\n\ns, err := registry.NewSelector(rg,\n    selector.BalancerName(balancer.RoundRobin),\n)\nif err != nil {\n    panic(err)\n}\n\nclient, err := stark.NewRPCClient(\"stark.rpc.test\", s,\n    rpc.GrpcDialOption(\n        grpc.WithInsecure(),\n    ),\n)\nif err != nil {\n    panic(err)\n}\n\nc := routeguide.NewRouteGuideClient(client.Conn())\n\nfor i := 0; i \u003c 10; i++ {\n    resp, err := c.GetFeature(context.Background(), \u0026routeguide.Point{\n        Latitude:  0,\n        Longitude: 0,\n    })\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n[http server](example/rest/server/main.go)\n\n```go\nrg, err := mdns.NewRegistry()\nif err != nil {\n    panic(err)\n}\n\nr := gin.Default()\nr.GET(\"/ping\", func(c *gin.Context) {\n    c.JSON(200, gin.H{\n        \"message\": \"pong\",\n    })\n})\n\ns := stark.NewRestServer(rg, r,\n    rest.Name(\"stark.http.test\"),\n)\n\nif err := s.Start(); err != nil {\n    panic(err)\n}\n```\n\n[http client](example/rest/client/main.go)\n\n```go\nrg, err := mdns.NewRegistry()\nif err != nil {\n    panic(err)\n}\n\ns, err := registry.NewSelector(rg)\nif err != nil {\n    panic(err)\n}\n\nc, err := stark.NewRestClient(\"stark.http.test\", s)\nif err != nil {\n    panic(err)\n}\n\nfor i := 0; i \u003c 5; i++ {\n    r, err := c.Request()\n    if err != nil {\n        panic(err)\n    }\n\n    resp, err := r.Get(\"/ping\")\n    if err != nil {\n        panic(err)\n    }\n\n    log.Info(resp)\n}\n```\n\n## 感谢\n\n[go-micro](https://github.com/asim/go-micro) \n本项目就是受到 go-micro 的启发而来，本意就是构建一个比 go-micro 更加轻量，够用就好的微服务框架。\n项目中 config，registry 都是从 go-micro v1.18 改造而来。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenxuxu%2Fstark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallenxuxu%2Fstark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenxuxu%2Fstark/lists"}