/
Data engineering

Filter Transform Route Data in Real Time with Functions

Discover Stacksync's embedded functions for real-time filtering, transformation, and routing of data changes in bi-directional sync pipelines with microsecond latency.
Blog post featured image

Filter Transform Route Data in Real Time with Functions

Modern enterprises implementing real-time data synchronization face a fundamental challenge: efficiently processing massive volumes of database changes while applying business logic in operational pipelines. Traditional CDC approaches struggle to deliver filtering, transformation, and routing capabilities at the sub-millisecond latency that operational systems demand [1].

Stacksync addresses this technical constraint by embedding custom processing functions directly within bi-directional synchronization pipelines, enabling organizations to filter, transform, and route data changes in single-digit microseconds without compromising reliability or consistency.

Why Functions Are Essential for Real-Time Data Sync

Stacksync powers real-time and two-way sync between CRMs, ERPs and databases, allowing engineers to sync and consolidate data at scale while focusing on business logic rather than API infrastructure . Within these high-throughput pipelines, three fundamental operations consistently emerge:

Filter: Organizations require specific database changes based on inclusion criteria, exclusion rules, or complex conditional logic—not every modification captured by CDC systems [2]. Processing unnecessary events downstream creates inefficiencies across entire synchronization architectures.

Transform: Raw database payloads rarely match target system requirements. Operational systems need PII redaction, timestamp reformatting, field derivation, and data normalization—all with sub-second latency [3].

Route: Modern data architectures require intelligent distribution of events to specific destinations based on content analysis, metadata evaluation, or business rules [4].

Applying this logic downstream through separate services adds latency, overhead, and architectural complexity that undermines real-time operational capabilities [5]. Database triggers increase source system load, while configuration-based rules lack the flexibility for complex processing requirements.

Stacksync's unified function primitive addresses all three operations using the same interface, eliminating multiple tool dependencies while delivering enterprise-grade performance.

Function Examples: Real-Time Processing in Action

Filter Functions

Filter functions return boolean values to determine which database changes propagate through synchronization pipelines:

def filter(_action, record, _changes, _metadata) do
  record["region"] in ["us-west", "us-east"] and record["status"] == "active"
end

This filter processes only records from specific geographic regions with active status, eliminating downstream processing of irrelevant data while maintaining field-level precision.

Transform Functions

Transform functions reshape database changes into target-appropriate JSON structures during synchronization:

def transform(_action, record, _changes, metadata) do
 %{
   "customer_id" => record["id"],
   "email_normalized" => String.downcase(record["email"]),
   "sync_timestamp" => metadata.commit_timestamp,
   "source_table" => "#{metadata.table_schema}.#{metadata.table_name}"
 }
end

This approach creates clean, immediately usable payloads with normalized data and contextual metadata, eliminating post-processing requirements [3].

Routing Functions

Routing functions dynamically determine event destinations based on content analysis:

def route(_action, record, _changes, metadata) do
 destination = case record["priority_level"] do
   "critical" -> "alerts.high_priority"
   "standard" -> "#{metadata.table_schema}.standard"
   _ -> "events.general"
 end
 
 %{"topic" => destination}
end

This routing logic directs critical events to priority queues while maintaining standard processing flows for regular updates.

Technical Implementation: High-Performance Function Execution

Stacksync implements functions using a restricted Elixir interpreter optimized for microsecond-latency execution within high-volume CDC pipelines. This architectural choice delivers unmatched performance while maintaining operational simplicity.

Performance Requirements: Real-time data pipelines processing 50,000+ messages per second demand sub-millisecond function execution [6]. Stacksync's approach eliminates the latency penalties of external service calls or separate processing stages.

Language Selection: Most organizations haven't implemented Elixir, but complex data processing requires full programming language expressiveness rather than limited configuration options. Stacksync includes a "Copy for ChatGPT" feature providing LLMs with complete context for translating requirements into working Mini Elixir code, eliminating the learning curve.

Unified Architecture: Rather than managing multiple specialized tools for different pipeline stages, Stacksync provides a single platform engineered specifically for real-time, bi-directional data synchronization with embedded processing capabilities.

Building and Testing Functions

Stacksync integrates function development into standard engineering workflows through multiple interfaces:

Console Development: The Stacksync Console provides an integrated IDE for writing and testing functions against live data streams with immediate feedback.

Configuration as Code: Functions integrate with CI/CD pipelines through declarative configuration:

