Info¶
An Extension is comprised of one or more Services deriving from BaseService
and typically
creates an abstraction layer for accessing a remote system. Furthermore, this type of Package usually implements the
Factory pattern.
Check out the aioli-rdbms extension for an example.
Import¶
To make use of an Extension, its Package along with dependencies needs to be registered with the Application.
Once registered, the Extension’s Service(s) can be incorporated into other Packages using
integrate()
or connect()
.
Example
Register the local users Package and its dependency; aioli_rdbms.
import aioli_rdbms
import toml
from aioli import Application
import .users
app = Application(
config=toml.load("aioli.cfg"),
packages=[users, aioli_rdbms]
)
The aioli_rdbms.Service can now be attached to users.UsersService:
from aioli import BaseService
from aioli_rdbms import DatabaseService
from .database import UserModel
class UsersService(BaseService):
db = None
async def on_startup(self):
self.db = (
self.integrate(DatabaseService)
.use_model(UserModel)
)
async def get_one(user_id):
return await self.db.get_one(pk=user_id)
...
Publish¶
Shortly, a Package Management CLI will be added, along with the https://pkgs.aioli.dev website for showing useful info about extension-type Packages; their trust status, install instructions, author and license data, as well as links to source code and more.