messagebus

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package messagebus routes messages (contract calls & responses) and delivers'em to relevant modules.

Usage:

TODO:

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoReply is returned from player when there is no stored reply for provided message.
	ErrNoReply = errors.New("no such reply")
)

Functions

func GetMessageHash added in v0.6.3

func GetMessageHash(scheme core.PlatformCryptographyScheme, msg core.Parcel) []byte

GetMessageHash calculates message hash.

func NewParcelFactory added in v0.6.3

func NewParcelFactory() message.ParcelFactory

func NewTape added in v0.6.3

func NewTape(ls core.LocalStorage, pulse core.PulseNumber) (*storageTape, error)

NewTape creates new storageTape with random id.

func NewTapeFromReader added in v0.6.3

func NewTapeFromReader(ctx context.Context, ls core.LocalStorage, r io.Reader) (*storageTape, error)

NewTapeFromReader creates and fills a new storageTape from a stream.

This is a very long operation, as it saves replies in storage until the stream is exhausted.

Types

type MessageBus

type MessageBus struct {
	Service                    core.Network                    `inject:""`
	JetCoordinator             core.JetCoordinator             `inject:""`
	LocalStorage               core.LocalStorage               `inject:""`
	PulseManager               core.PulseManager               `inject:""`
	ActiveNodes                core.NodeNetwork                `inject:""`
	PlatformCryptographyScheme core.PlatformCryptographyScheme `inject:""`
	CryptographyService        core.CryptographyService        `inject:""`
	DelegationTokenFactory     core.DelegationTokenFactory     `inject:""`
	ParcelFactory              message.ParcelFactory           `inject:""`
	// contains filtered or unexported fields
}

MessageBus is component that routes application logic requests, e.g. glue between network and logic runner

func NewMessageBus

func NewMessageBus(config configuration.Configuration) (*MessageBus, error)

NewMessageBus creates plain MessageBus instance. It can be used to create Player and Recorder instances that wrap it, providing additional functionality.

func (*MessageBus) Acquire added in v0.6.3

func (mb *MessageBus) Acquire(ctx context.Context)

func (*MessageBus) CreateParcel added in v0.6.3

func (mb *MessageBus) CreateParcel(ctx context.Context, msg core.Message, token core.DelegationToken) (core.Parcel, error)

CreateParcel creates signed message from provided message.

func (*MessageBus) MustRegister added in v0.5.0

func (mb *MessageBus) MustRegister(p core.MessageType, handler core.MessageHandler)

MustRegister is a Register wrapper that panics if an error was returned.

func (*MessageBus) NewPlayer added in v0.6.3

func (mb *MessageBus) NewPlayer(ctx context.Context, r io.Reader) (core.MessageBus, error)

NewPlayer creates a new player from stream. This is a very long operation, as it saves replies in storage until the stream is exhausted.

Player can be created from MessageBus and passed as MessageBus instance.

func (*MessageBus) NewRecorder added in v0.6.3

func (mb *MessageBus) NewRecorder(ctx context.Context) (core.MessageBus, error)

NewRecorder creates a new recorder with unique tape that can be used to store message replies.

Recorder can be created from MessageBus and passed as MessageBus instance.

func (*MessageBus) Register

func (mb *MessageBus) Register(p core.MessageType, handler core.MessageHandler) error

Register sets a function as a handler for particular message type, only one handler per type is allowed

func (*MessageBus) Release added in v0.6.3

func (mb *MessageBus) Release(ctx context.Context)

func (*MessageBus) Send

Send an `Message` and get a `Value` or error from remote host.

func (*MessageBus) SendParcel added in v0.6.3

func (mb *MessageBus) SendParcel(ctx context.Context, parcel core.Parcel, options *core.MessageSendOptions) (core.Reply, error)

SendParcel sends provided message via network.

func (*MessageBus) Start

func (mb *MessageBus) Start(ctx context.Context) error

Start initializes message bus.

func (*MessageBus) Stop

func (mb *MessageBus) Stop(ctx context.Context) error

Stop releases resources and stops the bus

func (*MessageBus) WriteTape added in v0.6.3

func (mb *MessageBus) WriteTape(ctx context.Context, writer io.Writer) error

WriteTape for MessageBus is not available.

Jump to

Keyboard shortcuts

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