About¶
The typical Aioli extension-type Package manages one or more Service objects, provides an API of its own, and may contain Controller code as well.
Create¶
Extensions make use of the BaseService
class and
usually implements the Factory pattern
teamed by the integrate()
method.
Check out the aioli-rdbms extension for an example.
Use¶
Extensions are registered with the Application
, just like a regular Package
–
and usually have their Services incorporated into other Packages.
Example
Register the local users Package and its dependency, aioli_rdbms.
import aioli_rdbms
from .packages import users
app = Application(
packages=[
("/users", users),
(None, 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):
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.