/Go_GuestListService

A guest list http service implemented in Go

Primary LanguageGo

Task Overview

Implement a guest list service for a company's end of the year party! The venue has not been chosen yet so the number of tables and the capacity are subject to change.

When the party begins, guests will arrive with an entourage. This party may not be the size indicated on the guest list. However, if it is expected that the guest's table can accommodate the extra people, then the whole party should be let in. Otherwise, they will be turned away. Guests will also leave throughout the course of the party. Note that when a guest leaves, their accompanying guests will leave with them.

At any point in the party, the following data should be known:

  • Number of guests at the party
  • How many empty seats there are

REST API

Add a guest to the guestlist

If there is insufficient space at the specified table, then an error should be thrown.

POST /guest_list/name
body: 
{
    "table": int,
    "accompanying_guests": int
}
response: 
{
    "name": "string"
}

Get the guest list

GET /guest_list
response: 
{
    "guests": [
        {
            "name": "string",
            "table": int,
            "accompanying_guests": int
        }, ...
    ]
}

Guest Arrives

A guest may arrive with an entourage that is not the size indicated at the guest list. If the table is expected to have space for the extras, allow them to come. Otherwise, this method should throw an error.

PUT /guests/name
body:
{
    "accompanying_guests": int
}
response:
{
    "name": "string"
}

Guest Leaves

When a guest leaves, all their accompanying guests leave as well.

DELETE /guests/name

Get arrived guests

GET /guests
response: 
{
    "guests": [
        {
            "name": "string",
            "accompanying_guests": int,
            "time_arrived": "string"
        }
    ]
}

Count number of empty seats

GET /seats_empty
response:
{
    "seats_empty": int
}

Instructions

To run the application:

make docker-up

To run the tests

go test -v $(go list ./... | grep test)