types

package
v0.0.0-...-73c317a Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Announcement

type Announcement struct {
	// used to determine when to expire an announcement
	SentRate time.Duration `json:"sent_rate"`

	// UDP port the announced endpoint is listening on for unicast data communications
	ListenPort int `json:"listen_port"`
	ListenAddr *net.UDPAddr

	// UDP address the announced endpoint is sending discovery announcements
	DiscoveryListenAddress string `json:"discovery_listen_address"`
	DiscoveryListenAddr    *net.UDPAddr

	// UDP address the announced endpoint is listening on for discovery announcements
	DiscoveryTargetAddress string `json:"discovery_target_address"`
	DiscoveryTargetAddr    *net.UDPAddr

	// used to avoid announcement forwarding loops
	Forwarded bool
}

func (*Announcement) Copy

func (a *Announcement) Copy() *Announcement

func (*Announcement) String

func (a *Announcement) String() string

type Container

type Container struct {
	// timestamp the sender originally sent the container
	SentTimestamp time.Time `json:"sent_timestamp"`

	// when then sender most recently sent the container (according to the sender)
	LastSentTimestamp time.Time `json:"last_sent_timestamp"`

	// source address according to the sender
	SentBy     string `json:"sent_by"`
	SentByAddr *net.UDPAddr

	// destination address according to the sender
	SentTo     string `json:"sent_to"`
	SentToAddr *net.UDPAddr

	// timestamp the receiver received the container
	ReceivedTimestamp time.Time `json:"-"`

	// destination address according to the receiver
	ReceivedFrom     string `json:"-"`
	ReceivedFromAddr *net.UDPAddr

	// source address according to the receiver
	ReceivedBy     string `json:"-"`
	ReceivedByAddr *net.UDPAddr

	// used to identify a group of endpoints
	NetworkID int64 `json:"network_id"`

	// automatically generated per endpoint lifecycle
	SourceEndpointID ksuid.KSUID `json:"source_endpoint_id"`

	// set by user- cannot appear twice in the same network
	SourceEndpointName string `json:"source_endpoint_name"`

	// content for an announcement
	Announcement *Announcement `json:"announcement"`

	// content for a frame
	Frame *Frame `json:"frame"`
}

func GetAnnouncementContainer

func GetAnnouncementContainer(
	sentTimestamp time.Time,
	sentBy string,
	networkID int64,
	sourceEndpointID ksuid.KSUID,
	sourceEndpointName string,
	sentRate time.Duration,
	discoveryListenAddress *net.UDPAddr,
	discoveryTargetAddress *net.UDPAddr,
	listenAddress *net.UDPAddr,
) *Container

func GetFrameAckContainer

func GetFrameAckContainer(
	networkID int64,
	sourceEndpointID ksuid.KSUID,
	sourceEndpointName string,
	container *Container,
) *Container

func GetFrameContainer

func GetFrameContainer(
	resendPeriod time.Duration,
	resendExpiry time.Duration,
	networkID int64,
	sourceEndpointID ksuid.KSUID,
	sourceEndpointName string,
	correlationID ksuid.KSUID,
	fragmentCount int64,
	fragmentIndex int64,
	destinationEndpointID ksuid.KSUID,
	destinationEndpointName string,
	needsAck bool,
	isAck bool,
	payload []byte,
) *Container

func (*Container) Copy

func (c *Container) Copy() *Container

func (*Container) String

func (c *Container) String() string

type Frame

type Frame struct {
	// don't attempt to resend until the frame is this much older
	ResendPeriod time.Duration `json:"-"`

	// don't attempt to resend the frame after it's this much older
	ResendExpiry time.Duration `json:"-"`

	// unique for this frame
	FrameID ksuid.KSUID `json:"frame_id"`

	// unique for a related group of frames
	CorrelationID ksuid.KSUID `json:"correlation_id"`

	// how many fragments there are (1 = single frame)
	FragmentCount int64 `json:"fragment_count"`

	// which one this is
	FragmentIndex int64 `json:"fragment_index"`

	// a distant SourceEndpointID
	DestinationEndpointID ksuid.KSUID `json:"destination_endpoint_id"`

	// a distance SourceEndpointName
	DestinationEndpointName string `json:"destination_endpoint_name"`

	// is a markAck needed?
	NeedsAck bool `json:"needs_ack"`

	// is this a markAck?
	IsAck bool `json:"is_ack"`

	// the actual user payload (or fragment thereof)
	Payload []byte `json:"payload"`
}

func (*Frame) Copy

func (f *Frame) Copy() *Frame

func (*Frame) String

func (f *Frame) String() string

Jump to

Keyboard shortcuts

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