(events pii.EventStore, modelName string, retryAfter time.Duration)
| 58 | var admissionEventSeq atomic.Uint64 |
| 59 | |
| 60 | func recordAdmissionRejection(events pii.EventStore, modelName string, retryAfter time.Duration) { |
| 61 | if events == nil { |
| 62 | return |
| 63 | } |
| 64 | statusCode := http.StatusServiceUnavailable |
| 65 | durMS := retryAfter.Milliseconds() |
| 66 | id := fmt.Sprintf("adm_%d_%s", admissionEventSeq.Add(1), randHex(4)) |
| 67 | _ = events.Record(context.Background(), pii.PIIEvent{ |
| 68 | ID: id, |
| 69 | Kind: pii.KindAdmission, |
| 70 | Host: modelName, |
| 71 | StatusCode: statusCode, |
| 72 | DurationMS: durMS, |
| 73 | CreatedAt: time.Now().UTC(), |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | func randHex(n int) string { |
| 78 | b := make([]byte, n) |
no test coverage detected