forked from mtusi2026/mtusi2026lab7
lab7: безопасность, mTLS, OpenBao и PKI lifecycle
This commit is contained in:
@@ -106,8 +106,10 @@ func New(repo Repository, store Store, config Config, log *slog.Logger) *Worker
|
||||
// Run starts Concurrency consumer channels. It returns when the context is
|
||||
// cancelled or one consumer fails; the caller recreates the broker connection.
|
||||
func (w *Worker) Run(ctx context.Context, consumer Consumer) error {
|
||||
w.mu.Lock()
|
||||
w.consumer = consumer
|
||||
w.setRunning(true)
|
||||
w.running = true
|
||||
w.mu.Unlock()
|
||||
defer w.setRunning(false)
|
||||
|
||||
runCtx, cancel := context.WithCancel(ctx)
|
||||
@@ -155,13 +157,14 @@ func (w *Worker) Capacity() int { return w.config.Concurrency }
|
||||
func (w *Worker) Ready() (consumerRunning, brokerConnected bool) {
|
||||
w.mu.RLock()
|
||||
running := w.running
|
||||
consumer := w.consumer
|
||||
w.mu.RUnlock()
|
||||
|
||||
if w.consumer == nil {
|
||||
if consumer == nil {
|
||||
return running, false
|
||||
}
|
||||
|
||||
return running, w.consumer.Connected()
|
||||
return running, consumer.Connected()
|
||||
}
|
||||
|
||||
func (w *Worker) handle(ctx context.Context, delivery amqp.Delivery) broker.Outcome {
|
||||
|
||||
Reference in New Issue
Block a user