Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
24 changes: 17 additions & 7 deletions docs/photoniq/event-delivery/clients/index.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
---
sidebar_position: 1
title: Event Delivery Client SDKs
title: Getting Started with Event Delivery Client SDKs
---

This section demonstrates some of the tasks you can complete with JavaScript SDKs. Macrometa offers the following SDKs:

PhotonIQ offers two client SDKs to enable you connect to and deliver event streams to your applications, services, and several other data-volatile use cases. These SDKs are written in Javascript:
- [WebSocket](/download/eds-clients/photoniq-eds-ws.min.js)
- SSE (coming soon)
- Server Sent Events (SSE)
This section demonstrates some simple tasks to help get you started using these client SDKs.

## Pre-requisites
## Objectives
In event delivery, an event refers to every new data generated or function executed. Getting started with this PhotonIQ service will involve you connecting to and subscribing to events from a stream.

This quickstart guide will guide you through:
- Connecting to an event delivery service
- Querying that service and receiving query results
- Disconnecting from the event delivery service

- Download `photoniq-eds-ws.min.js` or `photoniq-eds-sse.min.js` from section above.
- Attach the module to your html:

## Pre-requisites
You need the WebSocket or SSE client to successfully complete this guide:
1. Download the `photoniq-eds-ws.min.js` or `photoniq-eds-sse.min.js` client SDK.
1. Attach the Javascript module to html code
```html
<script src="path/to/photoniq-eds-ws.min.js"></script>
<!-- or -->
<script src="path/to/photoniq-eds-sse.min.js"></script>
```


## Basic Example

Connect to Event Delivery Service, retrieve and subsribe to SQL:
Expand Down
13 changes: 7 additions & 6 deletions docs/photoniq/event-delivery/event-delivery-queries.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
sidebar_position: 60
title: Event Delivery Queries
title: Event Delivery Filters
---

PhotonIQ Event Delivery offers powerful filtering capabilities that allow users to specify exactly which events they want to receive. By using PostgreSQL SELECT statement syntax, users can define filters to tailor the event stream to their needs. This page outlines how to construct these queries, providing syntax guidelines, use cases, and examples.
PhotonIQ Event Delivery offers powerful filtering capabilities that allow users to specify exactly which events they want to receive. By using the PostgreSQL `SELECT` statement syntax, users can define filters to tailor the event stream to their needs. This page outlines how to construct these queries, providing syntax guidelines, use cases, and examples.

## Syntax

Filters are defined in a JSON format string, which includes fields to specify the desired event criteria. The fundamental structure of a filter includes:

- `action`: Defines the filter action, such as "add" for adding new filters or "remove" for removing existing filters.
- `once`: A boolean flag (`TRUE` or `FALSE`), indicating whether the filter should be applied just once. The default is `FALSE`.
- `once`: A boolean flag (`TRUE` or `FALSE`), indicating whether to apply the filter just once. The default is `FALSE`.
- `queries`: An array of SELECT statements defining the specific events to filter.

