Stop tracking .env
It has been in the repository since the initial commit carrying the live database host, user and password. Removing it from the index stops that getting worse; the credentials are still in history and should be rotated, which needs coordinating with everything that reads them. Deployments should pass configuration as container environment rather than shipping a file — a file on disk is one `git add -f` away from being committed again. Also closes the last untested path: a shopper registration published over the broker rather than posted over HTTP. All three MQTT topics — order, customer and health — have now been fired against the live Mosquitto instance and acknowledged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,5 +118,31 @@ func main() {
|
||||
log.Fatal("publish health:", t.Error())
|
||||
}
|
||||
fmt.Println("\npublished a heartbeat to", healthTopic)
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// The registration uplink. Tested over HTTP early on; this is the same
|
||||
// service reached over the broker, which is the path a real till uses.
|
||||
custBatch, _ := json.Marshal(map[string]any{
|
||||
"schema": 1, "batch_id": "batch-cust-mqtt-0001",
|
||||
"store_id": locationID, "terminal_id": terminalID,
|
||||
"customers": []map[string]any{{
|
||||
"id": "3d7a0000-0000-4000-8000-000000000001",
|
||||
"mobile": "9840077777",
|
||||
"name": "MQTT Probe Shopper",
|
||||
"registered_at": time.Now().UTC().Format(time.RFC3339),
|
||||
"registered_by_terminal": terminalID,
|
||||
}},
|
||||
})
|
||||
custTopic := fmt.Sprintf("nearle/pos/%s/%s/customer", locationID, terminalID)
|
||||
if t := client.Publish(custTopic, 1, false, custBatch); t.Wait() && t.Error() != nil {
|
||||
log.Fatal("publish customer:", t.Error())
|
||||
}
|
||||
fmt.Println("published a registration to", custTopic)
|
||||
|
||||
select {
|
||||
case payload := <-acks:
|
||||
fmt.Println(" registration ACK:", string(payload))
|
||||
case <-time.After(20 * time.Second):
|
||||
fmt.Println(" NO ACK for the registration")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user