from ctrlstack import ctrl_cmd_method, ctrl_query_method, ctrl_method
class FooController(Controller):
@ctrl_cmd_method
def bar(self):
pass
@ctrl_query_method
def baz(self, x: int) -> str:
pass
@ctrl_method(ControllerMethodType.QUERY, "q")
def qux(self):
pass
= create_controller_server(FooController()) app
server
create_controller_server
create_controller_server(
controller: Controller,bool,
prepend_method_group: str]]
api_keys: Optional[List[-> FastAPI )
Get the controller server instance.
Arguments: - controller
(Controller): The controller to get the server for.
Returns: FastAPI: The controller server instance.
assert _is_port_free(_find_free_port())
start_local_controller_server_process
start_local_controller_server_process(|Callable[[], Controller],
controller: Controllerstr,
lockfile_path: int]
port: Optional[-> Tuple[int, int, bool] )
Start a local server for the given controller.
Arguments: - controller
(Controller|Callable[[], Controller]): The controller or a callable that returns the controller to run. - lockfile_path
(str): Path to the lockfile that stores the port and PID. - port
(Optional[int]): The port to run the server on. If None, a free port will be found.
get_local_controller_server_status
str) -> Tuple[int, int, bool] get_local_controller_server_status(lockfile_path:
Get the status of the server from the lockfile.
Arguments: - lockfile_path
(str): Path to the lockfile that stores the port and PID.
Returns: Tuple[int, int, bool]: A tuple containing the port number, process ID, and a boolean indicating if the server is running.
check_local_controller_server_process
check_local_controller_server_process(str
lockfile_path: -> Tuple[Optional[int], Optional[int], bool] )
Check if a local server process is running and return its port and PID.
Arguments: - lockfile_path
(str): Path to the lockfile that stores the port and PID. - port
(Optional[int]): The port to check. If None, the port from the lockfile will be used.
Returns: Tuple[Optional[int], Optional[int], bool]: A tuple containing the port number, process ID, and a boolean indicating if the server is running.
stop_local_controller_server_process
str) stop_local_controller_server_process(lockfile_path: