https://github.com/smartupio/handyman
Lightweight library for managing and retrieving maintenance status for a Java web service
https://github.com/smartupio/handyman
api-gateway filter java maintenance maintenance-mode maintenance-status ops s3 servlet zuul
Last synced: 3 months ago
JSON representation
Lightweight library for managing and retrieving maintenance status for a Java web service
- Host: GitHub
- URL: https://github.com/smartupio/handyman
- Owner: smartupio
- License: other
- Created: 2018-02-07T08:57:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T15:03:32.000Z (over 7 years ago)
- Last Synced: 2025-02-06T16:58:53.474Z (4 months ago)
- Topics: api-gateway, filter, java, maintenance, maintenance-mode, maintenance-status, ops, s3, servlet, zuul
- Language: Java
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SmartUp Handyman
## What does it do?
This project is meant to solve the simple problem of activating, inactivating and interrogating the status of a maintenance mode flag in a Java web application.
[](https://travis-ci.org/smartupio/handyman)
## Modules
* handyman-core - core models and interfaces
* handyman-parent - maven parent pom for easy dependency management
* handyman-s3 - implementation that stores and retrieves the maintenance mode settings from S3
* handyman-zuul - Zuul filter to check maintenance mode and short-circuit requests if it is enabled
* handyman-sample - Sample code to show you how to use it## Core classes
#### `MaintenanceStatusManager`
Interface to set the maintenance status.```java
void setMaintenanceStatus(MaintenanceStatus status);
```#### `MaintenanceStatusProvider`
Interface for retrieving the maintenance status.```java
MaintenanceStatus getStatus();
```#### `InMemoryMaintenanceStatusService`
Solely for testing purposes, or for really simple, single instance deployments. It is purely in-memory and does not persist maintenance status anywhere.#### `CachingMaintenanceStatusProvider`
Provided a delegate `MaintenanceStatusProvider` called origin it is going to cache and periodically refresh the maintenance status.You can provide the refresh interval, which defaults to 10 000 milliseconds.
## Backends
### S3 backend
To use the S3 backend you'll have to build an `S3MaintenanceStatusService`. You can use the nested builder to do so.Example:
```java
public S3MaintenanceStatusService s3Service() {
return S3MaintenanceStatusService.builder()
.withAmazonS3(
AmazonS3ClientBuilder.standard()
.build()
)
.withBucketName(BUCKET_NAME)
.withFileName(S3_FILE_NAME)
.build();
}```
## Filters
Filters allow you to short circuit the incoming request-response flow and quickly return [HTTP 503 (Service Unavailable)](
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503).**IMPORTANT** In servlet context each request is going to hit your filters, no matter your choice of tech(Java Servlet Filter, Spring Once-Per-Request, Zuul, etc), you most probably want to use the `CachingMaintenanceStatusProvider` to avoid making too many round trips to the flag providing backend.
### Zuul Filter
Contains `MaintenanceZuulFilter` which is a "pre" filter in Zuul terms. It's going to stop the filter chain and respond to the incoming request without routing to origin.