proxy.golang.org : github.com/plexsysio/go-libp2p-genrpc
Package genrpc is heavily inspired by the go-libp2p-gorpc package. It tries to provide a similar API to the go-libp2p-gorpc package, but with the use of generics. With generics we can provide a more type-safe API. Aim was to see if we can use generics to remove all the reflection code and still provide a similar API. The result is a bit more verbose, but it is type-safe. The API is also a bit different, but it is still easy to use and inspired by the net/http package. Differences with go-libp2p-gorpc: Users have to write the methods and register them with the server. Each method can be registered with a different path. The path is used to register the handler. The path can be a method name or a path describing the method. Each type of RPC has a specific signature. The method and object types dont need to be exported. Only the exported fields in the object are sent in the message. It uses msgpack for serialization, so go structs with exported fields can be used. The method can return an error. The error is sent back to the client as a response. Streams are mapped to channels. Closing the channel will close the stream. Corresponding to each RPC, there is a client method. The client method takes the same arguments as the server method. On the client side as well, streams are mapped to channels. Closing the channel will close the stream. Only thing required to start the server or client is a libp2p host. The server and client will use the host to start listening and dialing. Typical workflow: On the client side: The peer address information should be added to the Peerstore of the host prior to executing the request. Check examples for more details.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/plexsysio/go-libp2p-genrpc
License: BSD-3-Clause
Latest release: over 1 year ago
First release: about 2 years ago
Namespace: github.com/plexsysio
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 16 days ago