Skip to content

Instantly share code, notes, and snippets.

@rselva
Created November 21, 2025 11:59
Show Gist options
  • Select an option

  • Save rselva/13e4cfbfd45c9bd465fa214e42df2b07 to your computer and use it in GitHub Desktop.

Select an option

Save rselva/13e4cfbfd45c9bd465fa214e42df2b07 to your computer and use it in GitHub Desktop.

Subscription Sync Flow (Salesforce to OpenSearch)

When a scheduled change is created in Salesforce, a sync process updates the subscription record in DDB and OpenSearch to reflect the new scheduled change.

---
displayMode: compact
config:
  theme: redux-color
---
sequenceDiagram
    title Subscription Sync Flow 
    actor User as Airtime / API User 
    participant Salesforce
    participant Serverless
    participant DB as DDB/OpenSearch

    User->>Salesforce: Create scheduled change (Suspend)
    Salesforce-->>Serverless: Subscription OM
    Serverless->>Salesforce: Fetch updated subscription data
    Salesforce-->>Serverless: Return subscription data with scheduled change
    Serverless->>DB: Update subscription record with scheduled change
Loading

Subscription record in OpenSearch after scheduled change created

As scheduled changes are created/deleted/updated in Salesforce, a sync process updates the subscription record in DDB to reflect the current state of scheduled changes.

{
    "range_key": "SUBSCRIPTION#18054528-15#GLOBAL",
    "hash_key": "18054528-SLK",
    "scheduled_change":
    {
        "sf_id": "a0sPa000005UsphIAC",
        "effective_date": "2025-11-30T23:00:00Z",
        "created_at": "2025-11-19T11:18:12Z",
        "type": "SUSPEND",
        "status": "SCHEDULED"
    },
    "status": "ACTIVE"
}

Subscription status flow

flowchart TD
    ACTIVE --> SUSPENDED
    SUSPENDED --> ACTIVE
    ACTIVE --> TERMINATED
    SUSPENDED --> TERMINATED
    TERMINATED --is it even possible?--> ACTIVE

    %% class defs (reusable)
    classDef success fill:#28a745,stroke:#1e7e34,color:#fff;
    classDef warn fill:#ffc107,stroke:#d39e00,color:#212529;
    classDef info fill:#17a2b8,stroke:#117a8b,color:#fff;

    %% assign classes
    class ACTIVE success;
    class SUSPENDED,TERMINATED warn;
Loading

Scheduled Change Status Flow

The following diagram illustrates the various states a scheduled change can go through from creation to completion. Life cycle covers both KVH Manager initiated and Salesforce initiated scheduled changes.

flowchart TD
    NONE(NONE) --> CREATED
    CREATED --> ACCEPTED
    CREATED --> REJECTED
    ACCEPTED --> SCHEDULED
    SCHEDULED --Deleted--> NONE
    SCHEDULED --> FAILED
    SCHEDULED --Completed--> NONE
    SCHEDULED --> ABORTED
    SCHEDULED --Superceded--> NONE

    %% class defs (reusable)
    classDef success fill:#28a745,stroke:#1e7e34,color:#fff;
    classDef warn fill:#ffc107,stroke:#d39e00,color:#212529;
    classDef info fill:#17a2b8,stroke:#117a8b,color:#fff;

    %% assign classes
    class FORWARDED,CREATED info;
    class FAILED,ABORTED,REJECTED warn;
    class SCHEDULED,ACCEPTED success;
Loading

Subscription + Scheduled Change => UI action

Subscription Change UI behavior
ACTIVE NONE Suspend
ACTIVE CREATED NOOP
ACTIVE ACCEPTED NOOP
ACTIVE REJECTED Suspend
ACTIVE SCHEDULED Cancel Suspend
ACTIVE FAILED Warning
ACTIVE ABORTED Warning
TERMINATED any NOOP
SUSPENDED NONE Re-Activate
SUSPENDED CREATED NOOP
SUSPENDED ACCEPTED NOOP
SUSPENDED REJECTED Re-Activate
SUSPENDED SCHEDULED Cancel Re-Activate
SUSPENDED FAILED Warning
SUSPENDED ABORTED Warning

Suspend

When a scheduled change is created in KVH Manager, a sync process updates the subscription record in DDB and OpenSearch to reflect the new scheduled change.

---
displayMode: compact
config:
  theme: redux-color
---
sequenceDiagram
    title Suspend 
    actor User as KVH Manager User / UI
    participant KVHManager
    participant Serverless
    participant DB as DDB / OpenSearch  

    User->>KVHManager: Create scheduled change (Suspend)
    KVHManager-->>Serverless: CreateScheduled[Suspend] event
    Serverless->>Serverless:  CreateScheduledJob[Suspend] event
    Serverless->>DB: Update subscription record with scheduled change
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment