Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the handler of accesslog convertor uses endpoints cache map #119

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions framework/model/metric/accesslog_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ import (
"errors"
data_accesslog "github.com/envoyproxy/go-control-plane/envoy/data/accesslog/v3"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
"sync"
)

type AccessLogConvertor struct {
name string // handler name
cacheResult map[string]map[string]string // meta -> value
cacheResultCopy map[string]map[string]string
handler func(logEntry []*data_accesslog.HTTPAccessLogEntry, clientSet *kubernetes.Clientset) (map[string]map[string]string, error)
handler func(logEntry []*data_accesslog.HTTPAccessLogEntry) (map[string]map[string]string, error)
convertorLock sync.RWMutex
clientSet *kubernetes.Clientset
}

func NewAccessLogConvertor(config AccessLogConvertorConfig) *AccessLogConvertor {
return &AccessLogConvertor{
name: config.Name,
clientSet: config.ClientSet,
handler: config.Handler,
cacheResult: make(map[string]map[string]string),
cacheResultCopy: make(map[string]map[string]string),
Expand All @@ -40,7 +37,7 @@ func (alc *AccessLogConvertor) CacheResultCopy() map[string]map[string]string {

func (alc *AccessLogConvertor) Convert(logEntry []*data_accesslog.HTTPAccessLogEntry) error {
log := log.WithField("reporter", "AccessLogConvertor").WithField("function", "Convert")
tmpResult, err := alc.handler(logEntry, alc.clientSet)
tmpResult, err := alc.handler(logEntry)
if err != nil {
return err
}
Expand Down
6 changes: 2 additions & 4 deletions framework/model/metric/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
data_accesslog "github.com/envoyproxy/go-control-plane/envoy/data/accesslog/v3"
prometheus "github.com/prometheus/client_golang/api/prometheus/v1"
prometheusModel "github.com/prometheus/common/model"
"k8s.io/client-go/kubernetes"
"slime.io/slime/framework/model/trigger"
)

Expand Down Expand Up @@ -44,7 +43,6 @@ type AccessLogSourceConfig struct {
}

type AccessLogConvertorConfig struct {
Name string // handler name
ClientSet *kubernetes.Clientset
Handler func(logEntry []*data_accesslog.HTTPAccessLogEntry, clientSet *kubernetes.Clientset) (map[string]map[string]string, error)
Name string // handler name
Handler func(logEntry []*data_accesslog.HTTPAccessLogEntry) (map[string]map[string]string, error)
}