This project is written in Go and acts similarly to the Pusher service. The project is designed using Event-Driven Architecture (EDA), which allows you to manage different systems indirectly and scalably using events. π―
-
Similar to Pusher: For sending and receiving events in real-time. π
-
EDA Architecture: The system is designed based on event-driven architecture. β‘
-
Scalable: Designed for high performance and scalability. π
-
API Keys: Secure connection to WebSocket using public key and secret key. π
This endpoint provides the public key and secret key.
{
"public_key": "your_public_key",
"secret_key": "your_secret_key"
}When connecting to Pusher, you need to send the public key in the route and the secret key in the header.
- Route: Send the public key in the route when establishing the Pusher connection. For example, the Pusher connection URL will look like this:
ws://ip:port/public_key// π Import the Pusher library
import Pusher from 'pusher-js';
// π Initialize Pusher WebSocket
const pusher = new Pusher('PUBLIC_KEY', { // Replace with your public key
wsHost: IP, // Running on localhost
wsPort: PORT, // Port where WebSocket is running
});
// π― Subscribe to a specific channel
const channel = pusher.subscribe(CHANNEL_NAME);
// π Listen for a specific event
channel.bind(EVENT_NAME, function(data) {
console.log('π© Data received:', data);
})π¨ Important: Ensure that the secret key is only sent in requests where it's necessary. For example, it should only be included in the Pusher connection request.
To set up the project, you first need to create the migrations using the following command:
go run cmd/main.go migration createAfter the migrations are created, you can run the project with the following command:
go run cmd/main.goFor sample code and further details, you can visit the following repository:
https://github.com/sajad-dev/eda-architecture-sample π
https://github.com/sajad-dev/eda-architecture-sample-laravel π
Mohammad Sajad Poorajam / Ω ΨΩ Ψ― Ψ³Ψ¬Ψ§Ψ― ΩΎΩΨ±ΨΉΨ¬Ω