Giter VIP home page Giter VIP logo

llcfreedom-space / fs-app-health-checks Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 210 KB

The Health Checks Library for Swift is a simple and easy-to-use way to implement health checks for your server-side Swift applications. It is designed specifically for the Vapor framework and also conforms to the RFC Health Check Response Format for HTTP APIs.

License: GNU Affero General Public License v3.0

Swift 100.00%
health-check health-checks swift swift-package-manager swift5 vapor vapor-4 vapor-swift

fs-app-health-checks's Introduction

fs-app-health-checks

Swift Version License GitHub release (with filter) Read the Docs example workflow example workflow example workflow example workflow codecov

This repository offers a wide collection of health checks features for widely used services and platforms.

Health Checks Library for Swift

The Health Checks Library for Swift is a simple and easy-to-use way to implement health checks for your server-side Swift applications. It is designed specifically for the Vapor framework and also conforms to the RFC Health Check Response Format for HTTP APIs.

Features

  • A set of pre-defined health checks that cover common server-side functionality, such as database connectivity, HTTP connectivity, and memory usage.
  • The ability to create custom health checks to monitor your application's specific needs.
  • A simple API that makes it easy to implement health checks in your Vapor application.
  • Conforms to the RFC Health Check Response Format for HTTP APIs.

Installation

App Health Checks is available with Swift Package Manager. The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding App Health Checks as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/LLCFreedom-Space/fs-app-health-checks.git", from: "1.0.0")
]

Links

LLC Freedom Space โ€“ @LLCFreedomSpace โ€“ [email protected]

Distributed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3. See LICENSE.md for more information.

GitHub

fs-app-health-checks's People

Contributors

gulivero1773 avatar mcmikius avatar

Stargazers

 avatar

Watchers

 avatar

fs-app-health-checks's Issues

Add uptime

Need to add uptime data

The function should return application uptime result.

Result example:
{ "componentType": "system", "observedValue": 1209600.245, "observedUnit": "s", "status": "pass", "time": "2018-01-17T03:36:48Z" }

Also need add unit tests

Add check ConsulKV connection

Need to add a connection check with ConsulKV

The function should take the ConsulKV connection options and return check the connection result.

Connection options example:
ConsulOptions: { let hostName: String let port: Int let requireHttps: Bool let requireBasicAuthentication : Bool let username: String? let password: String? }

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Also need add unit tests

Add check Kafka Producer connection

Need to add a connection check with Kafka Producer

The function should take the Kafka Producer connection options and return check the connection result.

Connection options example:
brokers: "localhost:9092"

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Also need add unit tests

Add application health check

Need to add application health check

Result example:
{ "status": "pass", "version": "1", "releaseId": "1.2.2", "notes": [""], "output": "", "serviceId": "f03e522f-1f44-4062-9b55-9587f91c9c41", "description": "health of authz service", "checks": { }, "links": { "about": "http://api.example.com/about/authz", "http://api.x.io/rel/thresholds": "http://api.x.io/about/authz/thresholds" } }

Also need add unit tests

PostgreDatabase Mock for Unit Testing

Problem

Currently, it is impossible to write unit tests for the PostgreDatabase functionality because it directly interacts with a running PostgreSQL server. This is inconvenient because it:

  • Slows down development
  • Requires a PostgreSQL server to be present
  • Does not allow testing code in isolation

** Solution**
Make PostgreDatabase available as a Mock for writing unit tests. This will allow:

  • Testing PostgreDatabase code in isolation
  • Speeding up development
  • Not depending on the presence of a PostgreSQL server

Describe alternatives you've considered

  • Use a test PostgreSQL server. This is not very convenient because it requires its installation and configuration.
  • Do not write tests for PostgreDatabase functionality. This is not recommended as it reduces the code quality.

Additional context
None

Add check Redis connection

Need to add a connection check with Redis

The function should take the Redis connection options and return check the connection result.

Connection options example:
hostname: String, port: Int = RedisConnection.Configuration.defaultPort, password: String? = nil, tlsConfiguration: TLSConfiguration? = nil, database: Int? = nil, pool: [PoolOptions](https://api.vapor.codes/redis/documentation/redis/redisconfiguration/pooloptions) = .init()
or
serverAddresses: [SocketAddress], password: String? = nil, tlsConfiguration: TLSConfiguration? = nil, tlsHostname: String? = nil, database: Int? = nil, pool: [PoolOptions](https://api.vapor.codes/redis/documentation/redis/redisconfiguration/pooloptions) = .init()
or
url: URL, tlsConfiguration: TLSConfiguration? = nil, pool: [PoolOptions](https://api.vapor.codes/redis/documentation/redis/redisconfiguration/pooloptions) = .init()
or
url string: String, tlsConfiguration: TLSConfiguration? = nil, pool: [PoolOptions](https://api.vapor.codes/redis/documentation/redis/redisconfiguration/pooloptions) = .init()

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Need divides cases for data store and pub-sub mode

Also need add unit tests

Add check MongoDB connection

Need to add a connection check with MongoDB

The function should take the MongoDB connection options and return check the connection result.

Connection options example:
connectionString: "<connection string>"

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Also need add unit tests

Add check psql connection

Need to add a connection check with PostgreSQL

The function should take the POSTGRESQL connection options and return check the connection result.

Connection options example:
hostname: "localhost", username: "username", password: "password", database: "database"
or
url: "<connection string>"

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Also need add unit tests

Add check Kafka Consumer connection

Need to add a connection check with Kafka Consumer

The function should take the Kafka Consumer connection options and return check the connection result.

Connection options example:
brokers: "localhost:9092"

Result example:
{ "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 75, "status": "warn", "time": "2018-01-17T03:36:48Z", "output": "", "links": { "self": "http://api.example.com/dbnode/dfd6cf2b/health" } }

Also need add unit tests

Unable to Generate Swift Documentation

Describe the bug
GitHub Actions are failing to generate DocC documentation for the Library.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a GitHub workflow to use a DocC generation action (e.g., actions/checkout@v3, swift-tools/generate-documentation@latest).
  2. Push your code changes to the repository.
  3. Observe the workflow failing in the Actions tab of your repository.

Expected behavior
The workflow should successfully build your project, generate DocC documentation, and potentially deploy it to GitHub Pages.

Additional context

  • This issue can manifest in various ways, including DocC generation errors, missing documentation artifacts, or deployment failures.
  • Refer to the workflow logs for specific error messages.

Redis Mock for Unit Testing

Problem

Currently, it is impossible to write unit tests for the Redis Health Check functionality because it directly depends on a running Redis server. This is inconvenient because it:

  • Slows down development
  • Requires a Redis server to be present
  • Does not allow testing code in isolation

Solution

Make Redis available as a Mock for writing unit tests. This will allow:

  • Testing Redis Health Check code in isolation
  • Speeding up development
  • Not depending on the presence of a Redis server

Describe alternatives you've considered

  • Use a test Redis server. This is not very convenient because it requires its installation and configuration.
  • Do not write tests for Redis Health Check. This is not recommended as it reduces the code quality.

Additional context

None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.