feat(practice): add the code runner port and its TLS client

This commit is contained in:
shira committed 2026-10-11 09:48:44 +03:00
1 parent 53a125f2b5
commit facc1789b1
24 files changed
+3374 -6

No files matched your search

+12 -2
View File
@@ -37,6 +37,9 @@ type Application struct {
// mailSender is the transport selected by EMAIL_PROVIDER. Only the mail
// sending worker calls it.
mailSender outbound.MailSender
// codeRunner is the runner selected by CODE_RUNNER_URL: the disabled one
// when unset. Practice usecases receive it from here once they exist.
codeRunner outbound.CodeRunner
// relay publishes outbox events while the servers run. It is nil when
// the relay is disabled or the database is not configured.
relay *outboxrelay.Relay
@@ -127,8 +130,8 @@ func run(ctx context.Context, config config.Config, logger *slog.Logger) error {
}
// start prepares the application without opening listeners. The mail
// transport is selected before migrations, so a configuration that cannot
// start never changes the database. The demo policy seed and the mail quota
// transport and the code runner are selected before migrations, so a
// configuration that cannot start never changes the database. The demo policy seed and the mail quota
// report run after the migrations that create their tables.
func start(ctx context.Context, config config.Config, logger *slog.Logger) (*Application, func(), error) {
if err := config.Validate(); err != nil {
@@ -138,6 +141,10 @@ func start(ctx context.Context, config config.Config, logger *slog.Logger) (*App
if err != nil {
return nil, nil, fmt.Errorf("bootstrap.start - select mail transport: %w", err)
}
codeRunner, err := newCodeRunner(config, logger)
if err != nil {
return nil, nil, fmt.Errorf("bootstrap.start - select code runner: %w", err)
}
if err := migrateDatabase(ctx, config, logger); err != nil {
return nil, nil, fmt.Errorf("bootstrap.start - migrate database: %w", err)
}
@@ -149,6 +156,9 @@ func start(ctx context.Context, config config.Config, logger *slog.Logger) (*App
if err != nil {
return nil, nil, fmt.Errorf("bootstrap.start - initialize application: %w", err)
}
// No dependency needs the runner yet, so it is attached here rather than
// injected; the practice usecases will take it from the injector.
application.codeRunner = codeRunner
return application, cleanup, nil
}