connection

package
v0.0.0-...-c729bb3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AvailableConnectionTypes - global preset list of types connections that can be made
	AvailableConnectionTypes = []string{"relay"}
)
View Source
var (
	// AvailableEventTypes - global preset list of directions that an individual node can give to another
	AvailableEventTypes = []string{"push", "fetch"}
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	DestinationNode    *node.Node `json:"destination node"`  // Node to contact
	InitializationNode *node.Node `json:"initializing node"` // Node initializing connection

	Data []byte `json:"data"` // Actual data being transmitted

	Port int `json:"port"`

	ConnectionType  string  `json:"type"` // Type of connection
	ConnectionStack []Event `json:"stack"`
}

Connection - abstract container for Golang connection type, contains metadata, routing parameters

func FromBytes

func FromBytes(b []byte) (*Connection, error)

FromBytes - attempt to convert specified byte array to connection

func NewConnection

func NewConnection(sourceNode *node.Node, destinationNode *node.Node, port int, data []byte, connectionType string, connectionStack []Event) (*Connection, error)

NewConnection - creates new Connection{} instance with specified data, peers

func (*Connection) Attempt

func (connection *Connection) Attempt() ([]byte, error)

Attempt - attempts to carry out connection, if event stack is provided, begins to iterate through list

func (*Connection) AttemptVariable

func (connection *Connection) AttemptVariable() (*environment.Variable, error)

AttemptVariable - attempts to carry out connection, returning variable response

type Event

type Event struct {
	EventType string `json:"type"`

	Resolution Resolution `json:"resolution"` // Data being transmitted

	Command *command.Command `json:"command"` // Action for destination node to carry out

	DestinationNode *node.Node `json:"destination"` // Node to contact

	Port int `json:"port"`
}

Event - container holding metadata concerning a direction given from a peer to another

func NewEvent

func NewEvent(eventType string, resolution Resolution, command *command.Command, destinationNode *node.Node, port int) (*Event, error)

NewEvent - creates new Event{} instance with specified resolution, peers, command

func (*Event) Attempt

func (event *Event) Attempt() ([]byte, error)

Attempt - attempts to carry out event

type Resolution

type Resolution struct {
	ResolutionData []byte `json:"data"` // ResolutionData - data being passed via resolution (typically a struct)

	GuidingType interface{} `json:"guide"` // GuidingType - guiding struct to map resolution fields
}

Resolution - abstract type defining how to handle and deal with a connection or event's data

func NewResolution

func NewResolution(data []byte, guidingType interface{}) (*Resolution, error)

NewResolution - attempt to create new instance of the Resolution struct with specified initializers

type Response

type Response struct {
	Val [][]byte `json:"value"`
}

Response - abstract container holding array of byte arrays

func ResponseFromBytes

func ResponseFromBytes(b []byte) (*Response, error)

ResponseFromBytes - attempt to convert specified byte array to connection

Jump to

Keyboard shortcuts

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