Skip to content

Demo - worker application

Yokai's showroom provides a worker demo application.

Overview

This worker demo application is a simple subscriber to Pub/Sub.

It provides:

  • a Yokai application container, with the worker module to offer a subscriber worker using the fxgcppubsub contrib module
  • a Pub/Sub emulator container, with preconfigured topic and subscription
  • a Pub/Sub emulator UI container, preconfigured to work with the emulator container
  • a Jaeger container to collect the application traces

Layout

This demo application is following the recommended project layout:

  • cmd/: entry points
  • configs/: configuration files
  • internal/:
    • worker/: workers
    • bootstrap.go: bootstrap
    • register.go: dependencies registration

Makefile

This demo application provides a Makefile:

make up     # start the docker compose stack
make down   # stop the docker compose stack
make logs   # stream the docker compose stack logs
make fresh  # refresh the docker compose stack
make test   # run tests
make lint   # run linter

Usage

Start the application

To start the application, simply run:

make fresh

After a short moment, the application will offer:

Message publication

You can use the Pub/Sub emulator UI to publish a message to the preconfigured topic:

http://localhost:8680/project/demo-project/topic/demo-topic

Message subscription

Check your application logs by running:

make logs

You will see the SubscribeWorker subscribed to Pub/Sub in action, logging the received messages.