cpursley / walex

Postgres change events (CDC) in Elixir
MIT License
282 stars 14 forks source link

Event forwarding #6

Closed cpursley closed 9 months ago

cpursley commented 2 years ago

Add webhook forwarding of events that is configurable by yaml. This way you wouldn't even need to touch Elixir.

Hasura Event Trigger yaml format: https://hasura.io/docs/latest/graphql/core/event-triggers/create-trigger.html

Or consider a similar config: https://github.com/subzerocloud/pg-event-proxy-example/blob/master/config_example.ini

Also see Supabase

cpursley commented 1 year ago

Another idea is ability to transform requests: https://hasura.io/docs/latest/api-reference/kriti-templating/

^ but perhaps better suited for a different library

cpursley commented 9 months ago

When casting to json, remove to Elixir map_diff specific columns:

"changes": {
    "event_id": {
      "added": "35ff67b6-4b9c-43f3-b51b-d2b7770e5796",
      "changed": "primitive_change",
      "removed": "6c59f0ed-e45b-44a7-98df-c2976835e875"
    },
    "updated_at": {
      "added": "2023-11-25T10:52:55.108562-05:00",
      "value": {
        "day": {
          "value": 25,
          "changed": "equal"
        },
        "hour": {
          "value": 10,
          "changed": "equal"
        },
        "year": {
          "value": 2023,
          "changed": "equal"
        },
        "month": {
          "value": 11,
          "changed": "equal"
        },
        "minute": {
          "value": 52,
          "changed": "equal"
        },
        "second": {
          "added": 55,
          "changed": "primitive_change",
          "removed": 54
        },
        "calendar": {
          "value": "Elixir.Calendar.ISO",
          "changed": "equal"
        },
        "time_zone": {
          "value": "Etc/UTC-5",
          "changed": "equal"
        },
        "zone_abbr": {
          "value": "-05",
          "changed": "equal"
        },
        "std_offset": {
          "value": 0,
          "changed": "equal"
        },
        "utc_offset": {
          "value": -18000,
          "changed": "equal"
        },
        "microsecond": {
          "added": [
            108562,
            6
          ],
          "changed": "primitive_change",
          "removed": [
            671907,
            6
          ]
        }
      },
      "changed": "map_change",
      "removed": "2023-11-25T10:52:54.671907-05:00",
      "struct_name": "Elixir.DateTime"
    },

In the above example, that means remove:

Maybe keep "value", not sure.

cpursley commented 9 months ago

Consider providing option to send in Debezium format.

cpursley commented 9 months ago

https://github.com/supabase/realtime/issues/33#issuecomment-632622973

Ability to config similar to this via json.

cpursley commented 9 months ago

Added ability to forward events via webhooks or to EventRelay: https://github.com/cpursley/walex/releases/tag/v3.2.0

cpursley commented 8 months ago

See also: https://github.com/eventrelay/eventsql