pub struct ContainerBuilder { /* private fields */ }Expand description
Builder for constructing a ServiceContainer with all dependencies.
§Example
// Development with in-memory repositories
let container = ContainerBuilder::new()
.with_in_memory_repositories()
.build();
// Testing with custom mock repositories
let container = ContainerBuilder::new()
.with_creator_repository(Arc::new(mock_creator_repo))
.with_article_repository(Arc::new(mock_article_repo))
.with_transaction_repository(Arc::new(mock_transaction_repo))
.with_access_token_repository(Arc::new(mock_access_repo))
.with_fork_repository(Arc::new(mock_fork_repo))
.with_event_stream_repository(Arc::new(mock_event_stream_repo))
.build();Implementations§
Source§impl ContainerBuilder
impl ContainerBuilder
Sourcepub fn with_in_memory_repositories(self) -> Self
pub fn with_in_memory_repositories(self) -> Self
Configure all repositories with in-memory implementations.
This is the recommended setup for development and testing. For production, use specific repository setters with persistent implementations.
Sourcepub fn with_creator_repository(
self,
repository: Arc<dyn CreatorRepository>,
) -> Self
pub fn with_creator_repository( self, repository: Arc<dyn CreatorRepository>, ) -> Self
Set a custom creator repository.
Sourcepub fn with_article_repository(
self,
repository: Arc<dyn ArticleRepository>,
) -> Self
pub fn with_article_repository( self, repository: Arc<dyn ArticleRepository>, ) -> Self
Set a custom article repository.
Sourcepub fn with_transaction_repository(
self,
repository: Arc<dyn TransactionRepository>,
) -> Self
pub fn with_transaction_repository( self, repository: Arc<dyn TransactionRepository>, ) -> Self
Set a custom transaction repository.
Sourcepub fn with_access_token_repository(
self,
repository: Arc<dyn AccessTokenRepository>,
) -> Self
pub fn with_access_token_repository( self, repository: Arc<dyn AccessTokenRepository>, ) -> Self
Set a custom access token repository.
Sourcepub fn with_fork_repository(self, repository: Arc<dyn ForkRepository>) -> Self
pub fn with_fork_repository(self, repository: Arc<dyn ForkRepository>) -> Self
Set a custom fork repository.
Sourcepub fn with_event_stream_repository(
self,
repository: Arc<dyn EventStreamRepository>,
) -> Self
pub fn with_event_stream_repository( self, repository: Arc<dyn EventStreamRepository>, ) -> Self
Set a custom event stream repository.
Sourcepub fn with_system_repositories(self, repos: SystemRepositories) -> Self
pub fn with_system_repositories(self, repos: SystemRepositories) -> Self
Wire event-sourced system repositories from a SystemRepositories instance.
This replaces in-memory metadata storage with durable, event-sourced
repositories backed by AllSource’s own WAL. Call this after
SystemBootstrap::initialize() succeeds.
If not called, the container will have no system repositories (backward-compatible).
Sourcepub fn with_tenant_repository(
self,
repository: Arc<dyn TenantRepository>,
) -> Self
pub fn with_tenant_repository( self, repository: Arc<dyn TenantRepository>, ) -> Self
Set a custom tenant repository.
Sourcepub fn with_audit_repository(
self,
repository: Arc<dyn AuditEventRepository>,
) -> Self
pub fn with_audit_repository( self, repository: Arc<dyn AuditEventRepository>, ) -> Self
Set a custom audit repository.
Sourcepub fn build(self) -> ServiceContainer
pub fn build(self) -> ServiceContainer
Build the ServiceContainer.
§Panics
Panics if any required repository has not been set.
Use with_in_memory_repositories() to set all repositories at once,
or set each one individually.
Sourcepub fn try_build(self) -> Result<ServiceContainer, ContainerBuilderError>
pub fn try_build(self) -> Result<ServiceContainer, ContainerBuilderError>
Try to build the ServiceContainer, returning an error if any repository is missing.
This is a safer alternative to build() that doesn’t panic.