Fix linter errors
This commit is contained in:
parent
3433fa4a6e
commit
7b19beaf5d
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ElasticSearch_INDEX_DEFAULT = "lotus-pubsub"
|
ElasticSearchDefaultIndex = "lotus-pubsub"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewElasticSearchTransport(connectionString string, elasticsearchIndex string) (TracerTransport, error) {
|
func NewElasticSearchTransport(connectionString string, elasticsearchIndex string) (TracerTransport, error) {
|
||||||
@ -42,7 +42,7 @@ func NewElasticSearchTransport(connectionString string, elasticsearchIndex strin
|
|||||||
if elasticsearchIndex != "" {
|
if elasticsearchIndex != "" {
|
||||||
esIndex = elasticsearchIndex
|
esIndex = elasticsearchIndex
|
||||||
} else {
|
} else {
|
||||||
esIndex = ElasticSearch_INDEX_DEFAULT
|
esIndex = ElasticSearchDefaultIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
return &elasticSearchTransport{
|
return &elasticSearchTransport{
|
||||||
@ -83,10 +83,15 @@ func (est *elasticSearchTransport) Transport(evt TracerTransportEvent) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
|
||||||
|
err = res.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if res.IsError() {
|
if res.IsError() {
|
||||||
return fmt.Errorf("[%s] Error indexing document ID=%s", res.Status(), req.DocumentID)
|
return fmt.Errorf("[%s] Error indexing document ID=%s", res.Status(), req.DocumentID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,18 @@ type lotusTracer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TraceEvent_PEER_SCORES pubsub_pb.TraceEvent_Type = 100
|
TraceEventPeerScores pubsub_pb.TraceEvent_Type = 100
|
||||||
)
|
)
|
||||||
|
|
||||||
type LotusTraceEvent struct {
|
type LotusTraceEvent struct {
|
||||||
Type pubsub_pb.TraceEvent_Type `json:"type,omitempty"`
|
Type pubsub_pb.TraceEvent_Type `json:"type,omitempty"`
|
||||||
PeerID string `json:"peerID,omitempty"`
|
PeerID string `json:"peerID,omitempty"`
|
||||||
Timestamp *int64 `json:"timestamp,omitempty"`
|
Timestamp *int64 `json:"timestamp,omitempty"`
|
||||||
PeerScore TraceEvent_PeerScore `json:"peerScore,omitempty"`
|
PeerScore TraceEventPeerScore `json:"peerScore,omitempty"`
|
||||||
SourceAuth string `json:"sourceAuth,omitempty"`
|
SourceAuth string `json:"sourceAuth,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TraceEvent_PeerScore struct {
|
type TraceEventPeerScore struct {
|
||||||
PeerID string `json:"peerID"`
|
PeerID string `json:"peerID"`
|
||||||
Score float32 `json:"score"`
|
Score float32 `json:"score"`
|
||||||
}
|
}
|
||||||
@ -53,11 +53,11 @@ func (lt *lotusTracer) PeerScores(scores map[peer.ID]*pubsub.PeerScoreSnapshot)
|
|||||||
now := time.Now().UnixNano()
|
now := time.Now().UnixNano()
|
||||||
for pid, score := range scores {
|
for pid, score := range scores {
|
||||||
evt := &LotusTraceEvent{
|
evt := &LotusTraceEvent{
|
||||||
Type: *TraceEvent_PEER_SCORES.Enum(),
|
Type: *TraceEventPeerScores.Enum(),
|
||||||
PeerID: lt.pid.Pretty(),
|
PeerID: lt.pid.Pretty(),
|
||||||
Timestamp: &now,
|
Timestamp: &now,
|
||||||
SourceAuth: lt.sa,
|
SourceAuth: lt.sa,
|
||||||
PeerScore: TraceEvent_PeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)},
|
PeerScore: TraceEventPeerScore{PeerID: pid.Pretty(), Score: float32(score.Score)},
|
||||||
}
|
}
|
||||||
|
|
||||||
lt.TraceLotusEvent(evt)
|
lt.TraceLotusEvent(evt)
|
||||||
|
Loading…
Reference in New Issue
Block a user