net

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeNewBlock = "NewBlockMessage"
)

MessageTypeNewBlock

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher a message dispatcher service.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher create Dispatcher instance.

func (*Dispatcher) Deregister

func (dp *Dispatcher) Deregister(subscribers ...*Subscriber)

Deregister deregister subscribers.

func (*Dispatcher) PutMessage

func (dp *Dispatcher) PutMessage(msg Message)

PutMessage put new message to chan, then subscribers will be notified to process.

func (*Dispatcher) Register

func (dp *Dispatcher) Register(subscribers ...*Subscriber)

Register register subscribers.

func (*Dispatcher) Start

func (dp *Dispatcher) Start()

Start start message dispatch goroutine.

func (*Dispatcher) Stop

func (dp *Dispatcher) Stop()

Stop stop goroutine.

type DummyManager

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

DummyManager support dummy mode

func NewDummyManager

func NewDummyManager(sharedBlockCh chan interface{}) *DummyManager

NewDummyManager create DummyManager instance.

func (*DummyManager) BroadcastBlock

func (nm *DummyManager) BroadcastBlock(block interface{})

BroadcastBlock broadcast block to network.

func (*DummyManager) Deregister

func (nm *DummyManager) Deregister(subscribers ...*Subscriber)

Deregister Deregister the subscribers.

func (*DummyManager) PutMessage

func (nm *DummyManager) PutMessage(msg Message)

PutMessage put message to dispatcher.

func (*DummyManager) Register

func (nm *DummyManager) Register(subscribers ...*Subscriber)

Register register the subscribers.

func (*DummyManager) Start

func (nm *DummyManager) Start()

Start start net services.

func (*DummyManager) Stop

func (nm *DummyManager) Stop()

Stop stop net services.

type Manager

type Manager interface {
	Start()
	Stop()

	Register(subscribers ...*Subscriber)
	Deregister(subscribers ...*Subscriber)

	BroadcastBlock(block interface{})
}

Manager manager interface

type Message

type Message interface {
	MessageType() MessageType
	Data() interface{}
}

Message interface for message.

type MessageType

type MessageType string

MessageType a string for message type.

type Subscriber

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

Subscriber subscriber.

func NewSubscriber

func NewSubscriber(id interface{}, msgChan chan Message, msgTypes ...MessageType) *Subscriber

NewSubscriber return new Subscriber instance.

func (*Subscriber) ID

func (s *Subscriber) ID() interface{}

ID return id.

func (*Subscriber) MessageChan

func (s *Subscriber) MessageChan() chan Message

MessageChan return msgChan.

func (*Subscriber) MessageType

func (s *Subscriber) MessageType() []MessageType

MessageType return msgTypes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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