forked from sparckles/Robyn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add type stubs * Remove generic type stubs * Remove inconsistent docstrings
- Loading branch information
Showing
16 changed files
with
356 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import asyncio | ||
import multiprocessing as mp | ||
import os | ||
from inspect import signature | ||
from typing import Callable | ||
|
||
from multiprocess import Process | ||
from watchdog.observers import Observer | ||
|
||
from robyn.events import Events | ||
|
||
from .argument_parser import ArgumentParser | ||
from .dev_event_handler import EventHandler | ||
from .log_colors import Colors | ||
from .processpool import spawn_process | ||
from .responses import jsonify, static_file | ||
from .robyn import Server, SocketHeld | ||
from .router import MiddlewareRouter, Router, WebSocketRouter | ||
from .ws import WS | ||
|
||
|
||
class Robyn: | ||
"""This is the python wrapper for the Robyn binaries.""" | ||
|
||
def __init__(self, file_object: str) -> None: ... | ||
def before_request(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.before_request decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
... | ||
|
||
def after_request(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.after_request decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
... | ||
|
||
def add_directory( | ||
self, | ||
route: str, | ||
directory_path: str, | ||
index_file: str = ..., | ||
show_files_listing: str = ..., | ||
): ... | ||
def add_header(self, key: str, value: str) -> None: ... | ||
def add_web_socket(self, endpoint: str, ws: WS) -> None: ... | ||
def startup_handler(self, handler: Callable) -> None: ... | ||
def shutdown_handler(self, handler: Callable) -> None: ... | ||
def start(self, url: str = ..., port: int = ...) -> None: | ||
""" | ||
Starts the server | ||
:param port int: reperesents the port number at which the server is listening | ||
""" | ||
|
||
... | ||
def get(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.get decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
... | ||
def post(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.post decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
... | ||
def put(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.put decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... | ||
def delete(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.delete decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... | ||
def patch(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.patch decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... | ||
|
||
def head(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.head decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... | ||
def options(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.options decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... | ||
def connect(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.connect decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
... | ||
def trace(self, endpoint: str) -> Callable[..., None]: | ||
""" | ||
The @app.trace decorator to add a get route | ||
:param endpoint str: endpoint to server the route | ||
""" | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import argparse | ||
|
||
class ArgumentParser(argparse.ArgumentParser): | ||
def __init__(self) -> None: ... | ||
def num_processes(self): ... | ||
def workers(self): ... | ||
def is_dev(self): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from watchdog.events import FileSystemEvent, FileSystemEventHandler | ||
|
||
class EventHandler(FileSystemEventHandler): | ||
def __init__(self, file_name: str) -> None: ... | ||
def start_server_first_time(self) -> None: ... | ||
def on_any_event(self, event: FileSystemEvent) -> None: | ||
""" | ||
This function is a callback that will start a new server on every even change | ||
:param event FSEvent: a data structure with info about the events | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Events: | ||
STARTUP = ... | ||
SHUTDOWN = ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Colors: | ||
HEADER = ... | ||
OKBLUE = ... | ||
OKCYAN = ... | ||
OKGREEN = ... | ||
WARNING = ... | ||
FAIL = ... | ||
ENDC = ... | ||
BOLD = ... | ||
UNDERLINE = ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from numbers import Number | ||
from typing import Dict, Tuple | ||
|
||
from robyn.events import Events | ||
from robyn.robyn import SocketHeld | ||
from robyn.router import Route | ||
from robyn.ws import WS | ||
|
||
Directory = Tuple[str, str, str, str] | ||
Header = Tuple[str, str] | ||
|
||
def spawn_process( | ||
directories: Tuple[Directory, ...], | ||
headers: Tuple[Header, ...], | ||
routes: Tuple[Route, ...], | ||
middlewares: Tuple[Route, ...], | ||
web_sockets: Dict[str, WS], | ||
event_handlers: Dict[Events, list], | ||
socket: SocketHeld, | ||
workers: Number, | ||
) -> None: | ||
""" | ||
This function is called by the main process handler to create a server runtime. | ||
This functions allows one runtime per process. | ||
:param directories tuple: the list of all the directories and related data in a tuple | ||
:param headers tuple: All the global headers in a tuple | ||
:param routes Tuple[Route]: The routes touple, containing the description about every route. | ||
:param middlewares Tuple[Route]: The middleware router touple, containing the description about every route. | ||
:param web_sockets list: This is a list of all the web socket routes | ||
:param event_handlers Dict: This is an event dict that contains the event handlers | ||
:param socket SocketHeld: This is the main tcp socket, which is being shared across multiple processes. | ||
:param process_name string: This is the name given to the process to identify the process | ||
:param workers number: This is the name given to the process to identify the process | ||
""" |
Empty file.
Oops, something went wrong.