pubsubgrpc

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-libp2p-pubsub-grpc (pubsubgrpc)

pubsubgrpc provides a LibP2P PubSub framework that can be used as a stand-alone gRPC pubsub server and API, or as a module/component of existing gRPC servers to provide LibP2P PubSub functionality. It uses proto3 and borrows some ideas from libp2p/go-libp2p-daemon and libp2p/go-libp2p-pubsub.

usage

There are two ways of using this library:

  1. One is to construct a standalone pubsub server with a gRPC api (see server.go)
  2. Provide pubsub functionality to already existing gRPC servers (see pubsubgrpc.go)

If using the standalone pubsub server, there is a golang client in client.go that can be used.

todo:

  • once go-libp2p-pubsub has discovery, use it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(ctx context.Context, wg *sync.WaitGroup, service Service, protocol, url string, serverOpts ...grpc.ServerOption) error

NewServer is used to intiialize a pubsub grpc server and run it

Types

type Client

type Client struct {
	pb.PubSubServiceClient
	// contains filtered or unexported fields
}

Client is used to communicate with the gRPC Server service

func NewClient

func NewClient(certPath, authKey, url string) (*Client, error)

NewClient is used to instantiate a pubsub grpc client

func (*Client) Close

func (c *Client) Close() error

Close is used to terminate our connection to the grpc server

type Server

type Server struct {
	Service
}

Server is used to run the libp2p pubsub grpc server it enables communicating pubsub messages over grpc

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a libp2p pubsub service component

func NewService

func NewService(
	ps *ps.PubSub,
	sd *discovery.RoutingDiscovery,
	h host.Host,
	l *zap.SugaredLogger,
) Service

NewService creates and returns a new libp2p pubsub service

func (*Service) GetTopics

func (s *Service) GetTopics(ctx context.Context, req *pb.Empty) (*pb.TopicsResponse, error)

GetTopics is used to return a list of all known topics the pubsub instance is subscribed to.

func (*Service) ListPeers

func (s *Service) ListPeers(ctx context.Context, req *pb.ListPeersRequest) (*pb.ListPeersResponse, error)

ListPeers is used to return a list of peers subscribed to a given topic or topics

func (*Service) Publish

func (s *Service) Publish(stream pb.PubSubService_PublishServer) error

Publish is used to send a stream of messages to a pubsub topic.

func (*Service) Subscribe

func (s *Service) Subscribe(req *pb.SubscribeRequest, stream pb.PubSubService_SubscribeServer) error

Subscribe is used to subscribe to a topic and receive messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL