transports

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: AGPL-3.0 Imports: 0 Imported by: 2

README

transport module

Wraps multiple messaging/communication protocols in a common interface intended to facilitate flexible stream processing.

type Transport interface {
	
  // Init initializes the transport layer. Takes a transports.Connection type with a set of common options. 
  // Not all options must have effect.
	Init(c *Connection) error
  
	// ConnectionType returns the human readable name for the transport layer.
  ConnectionType() string
  
	// Listen starts and keeps listening for new messages, takes a channel where new messages will be written.
  Listen(reciever chan<- Message)
  
	// Send outputs a new message to the connection of MessageContext.
	// The package implementing this interface must also implement its own transports.MessageContext.
  Send(msg Message) error
  
	// SendUnicast outputs a new message to a specific connection identified by address.
  // This method only makes sense on p2p transports.
  SendUnicast(address string, msg Message) error
  
	// AddNamespace creates a new namespace for writing handlers. On HTTP namespace is usually the URL route.
  AddNamespace(namespace string) error
  
	// Address returns an string containing the transport own address identifier.
  Address() string
  
	// SetBootnodes takes a list of bootnodes and connects to them for boostraping the network protocol.
	// This method only makes sense on p2p transports.
  SetBootnodes(bootnodes []string)
  
	// AddPeer opens a new connection with the specified peer.
	// This method only makes sense on p2p transports.
  AddPeer(peer string) error
  
	// String returns a human readable string representation of the transport state
  String() string
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Topic        string // channel/topic for topic based messaging such as PubSub
	Encryption   string // what type of encryption to use
	TransportKey string // transport layer key for encrypting messages
	Key          string // this node's key
	Address      string // this node's address
	TLSdomain    string // tls domain
	TLScertDir   string // tls certificates directory
	Port         int32  // specific port on which a transport should listen
}

Connection describes the settings for any of the transports defined in the net module, note that not all fields are used for all transport types.

type Message

type Message struct {
	Data      []byte
	TimeStamp int32
	Namespace string

	Context MessageContext
}

Message is a wrapper for messages from various net transport modules

type MessageAPI

type MessageAPI interface {
	GetID() string
	SetID(string)
	SetTimestamp(int32)
	SetError(string)
	GetMethod() string
}

type MessageContext

type MessageContext interface {
	ConnectionType() string
	Send(Message) error
}

type Transport

type Transport interface {
	// Init initializes the transport layer. Takes a struct of options. Not all options must have effect.
	Init(c *Connection) error
	// ConnectionType returns the human readable name for the transport layer.
	ConnectionType() string
	// Listen starts and keeps listening for new messages, takes a channel where new messages will be written.
	Listen(reciever chan<- Message)
	// Send outputs a new message to the connection of MessageContext.
	// The package implementing this interface must also implement its own transports.MessageContext.
	Send(msg Message) error
	// SendUnicast outputs a new message to a specific connection identified by address.
	SendUnicast(address string, msg Message) error
	// AddNamespace creates a new namespace for writing handlers. On HTTP namespace is usually the URL route.
	AddNamespace(namespace string) error
	// Address returns an string containing the transport own address identifier.
	Address() string
	// SetBootnodes takes a list of bootnodes and connects to them for boostraping the network protocol.
	// This function only makes sense on p2p transports.
	SetBootnodes(bootnodes []string)
	// AddPeer opens a new connection with the specified peer.
	// This function only makes sense on p2p transports.
	AddPeer(peer string) error
	// String returns a human readable string representation of the transport state
	String() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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