Skip to content

Commit 4bffa6f

Browse files
committed
.
1 parent a98dc74 commit 4bffa6f

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
FEATURES:
44

55
- multiple file processing with `takreplay`. Like `./takreplay -format stats data/log/*.tak`
6+
- cot drops metric added
7+
8+
FIXES:
9+
10+
- xml cot handler fixed
611

712
# 0.17.0
813

cmd/goatak_server/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func NewApp(config *AppConfig) *App {
105105
config: config,
106106
packageManager: pm.NewPackageManager(filepath.Join(config.dataDir, "mp")),
107107
users: repository.NewFileUserRepo(config.usersFile),
108-
ch: make(chan *cot.CotMessage, 20),
108+
ch: make(chan *cot.CotMessage, 100),
109109
handlers: sync.Map{},
110110
changeCb: callbacks.New[*model.Item](),
111111
deleteCb: callbacks.New[string](),
@@ -202,7 +202,12 @@ func (app *App) NewCotMessage(msg *cot.CotMessage) {
202202
}
203203

204204
messagesMetric.With(prometheus.Labels{"scope": msg.Scope, "msg_type": t}).Inc()
205-
app.ch <- msg
205+
206+
select {
207+
case app.ch <- msg:
208+
default:
209+
dropMetric.With(prometheus.Labels{"scope": msg.Scope, "reason": "main_ch"}).Inc()
210+
}
206211
}
207212
}
208213

cmd/goatak_server/marti_api.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/kdudkov/goatak/cmd/goatak_server/mp"
1919
"github.com/kdudkov/goatak/internal/pm"
20+
"github.com/kdudkov/goatak/pkg/cot"
2021

2122
"github.com/kdudkov/goatak/pkg/cotproto"
2223
"github.com/kdudkov/goatak/pkg/model"
@@ -592,12 +593,18 @@ func getVideoPostHandler(app *App) air.Handler {
592593

593594
func getXmlHandler(app *App) air.Handler {
594595
return func(req *air.Request, res *air.Response) error {
595-
var evt *cotproto.CotEvent
596+
uid := getStringParam(req, "uid")
596597

597-
if item := app.items.Get(getStringParam(req, "uid")); item != nil {
598+
if uid == "" {
599+
res.Status = http.StatusBadRequest
600+
return res.WriteString("error")
601+
}
602+
603+
var evt *cotproto.CotEvent
604+
if item := app.items.Get(uid); item != nil {
598605
evt = item.GetMsg().GetTakMessage().GetCotEvent()
599606
} else {
600-
di := app.missions.GetPoint(getStringParam(req, "uid"))
607+
di := app.missions.GetPoint(uid)
601608
if di != nil {
602609
evt = di.GetEvent()
603610
}
@@ -609,7 +616,7 @@ func getXmlHandler(app *App) air.Handler {
609616
return nil
610617
}
611618

612-
return res.WriteXML(evt)
619+
return res.WriteXML(cot.CotToEvent(evt))
613620
}
614621
}
615622

cmd/goatak_server/metrics.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ var (
1313
Help: "The total number of cots processed",
1414
}, []string{"scope", "msg_type"})
1515

16+
dropMetric = promauto.NewCounterVec(prometheus.CounterOpts{
17+
Namespace: "goatak",
18+
Name: "cots_dropped",
19+
Help: "The total size of cots processed",
20+
}, []string{"scope", "reason"})
21+
1622
connectionsMetric = promauto.NewGaugeVec(prometheus.GaugeOpts{
1723
Namespace: "goatak",
1824
Name: "connections",

cmd/mm/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ func (app *App) Run(cmd string, args []string) {
8181
switch cmd {
8282
case "files", "mp":
8383
app.listFiles()
84-
case "get":
84+
case "file", "get":
8585
if len(args) != 2 {
8686
fmt.Println("need hash and name")
87+
return
8788
}
8889
app.getFile(args[0], args[1])
8990
default:

0 commit comments

Comments
 (0)