The SELECT syntax follows standard SQL conventions, allowing for conditions (`WHERE`), logical operators (`AND`, `OR`), and specifying particular fields or using `*` for all fields within a collection or stream.
Expand All @@ -30,9 +30,10 @@ The SELECT syntax follows standard SQL conventions, allowing for conditions (`WH

## Use Cases and Examples

In practice, leveraging event delivery queries allows for highly customizable data streams, catering to a wide array of application needs. Whether you're monitoring real-time updates from a specific dataset or listening for changes that meet particular criteria, these queries empower you to streamline data reception, ensuring your application only processes the most relevant information. To demonstrate the practical application of these filters, this section explores how to subscribe to and filter events using examples that mimic real-world scenarios.
In practice, leveraging event delivery queries allows for customizing data streams, catering to a wide array of application needs. Whether you're monitoring real-time updates from a specific dataset or listening for changes that meet particular criteria, these queries empower you to streamline data reception, ensuring your application only processes the most relevant information.
To demonstrate the practical application of these filters, this section explores how to subscribe to and filter events using examples that mimic real-world scenarios.

To interact with the PhotonIQ Event Delivery Service, you must use a tool that supports WebSocket connections, as traditional HTTP clients like `curl` do not accommodate the WebSocket protocol. These examples use `wscat`, a command-line tool for connecting to WebSocket servers.
To interact with the PhotonIQ Event Delivery Service, use a tool that supports WebSocket connections, as traditional HTTP clients like `curl` do not accommodate the WebSocket protocol. These examples use `wscat`, a command-line tool for connecting to WebSocket servers.

These examples illustrate the versatility of event delivery queries in EDS, enabling precise control over the data stream to suit diverse application needs. Through the use of SQL-like syntax and dynamic filter management, you can efficiently tailor the event delivery to your specific requirements.

Expand Down Expand Up @@ -62,7 +63,7 @@ This command subscribes to all changes within `CollectionName`. This is particul
wscat -c 'wss://your-eds-domain/api/es/v1/subscribe?type=collection&filters={"action": "add", "once": "FALSE", "queries": ["select specificField from CollectionName where condition"]}'
```

Subscribes to changes in `specificField` when `condition` is met. This method is ideal for situations where events are only relevant under certain conditions, reducing noise and focusing on significant data changes. For example, in a logistics application, this could be used to alert users only when shipments are delayed by more than a day or when inventory levels fall below a critical threshold, enabling timely decision-making and action.
Subscribes to changes in `specificField` that meets a `condition`. This method is ideal for situations where events are only relevant under certain conditions, reducing noise and focusing on significant data changes. For example, in a logistics application, this could be used to alert users only when shipments are delayed by more than a day or when inventory levels fall below a critical threshold, enabling timely decision-making and action.

### Dynamic Filter Management

Expand Down
48 changes: 0 additions & 48 deletions docs/photoniq/event-delivery/get-started-event-delivery.md

This file was deleted.

31 changes: 18 additions & 13 deletions docs/photoniq/event-delivery/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,49 @@ sidebar_position: 1
title: Event Delivery
---

PhotonIQ Event Delivery delivers real-time event data to applications using WebSockets and Server-Sent Events (SSE). It allows developers to integrate event-driven functionality into applications, ensuring they receive timely updates.
PhotonIQ Event Delivery ensures the timely delivery of real-time event data to your applications, allowing developers to integrate event-driven functionality into applications, thus guaranteeing the delivery of real-time updates for making better data-driven. It does this using two methods:

- **Websockets**: WebSockets addresses the limited unidirectional HTTP communication protocol by establishing a persistent, bi-directional communication between clients and servers, making them an ideal choice for building efficient, low-latent, real-time applications.
- **Server-Sent Events (SSE)**: An alternative to Websockets, SSE is a lightweight, unidirectional HTTP protocol for building communication channels. However, unlike the HTTP protocol, which closes a connection after receiving a response, the SSE keeps this connection open to receiving streaming updates as long as the client, thus enabling it to send real-time updates to clients.

## Benefits of Event Delivery

Event Delivery offers several key advantages that enhance the functionality and responsiveness of applications:

- **Immediate Data Updates:** Event Delivery provides real-time notifications, keeping applications up-to-date with the latest events.
- **Data Stream Customization:** With SQL-like filters, users can specify which events they receive, reducing unnecessary data.
- **Quick Decision Making:** Access to real-time data helps users respond faster to changes, improving operational efficiency.
- **Operational Efficiency**: For traffic monitoring, health, delivery, and ride-hailing and communication services, real-time event delivery helps coordinate and organize work efforts, thus improving operational efficiency and productivity.
- **Improved Customer Experiences**: Real-time applications like gaming and chat messaging offer an interactive and engaging experience for users, improving individual experiences.
- **Risk Management**: Finance, health, and military organizations rely on immediate data updates to assess risks and make informed decisions. For these industries, data is time-sensitive with a short window frame for action and becomes non-relevant or less relevant after time elapses.
- **Reduces Irrelevant Data**: Event delivery offers SQL-like filters, which help users filter subscribed events, thus reducing the occurrence of irrelevant data for processing and analytics.
- **Better Decision-making**: Access to real-time, relevant data helps teams respond faster and with better-informed solutions to changes.

## Challenges Addressed by Event Delivery

Event Delivery is designed to solve specific problems related to data management and delivery in modern applications:
Event Delivery aims to solve specific problems related to data management and delivery in modern applications:

- **Information Overload:** Event Delivery filters out irrelevant data, delivering only the information users need.
- **Data Reception Latency:** Real-time event delivery minimizes delays, ensuring decisions are made using the most current information.
- **Data Reception Latency:** Real-time event delivery minimizes delays, ensuring decision-making using the most current information.
- **Integration Complexity:** Event Delivery uses standard SQL-like querying for easy integration with existing systems.

## Features
## Features of EDS

Event Delivery is built with a comprehensive set of features to support real-time data delivery and customization.
The PhotonIQ Event Delivery Service has comprehensive features to support real-time data delivery and customization to fit different organizational use cases.

### Real-Time Event Delivery

This feature allows for the delivery of events as they happen, utilizing WebSockets and including event de-duplication to streamline data flow.
EDS offers two methods for enabling real-time delivery of events as they occur, utilizing Websockets and including event de-duplication to reduce the occurrence of noise and irrelevant data in your data stream.

### Event Subscription and Publishing

Users have the ability to subscribe to specific events that matter to them and can publish data to the event stream, facilitating a dynamic data exchange.
Users can subscribe to specific events that matter to them and can publish data to the event stream, facilitating a dynamic data exchange.

### Advanced Filtering

Event Delivery offers SQL-like filtering capabilities, enabling precise control over the events to which users subscribe, ensuring relevance and reducing noise.
Event Delivery offers SQL-like filtering capabilities, enabling precise control over users' subscriptions to events, ensuring relevance, and reducing noise.

### Scalability and Security

Designed to accommodate large user bases, Event Delivery provides robust security measures including data encryption and user authentication, ensuring safe and scalable operations.
Designed to accommodate large user bases, Event Delivery provides robust security measures, including data encryption and user authentication, ensuring safe and scalable operations.

### Metrics and Analytics

Providing detailed insights into data usage and event trends, this feature helps users optimize their applications and make informed decisions based on analytics.
EDS provides detailed insights into the health, performance, and event trends, helping users optimize their applications and make informed decisions based on analytics.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Managing Event Delivery Instances
---

To optimize the performance of your event delivery service, PhotonIQ offers different ways to manage the behaviour of your EDS instances. These methods include:

- **Query, Set and Batch**: A layer that helps you batch and run a group of queries together, instead of running each individually, thus improving efficiency.
- **Connection**: An instance with numerous methods that helps you connect, retrieve and configure connection details, and disconnect your WebSocket/SSE connection.
- **Listeners and Error Handling**: These are grouped into global, query, result, and error listeners and helps handles events.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Setting Up Event Stream in GDN
---

The Event Delivery service allows you to stream and filter events from Macrometa streams and also publish events to these streams.
Some important concepts to know:
- **Publisher**: An application or service that continuously generates data for consumption by a subscriber. Collections in the Macrometa GDN act as publishers in the Event Delivery Service (EDS)
- **Subscriber**: Subscribes to events from the publisher. Subscribers can use SQL-queries to subscribe to specific events, thus reducing noise and focusing on the necessary data.
- **Stream**: A named channel for sending messages. The GDN backs every stream in the GDN with a distributed append-only log and can be local (at one edge location only) or global (across all edge locations in the [fabric](../../../geofabrics/)).
- **Event**: Every new data point/message generated by the publisher.

Let's set up our first stream in a GDN.

## Prerequisites
- A [Macrometa account](https://auth-play.macrometa.io/) with sufficient permissions to create connections. Contact a Macrometa partner to sign up or [sign up](https://www.macrometa.com/sign-up) on your own. With a Macrometa account set up, you can decide what kind of collection to stream your data into.
The PhotonIQ GDN allows you to create:
- [Document Collection](../../collections/documents/) - Accepts any document type.
- [Key-Value Collection](../../collections/keyvalue/) - Accepts key-value pairs, can be set up to include blobs.

:::tip

Consult with Macrometa Partners to help decide the best type for your business use case.

:::
- An application to receive event delivery streams.
- Plan your filters. Filters are set up by adding queries to event subscriptions.


## Set Up Your Stream in the GDN
1. (Optional) [Create a fabric](../../../geofabrics/create-geofabric.md) for your collection. A fabric allows you to decide exactly where your data lives. Skipping this step means the collection will reside in the system fabric.
1. Create a collection to receive streaming data.

![New Collection Stream](/img/photoniq/event-delivery/new-collection-stream.png)

:::important

Make sure to enable streams when you [create a collection](https://www.macrometa.com/docs/collections/).

:::

3. Navigate to [collection settings](https://www.macrometa.com/docs/collections/view-collection-settings) to view and access information about your collection.

![View Collection Settings](/img/photoniq/event-delivery/view-collection-settings.png)

Your collection settings provides useful information like:
- **Resource URL** - The endpoint sending data to your collection. All messages sent here are both stored and transmitted to the stream.
- **Stream Name** - Name of our data stream.
- **Fabric Name** - Name of our fabric.
In the screenshot above, the fabric name is **_system**.

Loading