Skip to content

heissonwillen/event-go

Repository files navigation

Event Go

Broadcast server sent events by sending HTTP calls.

Docker Image Version Docker Pulls GitHub branch check runs Coveralls GitHub go.mod Go version

Event Go demo


Table of contents


Features

  • Broadcast events: Server sent events are broadcasted once an authorized user sends an HTTP call.
  • Event storage: New clients immediately receive the latest events once they connect.
  • Dockerized Deployment: Simple setup with Docker and Docker Compose.
  • Production and Debug Modes: Easily switch between production and debug builds.

Docker deployment

To pull the image from the Docker registry and run it locally using compose.sample.yaml

docker compose --file compose.sample.yaml up -d

Alternatively, to build and run the local Dockerfile (useful for debugging purposes)

docker compose --file compose.dev.yaml up -d

Installation

Prerequisites

Clone the repository

git clone https://github.com/heissonwillen/event-go.git
cd event-go

Build and run

Local setup

To download the dependencies, and have the hot-reloading locally

go mod tidy && air

Alternatively, it's possible to run without hot-reloading (air)

go mod tidy && go run -v cmd/server/main.go

Running tests

go test ./... -v

Configuration

Environment variables

Variable Description Default Value
LISTEN_ADDR API listen address :8080
SQLITE_DB_PATH SQLite DB path tmp/event-go.sqlite
BASIC_AUTH_USER Username for /authorized endpoints admin
BASIC_AUTH_PASSWORD Password for /authorized endpoints pass

Endpoints

Method Endpoint Description
POST /authorized/events Broadcast a new event to all clients. The event is stored on the DB as a side-effect. It uses basic-auth - see environment variables section.
GET /events Receive stream of events. The latest event from the DB is broadcasted when a new client connects.

Contributing

  1. Fork the repository.
  2. Create a new branch: git checkout -b my-feature-branch
  3. Make your changes and add tests.
  4. Submit a pull request.

License

event-go is licensed under the MIT License.


Community and Support

About

Broadcast server sent events by sending HTTP calls.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published