services

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisServer

func NewRedisServer(host, port, pubChannel, subChannel string) *redisServer

Types

type Connection

type Connection struct {
	Events chan *message.Event
	// contains filtered or unexported fields
}

Connection holds the live communication between peers Events are sent to/from peers

func Subscribe

func Subscribe(ctx context.Context, redis *redisServer, ps *pubsub.PubSub, meID peer.ID, topicName string, signKey ed25519.PrivateKey) (*Connection, error)

Subscribe tries to subscribe to the PubSub topic to initiate a connection, Connection is returned on success.

func (*Connection) ListPeers

func (conn *Connection) ListPeers() []peer.ID

func (*Connection) ListenEvents

func (conn *Connection) ListenEvents() error

func (*Connection) Publish

func (conn *Connection) Publish(ev *message.Event) error

Publish sends a event to peer.

type Message

type Message struct {
	Message string
	Sender  string
}

Message gets converted to/from JSON and sent in the body of pubsub messages.

Jump to

Keyboard shortcuts

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