feat(assessment): add the review band of attempt signals and the disclosed collector
This commit is contained in:
1 parent
68286af8b7
commit
b3c6dc870b
124 files changed
+13522
-633
No files matched your search
@@ -46,5 +46,11 @@ func newAssessmentHandler(
|
||||
pool.Close()
|
||||
return nil, nil, fmt.Errorf("bootstrap.newAssessmentHandler - create service: %w", err)
|
||||
}
|
||||
observer, err := newSignalObserver(keyring)
|
||||
if err != nil {
|
||||
pool.Close()
|
||||
return nil, nil, fmt.Errorf("bootstrap.newAssessmentHandler - create signal observer: %w", err)
|
||||
}
|
||||
service.WithSignalObserver(observer)
|
||||
return v1.NewAssessmentHandler(service), pool.Close, nil
|
||||
}
|
||||
@@ -35,5 +35,11 @@ func newAssessmentSignalHandler(
|
||||
pool.Close()
|
||||
return nil, nil, fmt.Errorf("bootstrap.newAssessmentSignalHandler - create service: %w", err)
|
||||
}
|
||||
return v1.NewAssessmentSignalHandler(service), pool.Close, nil
|
||||
observer, err := newSignalObserver(keyring)
|
||||
if err != nil {
|
||||
pool.Close()
|
||||
return nil, nil, fmt.Errorf("bootstrap.newAssessmentSignalHandler - create signal observer: %w", err)
|
||||
}
|
||||
service.WithSignalObserver(observer)
|
||||
return v1.NewAssessmentSignalHandler(service).WithNotice(service), pool.Close, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"lincodex/backend/internal/usecase/assessment"
|
||||
"lincodex/backend/internal/usecase/identity"
|
||||
)
|
||||
|
||||
// newSignalObserver derives the answer, session, and network digests of the
|
||||
// server signals from the identity keyring, so no separate secret is needed and
|
||||
// the digests change with IDENTITY_KEY_SECRET.
|
||||
func newSignalObserver(keyring *identity.Keyring) (*assessment.SignalObserver, error) {
|
||||
observer, err := assessment.NewSignalObserver(keyring)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bootstrap.newSignalObserver - create observer: %w", err)
|
||||
}
|
||||
return observer, nil
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"lincodex/backend/internal/adapter/secondary/postgres"
|
||||
"lincodex/backend/internal/adapter/secondary/prometheus"
|
||||
"lincodex/backend/internal/port/inbound"
|
||||
"lincodex/backend/internal/usecase/assessment"
|
||||
"lincodex/backend/internal/worker/jobrunner"
|
||||
"lincodex/backend/internal/worker/retry"
|
||||
)
|
||||
@@ -29,11 +30,12 @@ const (
|
||||
var _ jobrunner.Metrics = (*prometheus.Metrics)(nil)
|
||||
|
||||
// jobHandlers lists the scheduled job handlers, one per kind. A product
|
||||
// module adds its handler here, for example the invitation response
|
||||
// deadline, and the worker then claims jobs of that kind with the next
|
||||
// deployment. Jobs of a kind without a handler wait in the database.
|
||||
func jobHandlers() []inbound.JobHandler {
|
||||
return []inbound.JobHandler{}
|
||||
// module adds its handler here, and the worker then claims jobs of that kind
|
||||
// with the next deployment. Jobs of a kind without a handler wait in the
|
||||
// database. The only kind now is the computation of the assessment review
|
||||
// band, which can never block or change a result.
|
||||
func jobHandlers(logger *slog.Logger) []inbound.JobHandler {
|
||||
return []inbound.JobHandler{assessment.NewSignalReviewJob(logger)}
|
||||
}
|
||||
|
||||
func newJobWorker(
|
||||
@@ -42,7 +44,7 @@ func newJobWorker(
|
||||
logger *slog.Logger,
|
||||
metrics *prometheus.Metrics,
|
||||
) (*jobrunner.Worker, func(), error) {
|
||||
return buildJobWorker(ctx, settings, logger, metrics, jobHandlers())
|
||||
return buildJobWorker(ctx, settings, logger, metrics, jobHandlers(logger.With(slog.String("component", "assessment_review"))))
|
||||
}
|
||||
|
||||
// buildJobWorker builds the scheduled job worker and the PostgreSQL pool it
|
||||
|
||||
@@ -55,8 +55,9 @@ func TestBuildJobWorkerSkipsWithoutWork(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBootstrapRegistersNoJobKindYet(t *testing.T) {
|
||||
if handlers := jobHandlers(); len(handlers) != 0 {
|
||||
func TestBootstrapRegistersTheReviewJobKind(t *testing.T) {
|
||||
handlers := jobHandlers(slog.New(slog.DiscardHandler))
|
||||
if len(handlers) != 1 || handlers[0].JobKind() != "assessment.signal_review" {
|
||||
t.Fatalf("jobHandlers() = %v; update the documentation when the registered job kinds change", handlers)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user