Inquery is a utility for Postgres that triggers webhooks when rows are inserted, updated, or deleted. It uses database triggers that send low-latency websocket messages to a Go application. This application then calls the configured webhook(s) with a JSON payload that includes specified values from the database row.
How It Works
- Data is modified in Postgres table (INSERT, UPDATE, DELETE)
- Postgres trigger notifies the Inquery web server via a websocket message
- Inquery formats the data and sends the webhook(s)
Use Cases
- Send notifications: Slack, Email, Text Message, Push Notification
- Call serverless functions: AWS Lambda, Google Cloud Functions, Azure Functions
- Trigger analytics events: Segment, Mixpanel, Amplitude
- Stream data real-time: Snowflake, BigQuery, Clickhouse, Redshift
Get Started
Run Inquery locally
You can run Inquery locally with Docker.
git clone --depth 1 https://github.com/inqueryio/inquery.git
cd inquery
docker-compose up -d
Then open http://localhost:3000 to access Inquery.
Note: When connecting your database, if your Postgres host is localhost
, you must use host.docker.internal
instead to access it when running with Docker.
Run Inquery on AWS (EC2)
Note: Make sure this instance is only accessible within your VPC.
Note: These instructions are for Amazon Linux 2 AMI (HVM).
- To install Docker, run the following command in your SSH session on the instance terminal:
sudo yum update -y sudo yum install -y docker sudo service docker start sudo usermod -a -G docker $USER logout # Needed to close the SSH session so Docker does not have to be run as root
- To install
docker-compose
, run the following command in your ssh session on the instance terminal:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
docker-compose version
- Install and run Inquery
mkdir inquery && cd inquery wget https://raw.githubusercontent.com/inqueryio/inquery/main/{.env,docker-compose.yml,.dockerignore,frontend.env} docker-compose up -d
Features
Template Strings
When adding an action, you can insert data from the row into the response body of the POST request by using template strings.
For instance, if your table has a column called email
, you would put the value ${email}
in the request body: {"text":"User created: ${email}!"}
The prefixes new.
and old.
can be used if a new (INSERT, UPDATE) or old (UPDATE, DELETE) row is available. If a prefix is not specified, the new or old values will be used depending on the event. Example: {"text":"User updated: ${old.email} is now ${new.email}!"}
The meta values meta.table
(table name), meta.schema
(schema name), meta.event
(INSERT, UPDATE, or DELETE) can also be used.
Roadmap
- Filters and mapping options for row data when sending a POST request
Let us know your feedback or feature requests! You can submit a GitHub issue or contact us at hey@inquery.io.
from Hacker News https://ift.tt/PYxLUnK
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.