messageservice

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package messageservice is a messaging service responsible for routing messages to peers and relaying messages received from peers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

A Broker manages a mapping from identifying address to a TestMessageService, allowing messages sent from one message service to be directed to the intended recipient

func NewBroker

func NewBroker() Broker

type MessageService

type MessageService interface {
	// Out returns a chan for receiving messages from the message service
	Out() <-chan protocols.Message
	// Send is for sending messages with the message service
	Send(protocols.Message) error
	// Close closes the message service
	Close() error
}

type TestMessageService

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

TestMessageService is an implementation of the MessageService interface for use in multi-engine test environments.

It allows for individual nitro nodes / engines to:

  1. be instantiated together via test setup data
  2. "connect" with one another via gochans
  3. run independently in information-silo goroutines, while communicating on the simulated network

func NewTestMessageService

func NewTestMessageService(address types.Address, broker Broker, maxDelay time.Duration) TestMessageService

NewTestMessageService returns a running TestMessageService It accepts an address, a broker, and a max delay for messages. Messages will be handled with a random delay between 0 and maxDelay

func (TestMessageService) Close

func (tms TestMessageService) Close() error

Close stops the TestMessagerService from sending or receiving messages.

func (TestMessageService) HandleMessage

func (tms TestMessageService) HandleMessage(message []byte)

HandleMessage deserialize the message and feed it to the engine

func (TestMessageService) Out

func (t TestMessageService) Out() <-chan protocols.Message

func (TestMessageService) Send

func (tms TestMessageService) Send(msg protocols.Message) error

Send dispatches messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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