transport

package
v0.22.6 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReceivedMessageFields added in v0.13.5

func ReceivedMessageFields(p ReceivedMessage) log.Fields

Types

type AppInfo added in v0.15.2

type AppInfo struct {
	Name    string `json:"-"`
	Version string `json:"-"`
}

func (*AppInfo) GetAppInfo added in v0.15.2

func (a *AppInfo) GetAppInfo() AppInfo

func (*AppInfo) SetAppInfo added in v0.15.2

func (a *AppInfo) SetAppInfo(info AppInfo)

type Message

type Message interface {
	// MarshallBinary serializes the message into a byte slice.
	MarshallBinary() ([]byte, error)

	// UnmarshallBinary deserializes the message from a byte slice.
	UnmarshallBinary([]byte) error
}

Message is a message that can be sent over transport.

type Meta added in v0.11.0

type Meta struct {
	Transport            string `json:"transport"`
	Topic                string `json:"topic"`
	MessageID            string `json:"message_id"`
	PeerID               string `json:"peer_id"`
	PeerAddr             string `json:"peer_addr"`
	ReceivedFromPeerID   string `json:"received_from_peer_id"`
	ReceivedFromPeerAddr string `json:"received_from_peer_addr"`
	UserAgent            string `json:"user_agent"`
}

type ReceivedMessage

type ReceivedMessage struct {
	// Message contains the message content. It is nil when the Error field
	// is not nil.
	Message Message

	// Author is the author of the message.
	Author []byte

	// Data contains an optional data associated with the message. A type of
	// the data is different depending on a transport implementation.
	Data any

	// Error contains an optional error returned by transport layer.
	Error error

	// Meta contains optional information about the message.
	Meta Meta
}

ReceivedMessage contains a Message received from Transport.

func (ReceivedMessage) MarshalJSON added in v0.20.0

func (p ReceivedMessage) MarshalJSON() ([]byte, error)

type Service added in v0.11.0

type Service interface {
	supervisor.Service
	Transport
}

Service implements a mechanism for exchanging messages between Oracles.

type Transport

type Transport interface {
	// Broadcast sends a message with a given topic.
	Broadcast(topic string, message Message) error

	// Messages returns a channel for incoming messages. A new channel is
	// created for each call, therefore this method should not be used in
	// loops. In case of an error, an error will be returned in the
	// ReceivedMessage structure.
	Messages(topic string) <-chan ReceivedMessage
}

type WithAppInfo added in v0.15.2

type WithAppInfo interface {
	Message
	SetAppInfo(info AppInfo)
	GetAppInfo() AppInfo
}

Directories

Path Synopsis
pb
pb

Jump to

Keyboard shortcuts

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