forked from mtusi2026/mtusi2026lab5
26 lines
628 B
Go
26 lines
628 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Worker contains the broker address and a process-unique consumer identity.
|
|
type Worker struct {
|
|
// BrokerAddress is a private Valkey Streams endpoint.
|
|
BrokerAddress string
|
|
// Consumer is never used as an unbounded metric label.
|
|
Consumer string
|
|
}
|
|
|
|
// NewWorker requires an explicit broker separate from the admission shards.
|
|
func NewWorker() (*Worker, error) {
|
|
address := os.Getenv("BROKER_ADDRESS")
|
|
if address == "" {
|
|
return nil, fmt.Errorf("BROKER_ADDRESS is required")
|
|
}
|
|
return &Worker{BrokerAddress: address, Consumer: uuid.NewString()}, nil
|
|
}
|