EnSync Engine Documentation Help

PUB Command Overview

Purpose

The PUB command is the foundation of EnSync's event distribution system, enabling services to publish events to specified recipients. This command is essential for implementing event-driven architectures and facilitating asynchronous communication between distributed services.

Key Capabilities

Event Publishing

The PUB command allows services to broadcast events to other services without requiring direct connections or knowledge of the recipients' internal implementation. This decoupling is fundamental to building scalable microservice architectures.

Guaranteed Delivery

When an event is published, the EnSync system ensures it is durably stored and will be delivered to all subscribed recipients, even if they are temporarily unavailable. This guarantee is crucial for maintaining data consistency across distributed systems.

Payload Flexibility

Events can carry any JSON payload, making the PUB command versatile enough to handle various data types and structures. This flexibility allows services to exchange complex information while maintaining a consistent delivery mechanism.

Metadata Support

The optional METADATA parameter enables services to include contextual information with events, such as source system, correlation IDs, or processing hints, without cluttering the main payload.

Technical Implementation

The PUB command works by:

  1. Authenticating the publisher using their client ID and access key

  2. Validating that the publisher has permission to publish the specified event type

  3. Storing the event in both a durable storage layer and an in-memory cache

  4. Assigning a unique identifier (IDEM) to the event for tracking and deduplication

  5. Notifying subscribed recipients that a new event is available

This implementation ensures high throughput while maintaining delivery guarantees and proper access control.

Integration Points

The PUB command integrates with:

  • Authentication System: Verifies publisher identity and permissions

  • Storage Layer: Ensures event durability across system restarts

  • Caching Layer: Provides high-performance event access

  • Subscription System: Determines which clients receive the event

  • Audit System: Records all publish operations for compliance and debugging

Use Cases

  • Notifying services of state changes (e.g., user profile updates)

  • Broadcasting system-wide events (e.g., configuration changes)

  • Implementing event sourcing patterns

  • Building real-time dashboards and monitoring systems

  • Triggering workflow steps in distributed business processes

  • Implementing cross-service transactions

  • SUB: Subscribes to events published using PUB

  • DEFER: Postpones processing of published events

  • DISCARD: Permanently removes published events

Last modified: 07 October 2025