dsnet

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package dsnet implements a distributed systems networking library. It provides a Node type for sending and receiving messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMessage

type BaseMessage struct {
	From string `json:"from"`
	To   string `json:"to"`
	Type string `json:"type"`
}

BaseMessage represents the basic structure of a DSNet message.

type Event

type Event struct {
	From        string
	To          string
	Type        string
	Payload     []byte
	VectorClock map[string]uint64
}

Event represents a message sent or received by a DSNet node.

type Node

type Node struct {
	ID string

	Inbound chan Event
	// contains filtered or unexported fields
}

Node represents a DSNet node that can send and receive messages.

func NewNode

func NewNode(id string, controllerAddr string) (*Node, error)

NewNode creates a new DSNet node and connects it to the controller at the specified address. It performs a handshake with the controller upon creation.

func (*Node) Close

func (n *Node) Close()

Close gracefully shuts down the node, closing connections and files.

func (*Node) Send

func (n *Node) Send(ctx context.Context, dest string, msg interface{}) error

Send sends a message to the specified destination node. The message is marshaled to JSON and wrapped in an envelope with vector clock information.

Jump to

Keyboard shortcuts

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