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 Unit usually implements the Factory pattern.

Check out the aioli-rdbms extension for an example.

Import

To make use of an Extension, its Unit along with dependencies needs to be registered with the Application.

Once registered, the Extension’s Service(s) can be incorporated into other Units using integrate() or connect().

Example

Register the local users Unit 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 Unit Management CLI will be added, along with the https://pkgs.aioli.dev website for showing useful info about extension-type Units; their trust status, install instructions, author and license data, as well as links to source code and more.