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:
Jacquin Antoine
2026-03-01 00:26:07 +01:00
parent 9bb6ae3106
commit 41e763ad02
5 changed files with 13 additions and 27 deletions

View File

@ -32,10 +32,10 @@ Tout le build et les tests s'exécutent dans des containers Docker :
```bash
# Build complet (binaire + tests + RPM)
./build.sh
make package-rpm
# Uniquement les tests
./test.sh
make test
# Build manuel avec Docker
docker build --target builder -t logcorrelator-builder .
@ -53,7 +53,7 @@ docker build --target runtime -t logcorrelator:latest .
```bash
# Build de l'image
./build.sh
docker build --target runtime -t logcorrelator:latest .
# Exécuter
docker run -d \
@ -68,15 +68,12 @@ docker run -d \
```bash
# Générer les packages
./build.sh
# Installer le package RPM (CentOS 7)
sudo yum install -y dist/rpm/centos7/logcorrelator-1.0.0-1.el7.x86_64.rpm
make package-rpm
# Installer le package RPM (Rocky Linux 8/9/10)
sudo dnf install -y dist/rpm/rocky8/logcorrelator-1.0.0-1.el8.x86_64.rpm
sudo dnf install -y dist/rpm/rocky9/logcorrelator-1.0.0-1.el9.x86_64.rpm
sudo dnf install -y dist/rpm/rocky10/logcorrelator-1.0.0-1.el10.x86_64.rpm
sudo dnf install -y dist/rpm/rocky8/logcorrelator-1.0.3-1.el8.x86_64.rpm
sudo dnf install -y dist/rpm/rocky9/logcorrelator-1.0.3-1.el9.x86_64.rpm
sudo dnf install -y dist/rpm/almalinux10/logcorrelator-1.0.3-1.el10.x86_64.rpm
# Activer et démarrer le service
sudo systemctl enable logcorrelator

View File

@ -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)
}

View File

@ -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 {

View File

@ -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()
}

View File

@ -2,7 +2,6 @@ package ports
import (
"context"
"time"
"github.com/logcorrelator/logcorrelator/internal/domain"
)
@ -35,11 +34,6 @@ type CorrelatedLogSink interface {
Name() string
}
// TimeProvider abstracts time for testability.
type TimeProvider interface {
Now() time.Time
}
// CorrelationProcessor defines the interface for the correlation service.
// This allows for easier testing and alternative implementations.
type CorrelationProcessor interface {