types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package types implements the packet and handshake messages for the tree routing algorithm.

The messages have been implemented in this isolated package so that it does not create cycle imports when importing the serde formats.

Documentation Last Review: 06.10.2020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandshakeFormat

func RegisterHandshakeFormat(f serde.Format, e serde.FormatEngine)

RegisterHandshakeFormat registers the engine for the provided format.

func RegisterPacketFormat

func RegisterPacketFormat(c serde.Format, f serde.FormatEngine)

RegisterPacketFormat registers the engine for the provided format.

Types

type AddrKey

type AddrKey struct{}

AddrKey is the key for the address factory.

type Handshake

type Handshake struct {
	// contains filtered or unexported fields
}

Handshake is a message to send the initial parameters of a routing table.

- implements serde.Message

func NewHandshake

func NewHandshake(height int, expected ...mino.Address) Handshake

NewHandshake returns a new handshake message.

func (Handshake) GetAddresses

func (h Handshake) GetAddresses() []mino.Address

GetAddresses returns the list of addresses to route.

func (Handshake) GetHeight

func (h Handshake) GetHeight() int

GetHeight returns the maximum height of the tree.

func (Handshake) Serialize

func (h Handshake) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data for the handshake.

type HandshakeFactory

type HandshakeFactory struct {
	// contains filtered or unexported fields
}

HandshakeFactory is a factory to serialize and deserialize handshake messages.

- implements router.HandshakeFactory

func NewHandshakeFactory

func NewHandshakeFactory(addrFac mino.AddressFactory) HandshakeFactory

NewHandshakeFactory creates a new factory.

func (HandshakeFactory) Deserialize

func (fac HandshakeFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It populates the handshake if appropriate, otherwise it returns an error.

func (HandshakeFactory) HandshakeOf

func (fac HandshakeFactory) HandshakeOf(ctx serde.Context, data []byte) (router.Handshake, error)

HandshakeOf implements router.HandshakeFactory. It populates the handshake if appropriate, otherwise it returns an error.

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

Packet describes a tree routing packet

- implements router.Packet

func NewPacket

func NewPacket(src mino.Address, msg []byte, dest ...mino.Address) *Packet

NewPacket creates a new packet.

func (*Packet) Add

func (p *Packet) Add(to mino.Address)

Add appends the address to the destination list, only if it does not exist already.

func (*Packet) GetDestination

func (p *Packet) GetDestination() []mino.Address

GetDestination implements router.Packet. It returns a list of addresses where the packet should be send to.

func (*Packet) GetMessage

func (p *Packet) GetMessage() []byte

GetMessage implements router.Packet. It returns the byte buffer of the message.

func (*Packet) GetSource

func (p *Packet) GetSource() mino.Address

GetSource implements router.Packet. It returns the source address of the packet.

func (*Packet) Serialize

func (p *Packet) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized data of the packet.

func (*Packet) Slice

func (p *Packet) Slice(addr mino.Address) router.Packet

Slice implements router.Packet. It removes the address from the destination list and returns a packet with this single destination, if it exists. Otherwise the packet stays unchanged.

type PacketFactory

type PacketFactory struct {
	// contains filtered or unexported fields
}

PacketFactory is a factory for the packet.

- implements serde.Factory

func NewPacketFactory

func NewPacketFactory(f mino.AddressFactory) PacketFactory

NewPacketFactory returns a factory for the packet.

func (PacketFactory) Deserialize

func (f PacketFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It populates the packet associated with the data if appropriate, otherwise it returns an error.

func (PacketFactory) PacketOf

func (f PacketFactory) PacketOf(ctx serde.Context, data []byte) (router.Packet, error)

PacketOf implements router.PacketFactory. It populates the packet associated with the data if appropriate, otherwise it returns an error.

Jump to

Keyboard shortcuts

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