Skip to content
Merged
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
26 changes: 13 additions & 13 deletions .github/workflows/build-channel-sender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,43 @@ jobs:
- name: Generate a token of Github APP
id: generate_token
if: github.ref == 'refs/heads/main'
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
with:
app_id: ${{ secrets.APP_ID_ADMIN_GITHUB }}
private_key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
app-id: ${{ secrets.APP_ID_ADMIN_GITHUB }}
private-key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: github.ref == 'refs/heads/main'
with:
token: ${{ steps.generate_token.outputs.token }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: github.ref != 'refs/heads/main'

- name: Verify Conventional Commits
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up NodeJS
if: github.ref == 'refs/heads/main'
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: './channel-sender/.nvmrc'
- name: Set up Semantic Release
if: github.ref == 'refs/heads/main'
run: npm -g install @semantic-release/git semantic-release@23.0.0
run: npm -g install @semantic-release/git semantic-release
- name: Semantic Release
if: github.ref == 'refs/heads/main'
run: npx semantic-release@23.0.0
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- name: Set up Elixir
uses: erlef/setup-beam@v1.17.6
uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # v1.20.4
with:
version-type: strict
version-file: "./channel-sender/.tool-versions"
- name: Restore dependencies cache
uses: actions/cache@v4
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
Expand All @@ -94,10 +94,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PR Report tool
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: hrishikesh-kadam/setup-lcov@v1
uses: hrishikesh-kadam/setup-lcov@6c1aa0cc9e1c02f9f58f01ac599f1064ccc83470 # v1.1.0
- name: Validate code coverage
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: zgosalvez/github-actions-report-lcov@v3
uses: zgosalvez/github-actions-report-lcov@4eb99c09644c30cceb609413620bd9e1bf80ee79 # v6.0.1
with:
coverage-files: ./channel-sender/cover/lcov.info
minimum-coverage: 70
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'async-dataflow-docs'
on:
release:
types:
- released
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v6
# Next steps will only run if generation code templates have been changed
- name: Detect changes in generated code
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
filters: |
docs:
- 'docs/**'
- name: Set release mode
if: github.event_name == 'release'
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Setup Node.js
if: github.event_name == 'release' || steps.changes.outputs.docs == 'true'
uses: actions/setup-node@v6
with:
node-version-file: 'docs/.nvmrc'
- name: Install dependencies
if: github.event_name == 'release' || steps.changes.outputs.docs == 'true'
run: npm ci
working-directory: docs
- name: Build docs
if: github.event_name == 'release' || steps.changes.outputs.docs == 'true'
run: npm run build
working-directory: docs
- name: Upload artifact
if: github.event_name == 'release' || steps.changes.outputs.docs == 'true'
uses: actions/upload-pages-artifact@v4
with:
path: 'docs/build/'
- name: Deploy to GitHub Pages
if: github.event_name == 'release' || steps.changes.outputs.docs == 'true'
id: deployment
uses: actions/deploy-pages@v4
8 changes: 4 additions & 4 deletions .github/workflows/release-channel-sender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
working-directory: channel-sender
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Login to Docker Hub
uses: docker/login-action@v3
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Config Builder
run: docker buildx create --name mbuilder && docker buildx use mbuilder
- name: Docker Build Multiplatform
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-client-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
permissions:
id-token: write # Required for OIDC
contents: read
packages: write
jobs:
build:
defaults:
Expand Down
83 changes: 2 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,6 @@

The Async DataFlow component aims to deliver asynchronous responses in real time to client applications, thus enabling end-to-end asynchronois flows without losing the ability to respond in real time or eventually, send data to client applications as a result of asynchronous operations and oriented to `messages / commands / events` on the platform.

## Documentation

## Repository

- [Channel Sender](https://github.com/bancolombia/async-dataflow/tree/master/channel-sender) Distributed Elixir Cluster implementation of real time with websockets and notifications channels.

```mermaid
C4Dynamic
Boundary(aa, "Client side applications") {
Component(cli, "Single Page Application or Mobile App", "Javascript / Angular /Flutter", "")
}

Boundary(xx, "ADF") {
Component(sender, "Channel Sender", "", "")
}

Boundary(zz, "Backend") {
Component(abl, "Async business logic")
}

Rel(cli, sender, "create connection")
Rel(cli, abl, "Call Http or another entry point definition")
Rel(abl, cli, "Return Http Empty response")
Rel(abl, sender, "Send Response (Http)")
Rel(sender, cli, "Send Response (websocket)")

UpdateElementStyle(sender, $fontColor="black", $bgColor="orange", $borderColor="black")

UpdateRelStyle(cli, sender, $offsetX="-40", $offsetY="-20")
UpdateRelStyle(cli, abl, $offsetX="-240", $offsetY="-40")
UpdateRelStyle(abl, cli, $offsetX="30", $offsetY="-40")
UpdateRelStyle(abl, sender, $offsetX="-60", $offsetY="40")
UpdateRelStyle(sender, cli, $offsetX="-40", $offsetY="20")

UpdateLayoutConfig($c4ShapeInRow="2", $c4BoundaryInRow="2")
```


- [Channel Streams](https://github.com/bancolombia/async-dataflow/tree/master/channel-streams) Distributed Elixir Cluster implementation of a async messages router.

```mermaid
C4Dynamic

Boundary(zz, "Backend") {
Component(abl, "Async business logic")
SystemDb(bus, "Event bus")
}

Boundary(xx, "ADF") {
Component(sender, "Channel Sender", "", "")
Component(streams, "Channel Streams", "", "")
}

Boundary(aa, "Client side applications") {
Component(cli, "Single Page Application or Mobile App", "Javascript / Angular /Flutter", "")
}

Rel(abl, bus, "Emit event")
Rel(bus, streams, "Subscribe event")
Rel(streams, sender, "route [Http]")
Rel(sender, cli, "Push response [websocket]")

UpdateElementStyle(sender, $fontColor="black", $bgColor="orange", $borderColor="black")
UpdateElementStyle(streams, $fontColor="black", $bgColor="green", $borderColor="black")

UpdateRelStyle(abl, bus, $offsetX="-40", $offsetY="-40")
UpdateRelStyle(bus, streams, $offsetX="-40", $offsetY="-20")
UpdateRelStyle(streams, sender, $offsetX="-33", $offsetY="-20")
UpdateRelStyle(sender, cli, $offsetX="-40", $offsetY="-10")

UpdateLayoutConfig($c4ShapeInRow="2", $c4BoundaryInRow="1")
```


- [Client JS](https://github.com/bancolombia/async-dataflow/tree/master/clients/client-js) Javascript library for async data flow implementation for browsers.
- [Client Dart](https://github.com/bancolombia/async-dataflow/tree/master/clients/client-dart) Dart library for async data flow implementation for flutter applications.

- [Examples](https://github.com/bancolombia/async-dataflow/tree/master/examples)
The purpose of this project is to help the community to understand more the the async data flow component to implement in full asyncio solutions.

## How can I help?

Review the [issues](https://github.com/bancolombia/async-dataflow/issues). Read [how Contributing](https://github.com/bancolombia/async-dataflow/wiki/Contributing).
The documentation for this component is available in the [Async DataFlow Documentation Site](https://bancolombia.github.io/async-dataflow/).
2 changes: 1 addition & 1 deletion channel-sender/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.11.0
v24.12.0
4 changes: 2 additions & 2 deletions channel-sender/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 27.3
elixir 1.18.4-otp-27
erlang 28.3.1
elixir 1.19.5-otp-28
7 changes: 3 additions & 4 deletions channel-sender/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#===============
# Build Stage
#===============
FROM elixir:1.18.4-otp-27-alpine as build
FROM elixir:1.19.5-otp-28-alpine as build

ARG BUILD_ENV=prod

Expand Down Expand Up @@ -29,7 +29,7 @@ RUN mix release channel_sender_ex && \
#===================
# Deployment Stage
#===================
FROM alpine:3.22.2
FROM alpine:3.23

RUN apk upgrade --no-cache && \
apk add --no-cache \
Expand All @@ -52,5 +52,4 @@ USER adfuser
VOLUME /app/config

ENTRYPOINT ["/bin/bash"]
CMD ["/app/runner.sh"]

CMD ["/app/runner.sh"]
28 changes: 2 additions & 26 deletions channel-sender/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
# Channel Sender

[![Docker Hub](https://img.shields.io/docker/pulls/bancolombia/async-dataflow-channel-sender?label=Docker%20Hub)](https://hub.docker.com/repository/docker/bancolombia/async-dataflow-channel-sender)

- [Requirements](#requirements)
- [Install](#install)
- [Configuration](#configuration)
- [Run](#run)
- [Clients](#clients)

Distributed Elixir Cluster implementation of real time with websockets and notifications channels.

This service is part of the Async Dataflow project, which is a set of tools to facilitate the implementation
of real-time applications.

Channel sender main purpose is to allow backend services to send messages via a real time channel (websocket) to your
front end application(s) (web or mobile). Enabling you to implement real time notifications, updates, etc.

```mermaid
flowchart LR
subgraph
A(Backend service) -- send message --> B[ADF channel sender]
A2(Backend service) -- send message --> B
A3(Backend service) -- send message --> B
end
B -- send message --> C(Front end application)
```
See [Usage Documentation](https://bancolombia.github.io/async-dataflow/docs/channel-sender) for the Channel Sender component of the Async DataFlow project.

See detailed [docs](docs/main.md) for more information.
# Local Setup

## Requirements

Expand Down
6 changes: 3 additions & 3 deletions channel-sender/bench/single_socket_delivery_bench.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule SingleSocketDeliveryBench do
1000 -> raise "Websocket upgrade timeout!"
end

:gun.ws_send(conn, {:text, "Auth::#{secret}"})
:gun.ws_send(conn, stream, {:text, "Auth::#{secret}"})

data_string = receive do
{:gun_ws, ^conn, ^stream, {:text, data_string}} -> data_string
Expand Down Expand Up @@ -89,10 +89,10 @@ send_and_receive_sequential = fn {conn, stream, channel_id} ->
receive do
{:gun_ws, ^conn, ^stream, {:text, data}} ->
{message_id, _, _, _, _} = JsonEncoder.decode_message(data)
:gun.ws_send(conn, {:text, "Ack::" <> message_id})
:gun.ws_send(conn, stream, {:text, "Ack::" <> message_id})
{:gun_ws, ^conn, ^stream, {:binary, data}} ->
{message_id, _, _, _, _} = BinaryEncoder.decode_message(data)
:gun.ws_send(conn, {:text, "Ack::" <> message_id})
:gun.ws_send(conn, stream, {:text, "Ack::" <> message_id})
after
100 ->
raise "No message!"
Expand Down
3 changes: 2 additions & 1 deletion channel-sender/config/config-local.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
channel_sender_ex:
rest_port: 8081
socket_port: 8082
prometheus_port: 9568
secret_generator:
base: "aV4ZPOf7T7HX6GvbhwyBlDM8B9jfeiwi+9qkBnjXxUZXqAeTrehojWKHkV3U0kGc"
salt: "socket auth"
Expand Down Expand Up @@ -94,6 +93,8 @@ channel_sender_ex:
traces_endpoint: "http://localhost:4318"
traces_ignore_routes: ["/health", "/metrics"]
metrics:
enabled: true
prometheus_port: 9568
active_interval_minutes_count: 2
logger:
level: debug
Expand Down
3 changes: 2 additions & 1 deletion channel-sender/config/config-local1.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
channel_sender_ex:
rest_port: 8091
socket_port: 8092
prometheus_port: 8568
secret_generator:
base: "aV4ZPOf7T7HX6GvbhwyBlDM8B9jfeiwi+9qkBnjXxUZXqAeTrehojWKHkV3U0kGc"
salt: "socket auth"
Expand Down Expand Up @@ -82,6 +81,8 @@ channel_sender_ex:
traces_endpoint: "http://localhost:4318"
traces_ignore_routes: ["/health", "/metrics"]
metrics:
enabled: true
prometheus_port: 8568
active_interval_minutes_count: 2
logger:
level: debug
Expand Down
3 changes: 2 additions & 1 deletion channel-sender/config/config-local2.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
channel_sender_ex:
rest_port: 8071
socket_port: 8072
prometheus_port: 7568
secret_generator:
base: "aV4ZPOf7T7HX6GvbhwyBlDM8B9jfeiwi+9qkBnjXxUZXqAeTrehojWKHkV3U0kGc"
salt: "socket auth"
Expand Down Expand Up @@ -82,6 +81,8 @@ channel_sender_ex:
traces_endpoint: "http://localhost:4318"
traces_ignore_routes: ["/health", "/metrics"]
metrics:
enabled: true
prometheus_port: 7568
active_interval_minutes_count: 2
logger:
level: debug
Expand Down
Loading
Loading