Reserve table service. Use redis distributed lock to guarantee reliable reservations even when multiple instances of Reservatron are running. This service uses GraphQL API via this library.
- pagination. Easy way will be integrate querydsl and compose queries in repositories to support pagination on DB level
- filtering. Also querydsl could be used to optimise
requests like
getAllTables(filter: {tableId: 1})
- unsubscribe subscriptions on connection close (due to the strange bug subscriber's onConnect is not called)
- subscriptions in case of multiple instances. Need to send events with reservations to Kafka and publish updates for subscribed clients.
Ensure you've built Admin before.
sudo ./gradlew build docker -x test -x test_integration
sudo docker-compose up -d
export POSTGRES_HOST=localhost
export REDIS_HOST=localhost
./gradlew bootRun
./gradlew check
Graphql is used for communication. Make introspective query to get schema
for details.
Endpoint for query and mutations is /graphql
, for subscriptions is /subscriptions
Method: POST
Body:
mutation ReserveTable
{ reserveTable(input: {tableId: 1,
guest: "Test",
from: "2018-01-04T18:00:00.000+0000",
to: "2018-01-04T19:00:00.000+0000",
clientMutationId: "uuid"})
{status}
}
Response:
{
"data": {
"reserveTable": {
"status": "CONFLICT"
}
},
"errors": [],
"extensions": null
}
Method: POST
Body:
query {allTables
{edges {node {name reservations
{edges {node {guest from to}}}
}
}
}
}
Response:
{
"data": {
"allTables": {
"edges": [
{
"node": {
"name": "test",
"reservations": {
"edges": [
{
"node": {
"guest": "Test",
"from": "2018-01-04T18:00:00.000+0000",
"to": "2018-01-04T19:00:00.000+0000"
}
}
]
}
}
},
{
"node": {
"name": "test2",
"reservations": {
"edges": []
}
}
}
]
}
},
"errors": [],
"extensions": null
}
Websocket
Body:
subscription RealTimeReservationsSubscription {
newReservationMade(tableId: 1) {
guest
from
to
}
}
On every new subscription to this server you will receive a Reservation
.
Important! This repo is just an example of graphql usage. With multiple
instances of this service subscriptions won't work correctly, as one instance
doesn't receive events about subscription has been made from the other.
Important! Subscriptions unsubscribe feature is not working now.
CompletionStageMappingPublisher
's onSubscribe
is not called, thus link
between GraphqlSubscriber
and Subscription
can't be made. As a result,
when connection is closed we can't cancel subscription.