Federation

HoloSphere Federation

HoloSphere's federation system allows different holons (spaces) to share and access data from each other. Federation creates a relationship between spaces that enables data propagation and cross-space access.

Key Concepts

  • Federation Relationship: A connection between two spaces that allows data to flow between them.

  • Soul References: Lightweight references that point to data in its original location (single source of truth).

  • Notification Flow: Data notifications flow from source spaces to target spaces that are in the notify list.

  • Source-Target Relationship: Each federation sets up a source space (federation list) and a target space (notify list).

Federation Data Flow

The HoloSphere federation system works with a clear source-target relationship:

  1. Federation List: When space A federates with space B, space A adds B to its federation list.

  2. Notify List: Space B adds space A to its notify list.

  3. Data Flow: When space A changes, space B gets notified (but not vice versa unless bidirectional).

Creating Federation

Create federation relationships between spaces:

The bidirectional parameter is largely unused in the current implementation since the federation system naturally sets up the correct notification flow. The default relationship allows space2 to be notified of changes in space1.

Storing and Propagating Data

Data must be explicitly propagated to federated spaces:

You can also enable automatic propagation in the put() method:

Accessing Federated Data

Direct Retrieval

You can access data directly from any space:

Aggregate Federated Data

Use getFederated() to get data from multiple federated spaces:

Soul References

HoloSphere uses a simplified reference system based on soul paths:

  1. A reference contains only an id and a soul property

  2. The soul path is in the format: appname/holon/lens/key

  3. When resolving a reference, HoloSphere follows the soul path to retrieve the original data

By default, federation propagation uses references instead of duplicating data. This can be controlled:

Removing Federation

Complete Example

Here's a complete example showing the proper way to set up and use federation:

Troubleshooting

Common Issues

  1. Federation Relationship: Make sure to check both the federation list and notify list to understand data flow.

  2. Data Propagation: If data isn't appearing in federated spaces, check:

    • The federation relationship was created correctly

    • The data was propagated explicitly or autoPropagate was set to true

    • The notify list includes the target space

  3. Reference Resolution: If you're getting reference objects instead of the actual data:

    • Make sure resolveReferences is set to true (it's the default)

    • Check that the original data still exists at the referenced location

  4. Timing Issues: Data propagation is asynchronous. Add small delays (500-1000ms) between operations to allow propagation to complete.

Best Practices

  1. Verify Federation Structure: After creating a federation, check both spaces to ensure:

    • Source space has the target in its federation list

    • Target space has the source in its notify list

  2. Explicit Propagation: Unless you're using autoPropagate, always call propagate() explicitly after storing data that should be shared.

  3. Choose the Right Propagation Method:

    • Use useReferences: true (default) to keep a single source of truth

    • Use useReferences: false only when you need independent copies

  4. Cleanup: Always close the HoloSphere instance when done to prevent resource leaks.

Last updated

Was this helpful?