refactor: remove unused code and fix documentation
- Remove CorrelationKeyFull() alias, use CorrelationKey() everywhere - Remove duplicate TimeProvider interface from ports/source.go - Remove unused time import from ports/source.go - Update README.md: replace ./build.sh and ./test.sh with make commands - Update RPM package names in README to match current version (1.0.3) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNormalizedEvent_CorrelationKeyFull(t *testing.T) {
|
||||
func TestNormalizedEvent_CorrelationKey(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
event *NormalizedEvent
|
||||
@ -39,7 +39,7 @@ func TestNormalizedEvent_CorrelationKeyFull(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
key := tt.event.CorrelationKeyFull()
|
||||
key := tt.event.CorrelationKey()
|
||||
if key != tt.expected {
|
||||
t.Errorf("expected %s, got %s", tt.expected, key)
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ func (s *CorrelationService) isBufferFull(source EventSource) bool {
|
||||
}
|
||||
|
||||
func (s *CorrelationService) processSourceA(event *NormalizedEvent) ([]CorrelatedLog, bool) {
|
||||
key := event.CorrelationKeyFull()
|
||||
key := event.CorrelationKey()
|
||||
|
||||
// Look for the first matching B event (one-to-one first match)
|
||||
if bEvent := s.findAndPopFirstMatch(s.bufferB, s.pendingB, key, func(other *NormalizedEvent) bool {
|
||||
@ -149,7 +149,7 @@ func (s *CorrelationService) processSourceA(event *NormalizedEvent) ([]Correlate
|
||||
}
|
||||
|
||||
func (s *CorrelationService) processSourceB(event *NormalizedEvent) ([]CorrelatedLog, bool) {
|
||||
key := event.CorrelationKeyFull()
|
||||
key := event.CorrelationKey()
|
||||
|
||||
// Look for the first matching A event (one-to-one first match)
|
||||
if aEvent := s.findAndPopFirstMatch(s.bufferA, s.pendingA, key, func(other *NormalizedEvent) bool {
|
||||
@ -178,7 +178,7 @@ func (s *CorrelationService) eventsMatch(a, b *NormalizedEvent) bool {
|
||||
}
|
||||
|
||||
func (s *CorrelationService) addEvent(event *NormalizedEvent) {
|
||||
key := event.CorrelationKeyFull()
|
||||
key := event.CorrelationKey()
|
||||
|
||||
switch event.Source {
|
||||
case SourceA:
|
||||
@ -205,7 +205,7 @@ func (s *CorrelationService) cleanBuffer(buffer *eventBuffer, pending map[string
|
||||
event := elem.Value.(*NormalizedEvent)
|
||||
if event.Timestamp.Before(cutoff) {
|
||||
next := elem.Next()
|
||||
key := event.CorrelationKeyFull()
|
||||
key := event.CorrelationKey()
|
||||
buffer.events.Remove(elem)
|
||||
pending[key] = removeElementFromSlice(pending[key], elem)
|
||||
if len(pending[key]) == 0 {
|
||||
|
||||
@ -30,8 +30,3 @@ type NormalizedEvent struct {
|
||||
func (e *NormalizedEvent) CorrelationKey() string {
|
||||
return e.SrcIP + ":" + strconv.Itoa(e.SrcPort)
|
||||
}
|
||||
|
||||
// CorrelationKeyFull returns a proper correlation key (alias for clarity).
|
||||
func (e *NormalizedEvent) CorrelationKeyFull() string {
|
||||
return e.CorrelationKey()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user