Skip to content

Commit

Permalink
wip: module refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelloeater committed Jul 8, 2023
1 parent d167d55 commit fa6336d
Show file tree
Hide file tree
Showing 21 changed files with 416 additions and 254 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

```mermaid
flowchart
docker_compose
--> caddy --serves--> gatus & api_server
docker_compose
--creates--> api_server & caddy & config_gen
caddy
--serves--> gatus & api_server
api_server & config_gen
--uses--> db
config_gen
--creates config for--> gatus
api_server --> db
config_gen --server to monitor--> gatus
docker_compose --> config_gen
cron --> updater --> config_gen
```
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3'
vars:
BUILD_DIR: fedi_gatus
BUILD_DIR: config_gen
tasks:
default:
- task: test
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ services:
# restart: on-failure
image: fedi_api
environment:
- PYTHONPATH="${PYTHONPATH}:/fedi_gatus"
- PYTHONPATH="${PYTHONPATH}:/config_gen"
build:
context: .
dockerfile: Dockerfile
entrypoint: [ "python3", "fedi_api/api.py" ]
entrypoint: [ "python3", "api_server/api.py" ]

ports:
- "0.0.0.0:8080:8080"
68 changes: 68 additions & 0 deletions docs/fedi_gatus/config_gen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Module fedi_gatus.config_gen
============================

Functions
---------


`generate_endpoints(endpoint_list: [<class 'dict'>])`
:


`generate_full_config()`
:


`generate_ui()`
:

Classes
-------

`Endpoint()`
:

### Class variables

`conditions`
:

`interval`
: int([x]) -> integer
int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.__int__(). For floating point
numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4

`name`
: str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

`url`
: str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.
13 changes: 13 additions & 0 deletions docs/fedi_gatus/data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Module fedi_gatus.data
======================

Functions
---------


`generate_top_instances()`
:


`get_raw_data()`
:
82 changes: 82 additions & 0 deletions docs/fedi_gatus/db.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Module fedi_gatus.db
====================

Functions
---------


`setup_db_connection()`
:

Classes
-------

`Data(*args, **kwargs)`
:

### Ancestors (in MRO)

* fedi_gatus.db.DataModel
* fedi_gatus.db.ModelBase
* peewee.Model
* peewee._metaclass_helper_
* peewee.Node

### Class variables

`id`
:

`timestamp`
:

### Methods

`get(self, num_minutes_to_get: int) ‑> list`
: Takes time range of past mins, and returns list of db rows w/ temp data

`insert(self) ‑> None`
:

`DataModel(*args, **kwargs)`
:

### Ancestors (in MRO)

* fedi_gatus.db.ModelBase
* peewee.Model
* peewee._metaclass_helper_
* peewee.Node

### Descendants

* fedi_gatus.db.Data

### Class variables

`id`
:

`timestamp`
:

`ModelBase(*args, **kwargs)`
:

### Ancestors (in MRO)

* peewee.Model
* peewee._metaclass_helper_
* peewee.Node

### Descendants

* fedi_gatus.db.DataModel

### Class variables

`DoesNotExist`
: Common base class for all non-exit exceptions.

`id`
:
8 changes: 8 additions & 0 deletions docs/fedi_gatus/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Module fedi_gatus
=================

Sub-modules
-----------
* fedi_gatus.config_gen
* fedi_gatus.data
* fedi_gatus.db
Empty file removed fedi_api/__init__.py
Empty file.
36 changes: 0 additions & 36 deletions fedi_gatus/__main__.py

This file was deleted.

4 changes: 1 addition & 3 deletions fedi_api/api.py → fedi_gatus/api_server/api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import json
import logging
import os
import time

import uvicorn
from fastapi import FastAPI
from starlette import status
from starlette.responses import JSONResponse, RedirectResponse
from starlette.responses import RedirectResponse

if os.getenv("LOG_LEVEL") is None:
logging.basicConfig(level=logging.WARNING)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import yaml

import fedi_gatus.data
import data

# example template
x = """
Expand All @@ -18,7 +18,7 @@ class Endpoint:
conditions = [str]


def generate_endpoints(endpoint_list: [dict]):
def Generate_endpoints(endpoint_list: [dict]):
list_out = []
for i in endpoint_list:
o = Endpoint()
Expand Down Expand Up @@ -48,5 +48,5 @@ def generate_ui():

def generate_full_config():
u = generate_ui()
e = generate_endpoints(fedi_gatus.data.generate_top_instances())
e = Generate_endpoints(data.generate_top_instances())
return u + e
File renamed without changes.
41 changes: 0 additions & 41 deletions fedi_gatus/db.py

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion fedi_db/db.py → fedi_gatus/shared/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import peewee as p

DB_NAME = "data.db"
DB_NAME = "data.shared"


def setup_db_connection():
Expand Down
18 changes: 0 additions & 18 deletions gatus_template.yaml

This file was deleted.

Loading

0 comments on commit fa6336d

Please sign in to comment.