Skip to content
Ovsep Avakian edited this page Dec 11, 2024 · 2 revisions

Overview

Ports are the connection points of components in F-Mesh. Unlike systems that follow the actor model (e.g., Akka), where components communicate directly, F-Mesh components are isolated and communicate only through signals passed via ports.

This design promotes modularity and separation of concerns: a component only interacts with its own ports and does not need to know where its signals are routed. The abstraction ensures that the logic and behavior of each component remain self-contained and decoupled from the overall mesh structure.

You can explore the full API for ports here.

Types of Ports

There are two types of ports in F-Mesh:

  1. Input Ports: Receive signals for the component to process.
  2. Output Ports: Send signals to connected components.

Both input and output ports are instances of the same underlying type, Port.
However, F-Mesh enforces type-safe connections:

  • Pipes cannot be created between two input ports or two output ports.
  • Connections are strictly from an output port to an input port.

Internal Structure

Each port has three core elements:

  1. Name: Unique name used to access port.
  2. Signal Buffer: Holds an unlimited number of signals.
  3. Pipes List: Tracks outbound connections to other ports.

Important

The port buffer does not guarantee any specific order for the signals it holds.
Your program must not rely on the observed order of signals.

Working with Groups and Collections

When working with multiple ports, F-Mesh provides two utility types: Group and Collection. These abstractions simplify interactions with multiple ports, although users typically do not need to interact with them directly.

Group

A Group is essentially a wrapper around a slice of ports. It allows you to iterate over and manage a set of ports without concern for their individual names.

Collection

A Collection is an indexed structure, where ports are stored and accessed by name. Unlike a Group, a Collection cannot contain multiple ports with the same name, ensuring a unique mapping of port names to ports.

Clone this wiki locally