MCPcopy Create free account
hub / github.com/astercloud/aster / NewInMemoryAuditLog

Function NewInMemoryAuditLog

pkg/security/audit.go:402–430  ·  view source on GitHub ↗

NewInMemoryAuditLog 创建内存审计日志

(config *AuditConfiguration)

Source from the content-addressed store, hash-verified

400
401// NewInMemoryAuditLog 创建内存审计日志
402func NewInMemoryAuditLog(config *AuditConfiguration) *InMemoryAuditLog {
403 if config == nil {
404 config = &AuditConfiguration{
405 StorageType: StorageTypeMemory,
406 EnableCache: true,
407 CacheSize: 10000,
408 CacheTimeout: time.Minute * 5,
409 WorkerPoolSize: 5,
410 BatchSize: 100,
411 FlushInterval: time.Second * 10,
412 }
413 }
414
415 al := &InMemoryAuditLog{
416 events: make([]AuditEvent, 0),
417 config: config,
418 status: &AuditLogStatus{},
419 eventChan: make(chan AuditEvent, config.BatchSize*10),
420 workers: config.WorkerPoolSize,
421 done: make(chan struct{}),
422 }
423
424 // 启动工作协程
425 for range al.workers {
426 go al.eventWorker()
427 }
428
429 return al
430}
431
432// LogEvent 记录事件
433func (al *InMemoryAuditLog) LogEvent(event AuditEvent) error {

Calls 1

eventWorkerMethod · 0.95