5 An API for the worker

This chapter covers

  • Understanding the purpose of the worker API
  • Implementing methods to handle API requests
  • Creating a server to listen for API requests
  • Starting, stopping, and listing tasks via the API

In chapter 4, we implemented the core features of the worker: pulling tasks off its queue and then starting or stopping them. Those core features alone, however, do not make the worker complete. We need a way to expose those core features so a manager, which will be the exclusive user, running on a different machine can make use of them. To do this, we’re going to wrap the worker’s core functionality in an application programming interface, or API.

The API will be simple, as you can see in figure 5.1, providing the ...

Get Build an Orchestrator in Go (From Scratch) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.