Skip to content

cullinan.core.services

cullinan.core.services holds the advanced service base class and registry helpers. For most application code, import @service and dependency markers from cullinan.core.

Main exports

  • service
  • Service
  • Inject
  • InjectByName
  • Lazy

Compatibility registry exports:

  • ServiceRegistry
  • get_service_registry()
  • reset_service_registry()

Example

from cullinan.core.services import Service, service

@service
class UserService(Service):
    repo: UserRepository  # ← 构造注入

    def get_user(self, user_id: int):
        return self.repo.find_by_id(user_id)

For most code, use @service plus dependency markers and let the active ApplicationContext manage creation and lifecycle.

See also