File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 11// balboa
2- // Copyright (c) 2019, DCSO GmbH
2+ // Copyright (c) 2019, 2025, DCSO GmbH
33
44package db
55
66import (
7- "gopkg.in/yaml.v2"
87 "net"
98
109 obs "github.com/DCSO/balboa/observation"
1110
1211 log "github.com/sirupsen/logrus"
12+ "gopkg.in/yaml.v2"
1313)
1414
1515type Backend struct {
@@ -109,8 +109,22 @@ func (db *RemoteBackend) ConsumeFeed(inChan chan obs.InputObservation) {
109109 wanted := w .Len ()
110110 n , err := w .WriteTo (* conn )
111111 if err != nil {
112- log .Warnf ("sending observation failed: %s" , err )
113- continue
112+ log .Warnf ("sending observation failed: %s, reconnecting" , err )
113+ (* conn ).Close ()
114+ // try to reconnect
115+ newConn , err := net .Dial ("tcp" , (* conn ).RemoteAddr ().String ())
116+ if err != nil {
117+ log .Warnf ("reconnecting to backend failed: %s" , err )
118+ continue
119+ }
120+ * conn = newConn
121+ // and try again
122+ n , err = w .WriteTo (* conn )
123+ if err != nil {
124+ log .Warnf ("retry sending observation failed: %s" , err )
125+ (* conn ).Close ()
126+ continue
127+ }
114128 }
115129 if n != int64 (wanted ) {
116130 log .Warnf ("short write" )
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ type InputObservation struct {
1818 SensorID string `codec:"I"`
1919 TimestampEnd time.Time `codec:"L"`
2020 TimestampStart time.Time `codec:"F"`
21- Tags map [string ]struct {} `codec:"G ,omitempty"`
22- Selectors map [interface {}]struct {} `codec:"S ,omitempty"`
21+ Tags map [string ]struct {} `codec:"- ,omitempty"`
22+ Selectors map [interface {}]struct {} `codec:"- ,omitempty"`
2323}
2424
2525// InChan is the global input channel delivering InputObservations from
You can’t perform that action at this time.
0 commit comments