{"id":15021739,"url":"https://github.com/drgomesp/go-libp2p-grpc","last_synced_at":"2025-10-15T22:07:23.391Z","repository":{"id":59046381,"uuid":"532549843","full_name":"drgomesp/go-libp2p-grpc","owner":"drgomesp","description":"⚙ gRPC/Protobuf on Libp2p with gRPC-Gateway support","archived":false,"fork":false,"pushed_at":"2023-08-15T01:51:59.000Z","size":16510,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T17:21:23.497Z","etag":null,"topics":["go","go-libp2p","grpc","grpc-go","libp2p","libp2p-gorpc","libp2p-transport"],"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/drgomesp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-04T13:33:05.000Z","updated_at":"2024-08-28T13:23:05.000Z","dependencies_parsed_at":"2024-06-21T16:45:57.978Z","dependency_job_id":null,"html_url":"https://github.com/drgomesp/go-libp2p-grpc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgomesp%2Fgo-libp2p-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgomesp%2Fgo-libp2p-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgomesp%2Fgo-libp2p-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drgomesp%2Fgo-libp2p-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drgomesp","download_url":"https://codeload.github.com/drgomesp/go-libp2p-grpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281424,"owners_count":21077423,"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":["go","go-libp2p","grpc","grpc-go","libp2p","libp2p-gorpc","libp2p-transport"],"created_at":"2024-09-24T19:56:58.178Z","updated_at":"2025-10-15T22:07:18.372Z","avatar_url":"https://github.com/drgomesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-libp2p-grpc\n\n[![madeby](https://img.shields.io/badge/made%20by-%40drgomesp-blue)](https://github.com/drgomesp/)\n[![Go Report Card](https://goreportcard.com/badge/github.com/drgomesp/go-libp2p-grpc)](https://goreportcard.com/report/github.com/drgomesp/go-libp2p-grpc)\n[![build](https://github.com/drgomesp/go-libp2p-grpc/actions/workflows/go-test.yml/badge.svg?style=squared)](https://github.com/drgomesp/go-libp2p-grpc/actions)\n[![codecov](https://codecov.io/gh/drgomesp/go-libp2p-grpc/branch/main/graph/badge.svg?token=BRMFJRJV2X)](https://codecov.io/gh/drgomesp/go-libp2p-grpc)\n\n\u003e ⚙ gRPC/Protobuf on Libp2p with gRPC-Gateway support.\n\n## Table of Contents\n\n- [Install](#install)\n- [Features](#features)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n```bash\ngo get github.com/drgomesp/go-libp2p-grpc\n```\n\n## Features\n\n- [x] **[GRPC/Protobuf](https://grpc.io/docs/languages/go/)** support for any Libp2p **[`host.Host`](https://github.com/libp2p/go-libp2p/blob/master/core/host/host.go#L25)**\n- [x] **[GRPC Gateway](https://grpc-ecosystem.github.io/grpc-gateway/)** and **[OpenAPI/Swagger](https://swagger.io/specification/v2/)** support through **[`go-libp2p-http`](https://github.com/libp2p/)**\n\n## Usage\n\n\n\u003e For a working example with gRPC-gateway support, check the **[examples/](https://github.com/drgomesp/go-libp2p-grpc/tree/main/examples)** folder.\n\nGiven an RPC service:\n\n```proto\nservice EchoService {\n  // Echo asks a node to respond with a message.\n  rpc Echo(EchoRequest) returns (EchoReply) {}\n}\n```\n\n```go\ntype EchoService struct {}\n\nfunc (EchoService) Echo(context.Context, *EchoRequest) (*EchoReply, error) {\n\t...\n}\n```\n\nAnd a libp2p host to act as the server:\n\n```go\nma, _ := multiaddr.NewMultiaddr(\"/ip4/127.0.0.1/tcp/10000\")\n\nserverHost, err := libp2p.New(libp2p.ListenAddrs(ma))\nif err != nil {\n    log.Fatal(err)\n}\ndefer serverHost.Close()\n\nsrv, err := libp2pgrpc.NewGrpcServer(ctx, serverHost)\nif err != nil {\n    log.Fatal(err)\n}\n```\n\nRegister the gRPC service to the host server:\n```go\npb.RegisterEchoServiceServer(srv, \u0026EchoService{})\n```\n\nStart gRPC for serve:\n```go\ngo srv.Serve()\n```\n\nA libp2p host to act as the client:\n```go\nma, _ := multiaddr.NewMultiaddr(\"/ip4/127.0.0.1/tcp/10001\")\n\nclientHost, err := libp2p.New(libp2p.ListenAddrs(ma))\nif err != nil {\n    log.Fatal(err)\n}\n```\n\nDial the server and initiate the request:\n\n```go\nclient := libp2pgrpc.NewClient(cliHost, libp2pgrpc.ProtocolID, libp2pgrpc.WithServer(srv))\nconn, err := client.Dial(ctx, serverHost.ID(), grpc.WithTransportCredentials(insecure.NewCredentials()))\nif err != nil {\nlog.Fatal(err)\n}\ndefer conn.Close()\n\nc := pb.NewEchoServiceClient(conn)\nres, err := c.Echo(ctx, \u0026pb.EchoRequest{Message: \"give me something\"})\n```\n\n## Contributing\n\nPRs accepted.\n\n## License\n\nMIT © [Daniel Ribeiro](https://github.com/drgomesp)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrgomesp%2Fgo-libp2p-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrgomesp%2Fgo-libp2p-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrgomesp%2Fgo-libp2p-grpc/lists"}