functions:
 region_filter:
   type: filter
   code: |
     def filter(_action, record, _changes, _metadata) do
       record["region"] in ["us-west", "us-east"]
     end
     
 customer_transform:
   type: transform
   code: |
     def transform(_action, record, _changes, metadata) do
       %{
         "customer_id" => record["id"],
         "email" => String.downcase(record["email"]),
         "updated_at" => metadata.commit_timestamp
       }
     end
     
 priority_router:
   type: routing
   code: |
     def route(_action, record, _changes, metadata) do
       %{
         "destination" => "#{metadata.table_schema}.#{metadata.table_name}"
       }
     end
     
syncs:
 - name: customer_pipeline
   source_table: customers
   filter: region_filter
   transform: customer_transform
   routing: priority_router
   destination:
     type: database
     connection: "postgresql://target-db"

Version Control Integration: Functions exist as plain text, enabling standard development practices including automated testing, code review, and deployment automation.

Enterprise Advantages Over Traditional Approaches

Organizations implementing Stacksync report up to 80-90% reduction in integration maintenance effort compared to custom development or point solutions. Functions extend these benefits to data processing logic:

Eliminated Infrastructure: Organizations avoid building and maintaining separate filtering, transformation, and routing services while achieving superior performance.

Unified Operations: Point solutions create complex, untraceable data flows with fragmented governance and monitoring. Stacksync provides centralized processing within the synchronization platform .

Real-Time Consistency: Stacksync's true two-way sync ensures that updates in any system instantly reflect across all connected systems , with functions processing changes at synchronization speed.

Enterprise Security: Functions operate within Stacksync's SOC 2, GDPR, HIPAA, and ISO 27001 compliance framework with enterprise-grade monitoring and error handling.

Get Started with Real-Time Data Processing

Functions are available across all Stacksync synchronization capabilities. This establishes a unified and consistent data backbone across critical business systems, automating processes that were previously manual while empowering teams with reliable, real-time information .

Implementation Process:

  1. Connect Systems: Use Stacksync's 200+ pre-built connectors to establish bi-directional synchronization
  2. Develop Functions: Create filter, transform, and routing logic using the Console IDE or configuration-as-code approach
  3. Deploy and Monitor: Activate real-time processing with comprehensive observability through Stacksync's platform dashboard

Ready to eliminate custom data processing infrastructure while achieving microsecond-latency performance? Explore how Stacksync's functions can transform your real-time data synchronization architecture without the complexity of traditional approaches.

Start building with Stacksync's real-time functions →

Ready to see a real-time data integration platform in action? Book a demo with real engineers and discover how Stacksync brings together two-way sync, workflow automation, EDI, managed event queues, and built-in monitoring to keep your CRM, ERP, and databases aligned in real time without batch jobs or brittle integrations.
→  FAQS
What does this guide cover?
This guide covers filter transform route data in real time with functions, including key concepts, implementation strategies, and best practices for enterprises. You will learn how to leverage Stacksync's real-time bidirectional sync platform to solve common data integration challenges and maintain consistency across your business systems.
How does Stacksync help with this?
Stacksync provides a no-code platform for real-time bidirectional data synchronization between 200+ connectors including CRMs, ERPs, databases, and SaaS applications. The platform eliminates manual data entry, prevents data drift, and ensures all systems stay aligned with sub-second sync latency and enterprise-grade security.
Is Stacksync secure for enterprise use?
Yes. Stacksync is SOC 2 Type II certified, ISO 27001 certified, and HIPAA compliant. Data is encrypted in transit with TLS 1.2+ and at rest with AES-256. The platform uses zero-persistent-storage architecture, meaning your data is not retained after sync operations. Enterprise security features include SSO, SCIM, IP whitelisting, and full audit logging.
How long does implementation take?
Most Stacksync integrations go live within 3 to 7 business days. The no-code visual interface handles authentication, field mapping, and data transformation without engineering resources. Complex multi-system architectures may take 2 to 3 weeks. Stacksync provides pre-built connectors and templates that accelerate setup compared to custom development.
What pricing model does Stacksync use?
Stacksync uses flat pricing based on active sync connections and monthly record volume, starting at $1,000 per month. There are no per-row fees, no hidden charges for data volume, and no separate costs for bidirectional sync. Volume discounts are available for enterprise deployments. A 14-day free trial is available to evaluate the platform.

Syncing data at scale
across all industries.

a blue checkmark icon
POC from integration engineers
a blue checkmark icon
Two-way, Real-time sync
a blue checkmark icon
Workflow automation
a blue checkmark icon
White-glove onboarding
“We’ve been using Stacksync across 4 different projects and can’t imagine working without it.”

Alex Marinov

VP Technology, Acertus Delivers
Vehicle logistics powered by technology