Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elct9620/liveness
The Rack middleware to provide health check endpoints.
https://github.com/elct9620/liveness
rack rails ruby
Last synced: about 2 months ago
JSON representation
The Rack middleware to provide health check endpoints.
- Host: GitHub
- URL: https://github.com/elct9620/liveness
- Owner: elct9620
- License: apache-2.0
- Created: 2022-01-18T08:15:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-16T00:54:15.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T18:40:39.819Z (9 months ago)
- Topics: rack, rails, ruby
- Language: Ruby
- Homepage:
- Size: 69.3 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Liveness [![Ruby](https://github.com/elct9620/liveness/actions/workflows/main.yml/badge.svg)](https://github.com/elct9620/liveness/actions/workflows/main.yml)
===The Rack middleware to provide health check endpoints.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'liveness'
```## Usage
Configuration the Liveness to add dependency.
```ruby
Liveness.config do |c|
c.add :postgres, timeout: 10
end
```### Named Dependency
```ruby
Liveness.config do |c|
c.add :postgres, name: :primary_db, timeout: 10
c.add :postgres, name: :read_replica, timeout: 10
end
```
### Access Protected```ruby
Liveness.config do |c|
c.token = 'unm@tnh8ugq-WAR-myr'
end
```To access the status endpoint should add `?token=unm@tnh8ugq-WAR-myr` params to access it.
```ruby
Liveness.config do |c|
c.ip_whitelist = ['192.168.0.0/24']
end
```To access the status endpoint should called from `127.0.0.1` or `::1` or under `192.168.0.0/24`.
### Customize Connector
```ruby
Liveness.config do |c|
c.add :redis, timeout: 10 do
Redis.new(url: 'redis://example:6379/15')
end
end
```### Rails Application
Mount the `Liveness::Status` to `config/routes.rb`
```ruby
Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.htmlmount Liveness::Status => '/health'
end
```## Dependency Providers
| Name | Description |
|------------|-------------------------------------------------------|
| `postgres` | The PostgreSQL adapter which for `ActiveRecord::Base` |
| `mysql` | The MySQL adapter which for `ActiveRecord::Base` |
| `redis` | Test Redis via `redis-rb` gem via `#ping` method |## Roadmap
* [x] Status Endpoint
* [ ] Metrics Endpoint (for single dependency)
* [ ] Dependency Provider
* [ ] PostgreSQL
* [x] ActiveRecord
* [ ] Sequel
* [ ] MySQL
* [x] ActiveRecord
* [ ] Sequel
* [x] Redis
* [ ] HTTP Endpoint## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/elct9620/liveness. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/elct9620/liveness/blob/main/CODE_OF_CONDUCT.md).
## Code of Conduct
Everyone interacting in the Liveness project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elct9620/liveness/blob/main/CODE_OF_CONDUCT.md).