transport

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	Marshall() ([]byte, error)
	Unmarshall([]byte) error
}

type ReceivedMessage

type ReceivedMessage struct {
	// Message contains the message content. It is nil when the Error field
	// is not nil.
	Message Message
	// Data contains an optional data associated with the message. A type of
	// the data is different depending on a transport implementation.
	Data interface{}
	// Error contains an optional error returned by a transport.
	Error error
}

type Transport

type Transport interface {
	// Subscribe starts subscribing for messages with the given topic.
	// The second argument is a type of a message given as a nil pointer,
	// e.g.: (*Message)(nil).
	Subscribe(topic string, typ Message) error
	// Unsubscribe stops subscribing for messages with the given topic.
	Unsubscribe(topic string) error
	// Broadcast sends a message with the given topic to the network. To send
	// a message, you must first subscribe to appropriate topic.
	Broadcast(topic string, message Message) error
	// WaitFor returns a channel which will be blocked until message for given
	// topic arrives. Note, that only messages for subscribed topics will
	// be supported by this method, for unsubscribed topic nil will be
	// returned. In case of an error, error will be returned in a Status
	// structure.
	WaitFor(topic string) chan ReceivedMessage
	// Close closes connection.
	Close() error
}

Transport is the interface for different implementation of a publish–subscribe messaging solutions for the Oracle network.

Directories

Path Synopsis
p2p

Jump to

Keyboard shortcuts

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