forked from praekeltfoundation/vault-audit-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.go
34 lines (27 loc) · 822 Bytes
/
queue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package auditexporter
import (
"github.com/hashicorp/vault/audit"
)
// AuditEntryQueue is a q for audit entries.
type AuditEntryQueue struct {
channel chan interface{}
}
// NewAuditEntryQueue creates an new AuditEntryQueue
// TODO: Add buffer size, send timeout, dropping on error?
func NewAuditEntryQueue() *AuditEntryQueue {
return &AuditEntryQueue{channel: make(chan interface{})}
}
// Close closes the underlying channels
func (q *AuditEntryQueue) Close() {
close(q.channel)
}
// Receive returns a channel to receive AuditEntry instances from.
func (q *AuditEntryQueue) Receive() <-chan interface{} {
return q.channel
}
func (q *AuditEntryQueue) HandleRequest(req *audit.AuditRequestEntry) {
q.channel <- req
}
func (q *AuditEntryQueue) HandleResponse(res *audit.AuditResponseEntry) {
q.channel <- res
}