shipany.bot.servers
shipany.bot.servers package
Submodules
shipany.bot.servers.bot module
class shipany.bot.servers.bot.BotServer
Bases: object
Base class for bot servers.
serve(flow, app_config)
Start the server.
- Parameters:
- flow (Flow) — the flow to be used by the server
- app_config (ApplicationConfig) — the application configuration
- self (t.Self)
- Returns: coroutine to start the server in the event loop
- Return type: t.Coroutine[t.Any, t.Any, None]
shipany.bot.servers.schedule module
class shipany.bot.servers.schedule.ScheduleServer
Bases: object
Base class for schedule servers.
async serve(flow, app_config)
Start the server.
- Parameters:
- flow (Flow) — the flow to be used by the server
- app_config (ApplicationConfig) — the application configuration
- self (t.Self)
- Return type: None
add_job(*args, **kwargs)
Add a job to the scheduler.
- Parameters: self (Self)
- Return type: None
shipany.bot.servers.web module
The module contains the event dispatcher classes for the web application.
In order to handle startup, updates, and shutdown events, one can implement the corresponding dispatcher classes. These classes are asynchronous callables that must be injected into the application during start-up time.
inject library is used to bind the dispatcher classes to the corresponding.
It doesn’t require the user to inherit from the dispatcher classes, but callers
will rely on the interface provided by the classes.
(see inject.configure())
Examples:
from shipany.bot.server import webimport inject
class MyOnStartupDispatcher(web.OnStartupDispatcher): async def __call__(self): print("I am starting up")
inject.configure(lambda binder: binder.bind(events.OnStartupDispatcher, MyOnStartupDispatcher()))class shipany.bot.servers.web.WebServer
Bases: object
Base class for web servers.
serve(flow, app_config)
Start the server.
- Parameters:
- flow (Flow) — the flow to be used by the server
- app_config (ApplicationConfig) — the application configuration
- self (t.Self)
- Returns: coroutine to start the server in the event loop
- Return type: t.Coroutine[t.Any, t.Any, None]
class shipany.bot.servers.web.OnStartupDispatcher
Bases: object
Asynchronous callable class to handle startup events.
class shipany.bot.servers.web.OnUpdatesDispatcher
Bases: object
Asynchronous callable class to handle updates events.
class shipany.bot.servers.web.OnShutdownDispatcher
Bases: object
Asynchronous callable class to handle shutdown events.
Module contents
servers is a package that contains abstract server classes that serve the bot’s functionality.
Servers are responsible for handling incoming requests and/or sending responses.